FastSecForge is a robust, pluggable Python security boilerplate generator built on top of FastAPI, SQLAlchemy, and MongoDB. It provides JWT authentication, user management, and a powerful CLI (typer) to scaffold fully functional, secure project templates in one command.
- π JWT Authentication with secure password hashing (
passlib[bcrypt]) - π§© Supports SQL (SQLAlchemy) & MongoDB (Motor)
 - π¦ Pydantic v2+ for type-safe data validation and settings
 - π§ Typer-based CLI for instant FastAPI boilerplate creation
 - β»οΈ Async-ready architecture optimized for performance
 - π Security best practices out of the box (OAuth2 flows, CORS, rate limiting)
 
Install FastSecForge from PyPI:
pip install fastsecforgeOr install in editable mode from source:
git clone https://github.com/reprompts/fastsecforge.git
cd fastsecforge
python -m venv venv
source venv/bin/activate    # Windows: venv\\Scripts\\activate
pip install -e .            # editable modeFastSecForge exposes one primary command: new_project. This will scaffold a complete FastAPI project for you.
fastsecforge <project_name><project_name>: Name of the new project (also used as package name).
After running this, you will have:
<project_name>/
βββ src/
    βββ <project_name>/
        βββ __init__.py
        βββ main.py          # FastAPI app entrypoint
        βββ config.py        # Settings loader
        βββ database.py      # DB session & models
        βββ core/
        β   βββ __init__.py
        β   βββ security.py  # Auth, password hashing, JWT utilities
        βββ models/
        β   βββ __init__.py
        β   βββ user.py      # User ORM models
        βββ routers/
        β   βββ __init__.py
        β   βββ auth.py      # Authentication routes
        β   βββ users.py     # User management routes
        βββ schemas/
        β   βββ __init__.py
        β   βββ user.py      # Pydantic schemas
        βββ templates/      # Additional template assets
- 
Navigate into the new project
cd <project_name>
 - 
Create & activate a virtual environment
python -m venv venv source venv/bin/activate # Windows: venv\\Scripts\\activate
 - 
Install dependencies
pip install -r requirements.txt
 - 
Configure environment variables
- Rename 
.env.exampleto.env - Fill in your database URIs, JWT secret key, and other settings
 
 - Rename 
 - 
Start the development server
uvicorn src.<project_name>.main:app --reload
Your API will be available at http://127.0.0.1:8000 with interactive docs at http://127.0.0.1:8000/docs.
 
If you scaffold tests, run:
pytestThis project is licensed under the MIT License.
Contributions welcome! Open an issue or submit a pull request against main.