Production-ready FastAPI template for AI AGENTIC services.
This repository gives you a clean starting point for new backend services with:
- FastAPI application bootstrap
- structured logging with
structlog - environment-based settings via
pydantic-settings - SQLAlchemy foundation for database work
- ARQ worker setup for background jobs
- linting, testing, and pre-commit hooks
- Python 3.13
- FastAPI
- SQLAlchemy
- ARQ
uvfor dependency managementpytestandrufffor quality checks
src/
config.py # app settings
logger.py # structured logging setup
main.py # FastAPI app entrypoint
middleware/ # shared request middleware
db/ # database base and engine utilities
extensions/arq/ # background worker setup
modules/ # feature modules
services/ # service layer
workflows/ # langgraph & other workflows
tests/
docs/
- Create a local environment file:
cp .env.example .env- Install dependencies:
uv sync --extra dev- Install git hooks:
uv run pre-commit install- Start the API:
uv run uvicorn src.main:app --reloadThe API will be available at http://localhost:8000.
Run the ARQ worker with:
uv run arq src.extensions.arq.arq_common.WorkerSettingsRun tests:
uv run pytestRun lint:
uv run ruff check .Format code:
uv run ruff format .The template includes .env.example with the default local setup:
ENVIRONMENT=development
APP_HOST=0.0.0.0
APP_PORT=8000
APP_NAME=Vita Backend
APP_VERSION=0.1.0
SERVICE_NAME=vita-backend
LOG_LEVEL=DEBUG
LOG_FORMAT=console
CONNECTION_STRING=
REDIS_HOST=localhost
REDIS_PORT=6379
REDIS_DB=0
REDIS_PASSWORD=
ARQ_MAX_JOBS=50
ARQ_JOB_TIMEOUT=300
ARQ_KEEP_RESULT=3600After startup, you can verify the service with:
curl http://localhost:8000/healthExpected response:
{"status":"ok"}- The repository is configured as a GitHub template repository.
- Add your service-specific modules under
src/modules/. - Extend
docs/overview.mdwhen the service architecture becomes more specific.