Reusable FastAPI + React (Next.js) starter with JWT auth, audit logging, async SQLAlchemy, Celery workers, Docker Compose, Prometheus, and Grafana dashboards.
- Backend (FastAPI): Auth & audit routes, async SQLAlchemy + Alembic, Redis-backed rate limiting, Prometheus metrics, structured logging, Celery worker/beat scaffolding.
- Frontend (Next.js + TypeScript): Auth flows (login/register/profile), protected dashboard shell, typed API client, Tailwind styles.
- Agent scaffold: Stub LLM provider with
/api/v1/agents/runendpoint and frontend demo page to submit prompts. - Ops: Docker Compose for Postgres, Redis, backend, frontend, Prometheus, Grafana; health/readiness endpoints; Makefile helpers.
-
Replace placeholders:
{{PROJECT_NAME}}→ human-readable name{{PROJECT_NAME_SLUG}}/{{PROJECT_NAME_LOWER}}→ lowercase/slug used in container names and defaults
-
Copy env files and fill in secrets:
cp backend/.env.example backend/.env
cp frontend/.env.example frontend/.env
- Set
DATABASE_URL,JWT_SECRET_KEY(e.g.python -c "import secrets; print(secrets.token_urlsafe(32))"), and adjust any hostnames/ports. - When using Docker/nginx, set
NEXT_PUBLIC_API_URLtohttps://localhostinfrontend/.env(nginx terminates TLS with the bundled self-signed cert). For local Next.js dev (npm run dev) that talks directly to the backend, override tohttp://localhost:8000infrontend/.env.local. - For local Next.js runs, you can also place
NEXT_PUBLIC_*values infrontend/.env.local.
- Local dev (no Docker):
make backend-install
make frontend-install
cd backend && uv run alembic upgrade head
make dev # runs uvicorn + next dev
- Full stack with Docker:
docker compose up -d --build
Services: nginx entrypoint :80 (proxies frontend + backend), backend :8000, frontend :3000, Prometheus :9091, Grafana :3001 (admin/admin).
- Git hooks:
make pre-commit-installto add hooks (ruff/black/isort/mypy + frontend lint/format). Run on demand withmake pre-commit. - Lint/format:
make lint(backend + frontend) andmake formatto apply fixes. Backend type checks viamake backend-typecheck. - Sample data:
make seedloads fixture users (e.g., admin@example.com / ChangeMe123!) and basic audit events for local testing. - Frontend formatting uses Prettier; linting runs ESLint flat config in
frontend/eslint.config.mjs.
.
├── backend/ # FastAPI service, Alembic migrations, Celery worker
├── frontend/ # Next.js app with auth flows
├── prometheus/ # Prometheus scrape config
├── grafana/ # Provisioning + dashboards
├── docker-compose.yml
└── Makefile
- Canonical examples:
backend/.env.exampleandfrontend/.env.example - Key values:
DATABASE_URL,REDIS_URL,JWT_SECRET_KEY,NEXT_PUBLIC_API_URL,APP_NAME,LLM_PROVIDER,LLM_MODEL,LLM_API_KEY - Docker Compose reads
backend/.envfor backend services andfrontend/.env(withNEXT_PUBLIC_API_URL=http://localhost) for the nginx entrypoint.
- Backend workers: The provided compose files run a single Uvicorn process. For horizontal scale, run multiple backend replicas behind nginx or a load balancer and set
UVICORN_WORKERS(or switch to gunicorn+uvicorn workers) based on CPU cores. Keep migrations as a one-shot job to avoid race conditions when scaling. - Celery: Scale
celery-workerreplicas independently for background throughput.celery-beatshould stay singleton. - Sessions/state: The app is stateless (JWT auth), so horizontal scaling is safe. Redis is used for rate limiting; if you add server-side sessions or websockets, plan for a shared store (Redis) and sticky sessions where needed.
- Redis persistence: Persistence is disabled by default (see compose files). Enable AOF/RDB only if you need durable state beyond caching/rate-limit counters. For production durability, use a managed Redis or mount a volume with the desired persistence mode.
- Backend:
make backend-test(pytest sample health test) andmake backend-typecheck(mypy) - Frontend:
make frontend-test/npm run test:e2e(Playwright sample, adjust selectors as you extend UI)
- Add your domains: extend
backend/src/domainandbackend/src/api/v1 - Expand frontend pages/components for your use case
- Wire CI/CD (lint, test, build images) for your target platform