A boilerplate for FastAPI projects
Project description
FastAPI Boilerplate Kit
CLI scaffolding for production-ready FastAPI applications
Auth, RBAC, JWT middleware, multi-database presets, and pytest - generated with one command.
FastAPI Boilerplate Kit (dnd) is a PyPI package that generates opinionated, deployment-oriented FastAPI project layouts-routing, persistence, authentication, and tests - so you can focus on business logic instead of repetitive setup.
pip install fastapi-boilerplate-kit
dnd generate my_app --yes
Features
- FastAPI Boilerplate: A clean project setup for building FastAPI applications quickly.
- Auth Module: Register, login, refresh, forgot/reset password, change password, and invite flows.
- Auth Middleware + Authorization: JWT middleware with dependency-based authorization guards.
- Scoped Access Querying: Repository/service-level scope-aware filtering patterns.
- Email Integration: Async email service templates for auth and integration use cases.
- Test Scaffold (PyTest): Baseline test structure with API/service test examples.
- Interactive Scaffolding: Guided generation with
--interactive. - Config-Driven Scaffolding: Deterministic generation with
--config-file. - Preset Modes:
minimal,standard, andenterprise. - Database-Aware Generation: Supports SQLite and server DB style setup (PostgreSQL/MySQL).
Getting Started
Installation Instructions:
To install the FastAPI Boilerplate Kit, run:
pip install fastapi-boilerplate-kit
Alternatively, you can install from the test PyPI repository for testing purposes:
pip install -i https://test.pypi.org/simple/ fastapi-boilerplate-kit
Generate a New Project
Once the installation is complete, generate a project with:
dnd generate PROJECT_NAME
This creates PROJECT_NAME with recommended defaults (sqlalchemy, sqlite, auth/email/tests enabled).
What gets scaffolded
- API routing with public/protected separation
- Auth endpoints and auth token workflow
- JWT + password security utilities
- Middleware + dependency layers for auth/authorization
- Repositories/services with scoped querying pattern
- PyTest baseline and sample tests
- Environment and DB configuration templates
Project Setup
- Change to the generated project directory:
cd PROJECT_NAME
- Install dependencies:
pip install -r requirements.txt
- Start the FastAPI server:
python main.py
- Access the Swagger Docs: Open your browser and navigate to:
http://localhost:8000/docs
This will give you access to FastAPI's interactive API documentation.
Project Example:
For example, after generating a project named test_project, the following steps are needed:
- Change directory:
cd test_project
- Install dependencies:
pip install -r requirements.txt
- Start the FastAPI server:
python main.py
- Visit the Swagger docs at
http://localhost:8000/docsfor detailed API documentation.
Command-Line Interface (CLI)
The FastAPI Boilerplate Kit provides a CLI to simplify project generation.
Core Command
dnd generate PROJECT_NAME [options]
Common Workflows
- Default generation (recommended defaults)
dnd generate my_app
- Interactive guided setup
dnd generate my_app --interactive
- Non-interactive with explicit DB settings
dnd generate my_app --yes --database postgresql --database-host localhost --database-port 5432 --database-user app_user --database-password app_pass --database-name app_db
- Dry run (preview resolved config without writing files)
dnd generate my_app --yes --database mysql --database-host localhost --database-port 3306 --database-user root --database-password root --database-name app_db --dry-run
Using --config-file
You can pass a JSON file to keep generation deterministic across environments and teams.
Example file scaffold.config.json:
{
"preset": "standard",
"database": "postgresql",
"orm": "sqlalchemy",
"with_auth": true,
"with_email": true,
"with_tests": true,
"database_host": "localhost",
"database_port": 5432,
"database_user": "app_user",
"database_password": "app_pass",
"database_name": "app_db"
}
Generate from config:
dnd generate my_app --config-file scaffold.config.json --yes
Key Options
--interactive: guided prompts for preset, DB, and features--yes: accept defaults and skip prompts--dry-run: print resolved config and skip file generation--preset {minimal|standard|enterprise}: start from curated defaults--database {sqlite|postgresql|postgres|mysql}- SQLite option:
--database-path - Server DB options:
--database-host,--database-port,--database-user,--database-password,--database-name - Feature toggles:
--with-auth/--without-auth,--with-email/--without-email,--with-tests/--without-tests
For advanced examples and CI usage, see docs/cli.md.
Version Information
You can check the version of the FastAPI Boilerplate Kit using:
dnd --version
or
dnd -V
This will show the installed version of the fastapi-boilerplate-kit.
Production notes
Operational defaults & SuperAdmin bootstrap
General
- Current ORM support is
sqlalchemy. - If auth is enabled, email is enabled automatically by design.
Initial SuperAdmin (generated apps)
- Seeding creates roles (
SuperAdmin,User) by default. TheUserrole is the default for self-servicePOST /auth/register(least privilege). You may rename or delete theUserrole via the roles API; if it is missing, open registration returns 409 until you recreate a role namedUser(or use invite-only onboarding). - At most one user may hold the
SuperAdminrole at a time (enforced on register-with-invite, invite, admin user create/update, and optional env bootstrap). TheSuperAdminrole cannot be deleted via API; SuperAdmin users cannot be deleted via API (profile and password flows still apply). Offboarding or GDPR-style erasure may require a controlled DB or support process. - Optional bootstrap (
ENABLE_SEED=TRUE, no SuperAdmin yet): setADMIN_PASSWORDfor a fixed first password, or leave it empty for a mandatory one-time generated password. Stored value is always a hash;must_change_passwordapplies untilPOST /api/v1/auth/change-password. ADMIN_PASSWORDempty: a one-time random password is generated on first successful seed and printed to stdout (treat logs as sensitive). An explicitADMIN_PASSWORDalways wins.POST /api/v1/userscannot assignSuperAdmin—first admin comes from seed or controlled DB access.
Project information
Development setup
git clone https://github.com/Tharunkumar2024/fastapi-boilerplate-kit.git
cd fastapi-boilerplate-kit
python -m venv .venv
# Windows
.venv\Scripts\activate
# macOS / Linux
source .venv/bin/activate
pip install -e .
dnd --version
Build a wheel locally:
pip install setuptools wheel
python setup.py sdist bdist_wheel
Community
Report vulnerabilities privately via email or GitHub Security Advisories — do not use public issues for security reports.
Support this project
Optional contributions help fund maintenance, documentation, and releases.
Donations: email the maintainer for a secure PayPal link (no public payment URL in this repo).
GitHub Sponsors:
github.com/sponsors/Tharunkumar2024
· General:
tharunkumar.developers@gmail.com
Connect
Built with
FastAPI Boilerplate Kit · maintained by Tharunkumar Saravanan · LinkedIn · Trillionaire TK · YouTube
© 2025–2026 Tharunkumar Saravanan · Apache License 2.0
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file fastapi_boilerplate_kit-1.6.0.tar.gz.
File metadata
- Download URL: fastapi_boilerplate_kit-1.6.0.tar.gz
- Upload date:
- Size: 44.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f518916861448bb66b0cb280b010ab3faf06201ba80ec40a5eb7c4aacf7073ef
|
|
| MD5 |
ced6a5698439700a4df849842504506b
|
|
| BLAKE2b-256 |
61475e4d7db55ccc44151dd8e982fc06aeabe825d28033d456e3e5790a9fdf65
|
File details
Details for the file fastapi_boilerplate_kit-1.6.0-py3-none-any.whl.
File metadata
- Download URL: fastapi_boilerplate_kit-1.6.0-py3-none-any.whl
- Upload date:
- Size: 63.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1d05f202330cbaaa8f0969ef999c98a5ce31586acfc2623fac431db27a954f87
|
|
| MD5 |
a2c72997e8f0a1bac580dd1f234ac8db
|
|
| BLAKE2b-256 |
285973ab0001c36edb30e398f164d3b675df5596b784ceffaa89218bafb80e70
|