Async Python API backend built with Litestar, SQLAlchemy, and PostgreSQL. Features JWT authentication, role-based permissions, and a modular architecture.
uv sync # Install dependencies
cp config{.example,}.toml # Copy config (edit if necessary)
just run # Run development server# Database migrations
just db upgrade --no-prompt # Apply migrations
# Code quality
just format # Format code with ruff
just lint # Lint and auto-fix
just ty # Type checking with ty
just pyrefly # Type checking with pyrefly
# Testing
just test # Run all tests
just test tests/accounts/ # Run specific tests
uv run pytest -v --tb=no # Custom pytest options- app/main.py - Application factory
- app/config.py - Settings management (uses
config.toml) - app/db.py - SQLAlchemy configuration
- app/models/ - ORM models
- app/api/ - Feature modules by domain (accounts, etc.)
- OAuth2 password bearer flow with JWT tokens
- Password hashing with Argon2
- Role-based access control via guards
- Guards:
has_permission(),has_role(),has_any_permission(),has_all_permissions() - Superuser role bypasses permission checks
- Typed SQLAlchemy 2.x model
- Advanced Alchemy base models with UUIDv7 primary keys
Edit config.toml or set environment variables:
database_url- PostgreSQL connection URLsecret_key- JWT secret keycors_allowed_origins- List of allowed CORS originssuperuser_role_name- Role with all permissions
Uses pytest with Docker PostgreSQL via pytest-databases:
- Session-scoped test database per worker
- Function-scoped
clean_databasefixture - Parallel testing supported with
pytest-xdist