- Create a focused branch for the change.
- Update or add an Alembic migration when the database schema changes.
- Keep HTTP concerns in routers and business rules in services.
- Reuse repositories for database access instead of adding queries to route handlers.
- Update the API or frontend documentation when behavior changes.
- Run the validation commands below before opening a pull request.
# Install dependencies
poetry install
# Start the API with reload
poetry run uvicorn app.core.main:app --reload --host 0.0.0.0 --port 8888
# Apply migrations
poetry run alembic upgrade head
# Inspect migration state
poetry run alembic current
poetry run alembic history
# Check Python syntax
python -m compileall appcd frontend
yarn install
yarn dev
yarn lint
yarn buildFor a new resource or use case, use this sequence:
- Add or update SQLAlchemy models under
app/db/models/. - Generate and review an Alembic revision.
- Add Pydantic schemas under
app/schemas/. - Implement persistence methods in a repository.
- Implement business logic in a service.
- Expose the feature through a router and register it in
app/core/main.py. - Add the corresponding frontend service, types, page, or admin component.
- Document the endpoints in
docs/api.md.
poetry run alembic revision --autogenerate -m "describe the schema change"
poetry run alembic upgrade headAutogenerated migrations must be reviewed manually, especially enum changes, nullable constraints, foreign keys, indexes, and data migrations. Do not edit an already-applied migration; create a new revision instead.
- The API starts successfully with the documented environment variables.
GET /health/readyanswers200with the database reachable.poetry run alembic upgrade headsucceeds on a clean database.- Protected routes reject unauthenticated requests.
- Admin routes reject regular users.
python -m compileall appcompletes without errors.yarn lintcompletes without errors.yarn buildcompletes without errors.- Documentation contains no local secrets or machine-specific URLs.
poetry run ruff check . && poetry run ruff format --check .
poetry run pytest --cov # needs Docker (testcontainers) or TEST_DATABASE_URL
poetry run pytest -n auto --cov # in parallel (pytest-xdist): one database per worker
poetry run pip-audit
cd frontend && yarn eslint . --max-warnings 0 && yarn tsc -b && yarn test:cov && yarn buildTests use a throw-away PostgreSQL started by testcontainers; set TEST_DATABASE_URL=postgresql+asyncpg://user:pass@host:port/db to use an existing one. The schema is built once per run with alembic upgrade head; data is truncated after every test. CI (.github/workflows/ci.yml) runs the same checks plus content, Docker image and secret scans. After changing an endpoint run poetry run python scripts/gen_api_docs.py and yarn gen:api (in frontend/) — CI fails if the docs or generated types are stale.
- A license file has not yet been added.
- Production database access is intentionally not part of this repository's tooling; see
docs/audit/for the owner-side checklists.