Python FastAPI

Can be added by calling the add-api mcp tool. This will scaffold out and run a Python FastAPI and is intended to handle the business logic of our distributed system. Instead of adding dependencies manually, either you or the coding agent should call the <your-api-name>-add-dependencies tool, which will install and validate them. The API endpoints available through your API should be defined in modules/<your-api-name>/src/backend/routes/. You can also visit http://localhost:3030/docs in your browser to view the automatically generated documentation for your API endpoints. To implement business logic for couchbase and temporal you or your agent should call <your-api-name>-add-couchbase-client and <your-api-name>-add-temporal-client first, which will add <your-api-name>-add-couchbase-model and <your-api-name>-add-workflow. The couchbase tool helps you and the agent to set up models in your API to do CRUD operations on your couchbase documents. Set up through mcp tools follows best practices identified by Bluetext to guarantee maintainable code and good DevX, e.g. by raising errors as soon as syntax errors are introduced to the code base. The API is configured for hot reload, which allows you to review changes as soon as you save them. This also raises errors early during development for timely fixes. Furthermore, the feature makes manual container restarts obsolete for most use cases. Other setups in place to leverage those features are:

  • environment variable handling by injecting them in modules/<your-api-name>/polytope.yml and using them in a dedicated file at modules/<your-api-name>/src/backend/conf/, e.g. modules/<your-api-name>/src/backend/conf/couchbase.py for username and password for connecting to couchbase.

  • Temporal workflow handling and validation at modules/<your-api-name>/src/backend/workflows/ which is utilized by the <your-api-name>-add-workflow. The API is served on http://localhost:3030 once added.

Last updated