# 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.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.bluetext.dev/tech-stack-overview/python-fastapi.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
