Authentication and Authorization API built with FastAPI.
- Python 3.14+
- PostgreSQL 18+
- uv
Or alternatively:
- Docker and Docker Compose
- Install dependencies:
uv sync- Set up PostgreSQL database and configure environment variables:
cp .env.example .env
# Edit .env with your database credentialsThe easiest way to run the service is with Docker Compose.
- Copy and configure environment variables:
cp .env.example .env
# Edit .env - at minimum set SECRET_KEY- Start the services:
docker compose up -dView logs:
docker compose logs -f apiStop services:
docker compose downStop and remove volumes (reset database):
docker compose down -vRebuild after code changes:
docker compose build && docker compose up -d| Service | URL |
|---|---|
| API | http://localhost:8000 |
| Swagger Docs | http://localhost:8000/docs |
| ReDoc | http://localhost:8000/redoc |
| PostgreSQL | localhost:5433 |
Start the development server:
uv run uvicorn src.main:app --reloadWith custom host and port:
uv run uvicorn src.main:app --reload --host 0.0.0.0 --port 8000The API will be available at http://localhost:8000. Interactive docs at http://localhost:8000/docs.
Note: Migrations are automatically applied on startup (upgrade to head).
Migrations are managed with Alembic.
Auto-generate migration from model changes:
uv run alembic revision --autogenerate -m "description of changes"Create an empty migration:
uv run alembic revision -m "description of changes"Upgrade to the latest version (head):
uv run alembic upgrade headUpgrade by one revision:
uv run alembic upgrade +1Apply a specific migration by revision ID:
uv run alembic upgrade <revision_id>Downgrade by one revision:
uv run alembic downgrade -1Downgrade to a specific revision:
uv run alembic downgrade <revision_id>Downgrade to base (remove all migrations):
uv run alembic downgrade baseShow current revision:
uv run alembic currentShow migration history:
uv run alembic historyShow pending migrations:
uv run alembic history --indicate-currentTests require a PostgreSQL test database. By default, tests use:
postgresql+asyncpg://hecate:hecate@localhost:5432/hecate_sentinel_test
Override with the TEST_DATABASE_URL environment variable if needed.
uv run pytestWith verbose output:
uv run pytest -vCore utility tests:
uv run pytest tests/core/ -vService tests:
uv run pytest tests/services/ -vAPI endpoint tests:
uv run pytest tests/api/ -vuv run pytest tests/api/test_auth.py -vuv run pytest tests/api/test_auth.py::TestAuthLogin::test_login_success -vuv run pytest --cov=src --cov-report=term-missingGenerate HTML coverage report:
uv run pytest --cov=src --cov-report=htmluv run pytest -n autohecate-sentinel/
├── alembic/ # Database migrations
│ ├── versions/ # Migration scripts
│ └── env.py # Alembic configuration
├── src/
│ ├── api/ # API route handlers
│ ├── core/ # Core utilities (security, geoip, etc.)
│ ├── models/ # SQLAlchemy models
│ ├── schemas/ # Pydantic schemas
│ ├── services/ # Business logic services
│ └── main.py # Application entry point
├── tests/
│ ├── api/ # API endpoint tests
│ ├── core/ # Core utility tests
│ ├── services/ # Service tests
│ └── conftest.py # Test fixtures
├── alembic.ini # Alembic settings
├── compose.yaml # Docker Compose configuration
├── Dockerfile # Container build instructions
├── pyproject.toml # Project dependencies
└── pytest.ini # Pytest configuration