Skip to main content
George Khananaev
Open Source

Dark Theme Auth FastAPI Server

A FastAPI template with auth-protected endpoints, Redis, logging, and a custom dark-themed docs UI

2 min read

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.

FastAPI DocShield: protect your API docs with one line
2 min13

FastAPI DocShield: protect your API docs with one line

HTTP Basic Auth on the OpenAPI docs endpoints for FastAPI

A tiny FastAPI extension that adds HTTP Basic Authentication to the Swagger UI, ReDoc, and OpenAPI JSON endpoints. Drop it in, set a username and password, and your API docs are no longer public. Useful when you want docs in production but not publicly indexable.

fastapipythonsecurityauthentication
PyNextStack: a full-stack user management starter
PyNextStack: a full-stack user management starter illustrationFeaturedGitHub
2 min25

PyNextStack: a full-stack user management starter

FastAPI backend, Next.js frontend, auth and profiles out of the box

A full-stack user management system with a Next.js frontend and FastAPI backend. Registration, authentication, profile management, and a Material-UI interface. Production-ready defaults so you can focus on your actual product instead of rebuilding the login form.

fastapinextjspythontypescript
Travel Panel: the core travel management platform
Travel Panel: the core travel management platform illustrationFeaturedMoon Holidays
11 minDec 2022 — Present

Travel Panel: the core travel management platform

FastAPI backend, Next.js operator portal, and B2B partner portal powering Moon Holidays end to end

Travel Panel is the core system at Moon Holidays. A FastAPI backend, a Next.js operator portal, a B2B partner portal, and the orchestrator for every downstream product: TravelOffer for end customers, Live Deck for call-center TVs, Vercel Controller for deployment cache, StaySync for allotment availability, and a WebSocket messenger for internal communication. Running on AWS with ALB, MemoryDB, CloudFront, S3, and more.

fastapinextjspythontypescript