- Purpose: FastAPI API scaffold with Docker Compose, uv, and async Postgres access.
- Scope: API + Postgres with Alembic migrations; LLM integration remains a stub.
- Audience: Project collaborators.
app/FastAPI application packageDockerfileAPI container builddocker-compose.ymlLocal orchestration.python-versionPython version for uvpyproject.tomlPython project metadata and dependenciesuv.lockDependency lockfile (generated by uv)
- Install uv: https://docs.astral.sh/uv/getting-started/installation/
- Create the local environment and lockfile:
uv sync
- Configure database env vars:
cp .env.db.example .env.db- Update
POSTGRES_PASSWORDin.env.db
- Configure API auth:
cp .env.api.example .env.api- Update
API_TOKENin.env.api
- Local dev:
uv run uvicorn app.main:app --reload --host 0.0.0.0 --port 8000
- Docker:
docker compose up --build -d
- Verify:
curl http://localhost:8000/healthcurl http://localhost:8000/docker compose exec db pg_isready -U texet -d texetcurl http://localhost:8000/db/healthcurl -H "Authorization: Bearer <API_TOKEN>" -H "Content-Type: application/json" -X POST http://localhost:8000/chat -d '{"user_id":"u1","message":"hello"}'
- Migrations use Alembic and the
DATABASE_URLfrom the running Compose stack. - Define or update models in
app/models.py, then generate a migration. - Create a new migration:
make migration name=add_speakers
- Apply migrations:
make migrate
- If running locally (outside Docker), set
DATABASE_URLbefore running Alembic.
- Not wired yet.
- Add a package:
uv add <package>
- Upgrade a package:
uv lock --upgrade-package <package>
- Ensure the DB is running:
docker compose up -d db
- Run the connection test inside the Compose network (uses
DATABASE_URL_TESTpointing atdb):docker compose run --rm api uv run pytest tests/test_db_connection.py
- The test database is
texet_testinside the same Postgres container. - Tests apply Alembic migrations to
texet_testbefore running. - Run chat endpoint tests:
uv run pytest tests/test_chat_endpoint.py
- Run all tests with coverage (local):
uv run pytest --cov
- Run all tests with coverage (Docker):
docker compose run --rm api uv run pytest --cov
- Lint:
uv run ruff check .
- Format:
uv run ruff format .
- Type check:
uv run mypy
- Vulnerability audit:
uv run pip-audit
- Combined:
uv run ruff check . && uv run ruff format . && uv run mypy && uv run pip-audit
make startbuilds and starts the stack.make stopstops and removes the stack (including volumes).make testruns the full test suite with coverage (requiresmake startfirst).make cleanruns linting, formatting, type checks, and vulnerability audit (requiresmake startfirst).make migration name=...creates a new Alembic revision (requiresmake startfirst).make migrateapplies Alembic migrations (requiresmake startfirst).