FastAPI backend for the NeroSpatial platform.
- Python 3.11+
- uv package manager
- Install dependencies using uv:
uv sync- Create a
.envfile from the example:
cp .env.example .env- Run the application:
uv run uvicorn main:app --reloadOr using Python directly:
uv run python main.pyGET /health- Detailed health check with dependency statusGET /ready- Readiness probe (Kubernetes/load balancer)GET /live- Liveness probe (Kubernetes)
GET /helloworld- Hello world endpoint
Start infrastructure services (PostgreSQL, Redis, Jaeger) using Docker Compose:
docker compose -f docker-compose.infra.yml up -dThis will start:
- PostgreSQL on port 5432
- Redis on port 6379
- Jaeger (tracing) on ports 4317 (OTLP) and 16686 (UI)
The database schema is automatically initialized when the PostgreSQL container starts for the first time via scripts/init-db.sql.
Generate JWT RS256 keys for authentication:
./scripts/generate-keys.shThis creates keys/private.pem and keys/public.pem. Store these in Azure Key Vault for production.
Set up Azure Key Vault and upload secrets:
./scripts/setup-keyvault.shThis script will:
- Create Key Vault (if not exists)
- Create Service Principal with proper permissions
- Upload JWT keys and other secrets
- Output credentials for your
.envfile
Configuration is managed through a hierarchy:
-
Azure App Configuration (single source of truth for production/staging)
- Non-secret settings (URLs, ports, feature flags)
- Environment-specific configuration using labels
-
Azure Key Vault (secrets)
- Passwords, JWT keys, OAuth credentials
- Referenced from App Configuration
-
.envfile (bootstrap and development fallback)- Azure credentials to access App Config and Key Vault
- Local overrides for development
- Minimal - only what's needed to bootstrap
- Production/Staging: Requires Azure App Config and Key Vault URLs. Server will not start without them.
- Development: Optional Azure services. Falls back to
.envfile if not configured.
See .env.example for all available configuration options.
This project uses pre-commit hooks to ensure code quality before commits.
After cloning the repository, install the hooks:
uv sync --extra dev
uv run pre-commit installHooks run automatically on git commit. To run manually:
# Run on all files
uv run pre-commit run --all-files
# Run on staged files only
uv run pre-commit run- Ruff Linter: Checks for Python linting errors and auto-fixes them
- Ruff Formatter: Formats Python code according to project style
- Trailing Whitespace: Removes trailing whitespace
- End of File Fixer: Ensures files end with newline
- YAML/JSON/TOML Checkers: Validates configuration files
- Large File Check: Prevents committing large files (>1MB)
- Merge Conflict Check: Detects merge conflict markers
- Debugger Check: Prevents committing debugger imports
For detailed CI/CD documentation, see docs/CI_CD.md.
The application is designed to integrate with:
- Azure Key Vault (for secrets)
- Azure App Configuration Store (for configurations)