FastAPI backend for the FairShare expense splitting application.
This API provides the backend services for managing expense groups, tracking expenses, calculating balances, and handling user authentication.
- Python 3.12+
- uv (recommended)
- Install dependencies using uv:
uv sync- Run the development server:
docker compose up --buildThe API will be available at http://127.0.0.1:8000
This project uses Alembic for database schema migrations.
Migrations run automatically when the container starts. However, you can also run them manually:
# Migrations should be run inside container
docker compose exec api bash
# Generate a new migration
uv run alembic revision --autogenerate -m "Add user table"
# Apply migrations
uv run alembic upgrade head
# Rollback migrations
uv run alembic downgrade -1When creating new database models:
- Define the model in the appropriate module's
models.pyfile - Import the model in
src/db/models/__init__.py(critical for Alembic to detect it) - Generate a migration:
uv run alembic revision --autogenerate -m "Description" - Review the generated migration file in
src/alembic/versions/ - Apply the migration:
uv run alembic upgrade head
Once the server is running, you can access:
- Interactive API docs:
http://127.0.0.1:8000/docs - Alternative docs:
http://127.0.0.1:8000/redoc