Dark Theme Auth FastAPI Server
A FastAPI template with auth-protected endpoints, Redis, logging, and a custom dark-themed docs UI
Overview
Dark Theme Auth FastAPI Server is a starter template for production FastAPI applications. It bundles authentication, Redis caching, structured logging, and a custom dark-themed Swagger UI into a single repo you can clone, rename, and start building on top of.
What it gives you
- JWT authentication with login, token refresh, and role-based access control
- Redis integration for caching, rate limiting, and session storage
- Structured logging with request IDs, response times, and trace correlation
- Dark-themed docs — the Swagger UI is rebranded with a custom CSS that is easier on the eyes during long debugging sessions
- Health check and metrics endpoints ready for Kubernetes liveness/readiness probes
- Docker Compose for local development
- Pytest setup with fixtures for auth and DB isolation
Design choices
The template is opinionated on purpose. JWT uses RS256 asymmetric signing so the signing key never leaves the auth service. Redis is mandatory — not optional — because production apps that "maybe need caching later" always end up bolting it on in a rush. Logging is structured JSON because grep on structured logs is a thousand times more productive than grep on free text.
Tech stack
Python 3.11+, FastAPI, Pydantic v2, Redis, Docker, pytest, and Uvicorn with workers for production. Also ships with a GitHub Actions workflow for CI (test + lint + type-check).
When to use this
Reach for this template when starting a new API service that needs to be production-ready quickly. It is not a framework and not a library — it is a shape you fill in. Fork it, delete the example routes, add your own, and ship.
Takeaway
A good template saves a day on every new project. This one captures the decisions I would otherwise make from scratch each time, so I can focus on the part that is actually novel.
