A powerful CLI tool that creates production-ready FastAPI projects with complete automation - from scaffolding to running server in one command!
π 100% Automated Setup - Just answer a few questions, everything else is automatic
π¦ Auto Virtual Environment - Creates and configures venv automatically
π― Auto Poetry Install - Installs Poetry in your project's venv
π Auto Dependencies - Installs latest compatible versions automatically
πΎ Auto Database Setup - Initializes database with Alembic migrations
π JWT Authentication - Optional complete auth system (login, register, protected routes)
π Interactive Prompts - No need to remember command flags
π¨ Beautiful CLI - Rich colored output with progress indicators
β‘ Latest Versions - Always installs latest compatible package versions
fastapi-create-projectThat's it! Just run this one command and answer the prompts:
- Project name (default: fastapi-project)
- Developer name (optional)
- Developer email (optional)
- Database type (default: SQLite)
- Include Docker? (default: No)
- Include tests? (default: No)
- Include JWT auth? (default: No)
The CLI will automatically:
- β Generate complete project structure
- β
Create virtual environment (
python -m venv venv) - β Install Poetry in the venv
- β
Create
.envfile from template - β
Install all dependencies with
poetry install - β
Initialize database with
alembic upgrade head - β
You're ready to code! Just
cd project-name && source venv/bin/activate
cd /Users/pinkleshparjapati/Desktop/fastapi-create-project
pip install .
# Verify
fastapi-create-project --help# Install pipx (if you don't have it)
python -m pip install --user pipx
python -m pipx ensurepath
# Install the CLI tool globally
cd /Users/pinkleshparjapati/Desktop/fastapi-create-project
pipx install .
# Done! Use from anywhere
fastapi-create-project --helpOnly use this if you're modifying the CLI tool code:
cd /Users/pinkleshparjapati/Desktop/fastapi-create-project
source venv/bin/activate
pip install -e . # -e = editable mode, changes reflect immediatelyIf you installed with pipx:
pipx uninstall fastapi-create-projectIf you installed with pip:
pip uninstall fastapi-create-projectNote: You don't need to install Poetry globally! The CLI installs it automatically in each project.
fastapi-create-projectThat's it! Press Enter for all prompts to get a working FastAPI project in seconds!
- β Asks for project details (name, developer info)
- β Generates complete project structure
- β Creates virtual environment
- β Installs Poetry
- β
Runs
poetry addfor all dependencies (gets latest versions) - β
Runs
poetry installandpoetry update - β
Creates
.envwith unique JWT_SECRET_KEY - β Initializes database with Alembic
- β Ready to run!
cd your-project-name
source venv/bin/activate
poetry run uvicorn app.main:app --reloadOpen: http://localhost:8000/docs
fastapi-create-projectThe CLI will ask you:
- Project name - Enter your project name (default: fastapi-project)
- Developer name - Your name (appears in pyproject.toml)
- Developer email - Your email (appears in pyproject.toml)
- Database - Choose PostgreSQL, MySQL, or SQLite (default: SQLite - can change in .env)
- Docker - Include Docker configuration? (default: No)
- Tests - Include pytest setup? (default: No)
- JWT Auth - Include JWT authentication? (default: No)
Then sit back! The CLI will:
- Generate all files with your configuration
- Create virtual environment (
python -m venv venv) - Install Poetry in the venv
- Run
poetry add fastapi[standard] sqlalchemy alembic...(latest versions) - Run
poetry installandpoetry update - Create
.envfile with auto-generated JWT_SECRET_KEY - Initialize database with
alembic upgrade head
When it's done, just:
cd your-project-name
source venv/bin/activate
poetry run uvicorn app.main:app --reloadVisit: http://localhost:8000/docs
fastapi-create-project my-awesome-apiCLI will ask for developer info, database, Docker, tests, and JWT.
fastapi-create-project my-api \
--name "John Doe" \
--email "[email protected]" \
-d sqlite \
--no-docker \
--no-tests \
--no-jwtfastapi-create-project my-api --no-auto-setupThis only generates files without creating venv or installing dependencies.
| Option | Short | Description |
|---|---|---|
project_name |
- | Project name (optional, will prompt if not provided) |
--name |
- | Developer name for pyproject.toml |
--email |
- | Developer email for pyproject.toml |
--database |
-d |
Database: postgresql, mysql, or sqlite (default: sqlite) |
--docker / --no-docker |
- | Include Docker configuration (default: No) |
--tests / --no-tests |
- | Include pytest setup (default: No) |
--jwt / --no-jwt |
- | Include JWT authentication (default: No) |
--path |
- | Where to create project (default: current directory) |
--no-auto-setup |
- | Skip venv/poetry/installation automation |
fastapi-create-project
# Just press Enter for all prompts to use defaults:
# - Project name: fastapi-project
# - SQLite database (no setup needed!)
# - No Docker
# - No Tests
# - No JWT
# Done! Start coding immediatelyfastapi-create-project
# Choose PostgreSQL, Yes Docker, Yes Tests, Yes JWT
# Edit .env with your PostgreSQL credentials
# docker-compose up -dfastapi-create-project ci-api \
-d sqlite \
--no-docker \
--tests \
--no-jwt \
--name "CI Bot" \
--email "[email protected]"my-project/
βββ app/
β βββ main.py # FastAPI application
β βββ api/v1/
β β βββ api.py # API router
β β βββ endpoints/
β β βββ users.py # CRUD example
β β βββ health.py # Health checks
β βββ core/
β β βββ config.py # Settings (Pydantic)
β βββ crud/
β β βββ user.py # Database operations
β βββ db/
β β βββ base.py # Model registry
β β βββ database.py # DB connection
β βββ models/
β β βββ user.py # SQLAlchemy models
β βββ schemas/
β β βββ user.py # Pydantic schemas
β βββ services/ # Business logic
βββ alembic/
β βββ versions/ # Migrations
β βββ env.py # Alembic config
βββ tests/ # Pytest tests (optional)
βββ venv/ # Virtual environment (auto-created)
βββ .env # Environment vars (auto-created)
βββ .env.example # Template
βββ .gitignore # Git ignore
βββ pyproject.toml # Poetry config
βββ alembic.ini # Alembic config
βββ Dockerfile # Docker (optional)
βββ docker-compose.yml # Docker Compose (optional)
βββ pytest.ini # Pytest config (optional)
βββ README.md # Documentation
All with latest compatible versions (no hard-coded version numbers):
Core Framework:
- FastAPI
^0.115(any 0.115.x) - Uvicorn
^0.32with standard extras - SQLAlchemy
^2.0(any 2.x) - Alembic
^1.14(any 1.x) - Pydantic
^2.10+ pydantic-settings^2.6
Database Drivers:
- PostgreSQL:
psycopg2-binary ^2.9 - MySQL:
pymysql ^1.1 - SQLite: Built-in
Security:
- python-jose
^3.3(JWT) - passlib
^1.7(password hashing) - python-multipart
^0.0.17
Development:
- python-dotenv
^1.0
Testing (if selected):
- pytest
^8.0 - pytest-cov
^6.0 - httpx
^0.27
The ^ constraint means Poetry will install the latest compatible version within that major.minor range!
Working user management system with:
- Create user with password hashing
- Read users (list and detail)
- Update user
- Delete user
- Email and username uniqueness
- Timestamps (created_at, updated_at)
GET /api/v1/health- Application statusGET /api/v1/health/db- Database connectivity
- Swagger UI:
http://localhost:8000/docs - ReDoc:
http://localhost:8000/redoc - OpenAPI JSON:
http://localhost:8000/api/v1/openapi.json
When JWT is enabled, you get:
- Login endpoint (
POST /api/v1/auth/login) - Register endpoint (
POST /api/v1/auth/register) - Get current user (
GET /api/v1/auth/me) - Password hashing with bcrypt
- JWT token generation and verification
- Protected routes example with
get_current_userdependency - OAuth2 compatible (works with FastAPI's built-in docs)
Security Features:
- Password hashing with bcrypt
- JWT token structure (python-jose)
- Token expiration handling
- CORS middleware configured
- Environment-based secrets
- Alembic migrations pre-configured
- Auto-generated initial migration
- Database connection pooling
- SQLAlchemy 2.0 syntax
- Support for PostgreSQL, MySQL, SQLite
- Dockerfile with Poetry
- docker-compose.yml with database service
- Production-ready container setup
- Pytest configured
- Test database setup
- Example tests included
- Coverage reporting ready
cd your-project
source venv/bin/activate
poetry run uvicorn app.main:app --reloadpoetry run pytest
poetry run pytest --cov=apppoetry run alembic revision --autogenerate -m "Add new table"
poetry run alembic upgrade headpoetry add redis
poetry add --group dev blackdocker-compose up -d # Start services
docker-compose logs -f app # View logs
docker-compose down # Stop servicesfastapi-create-project blog-apiEdit app/models/post.py:
from sqlalchemy import Column, Integer, String, Text
from app.db.database import Base
class Post(Base):
__tablename__ = "posts"
id = Column(Integer, primary_key=True)
title = Column(String, nullable=False)
content = Column(Text)Edit app/db/base.py:
from app.models.user import User # noqa
from app.models.post import Post # noqa - Add thisEdit app/schemas/post.py (Pydantic models for API)
Edit app/crud/post.py (database operations)
Edit app/api/v1/endpoints/posts.py (API routes)
Edit app/api/v1/api.py:
from app.api.v1.endpoints import posts
api_router.include_router(posts.router, prefix="/posts", tags=["posts"])poetry run alembic revision --autogenerate -m "Add posts"
poetry run alembic upgrade headpoetry run pytest
poetry run uvicorn app.main:app --reload- Let Poetry Manage Versions - Don't pin exact versions, use
^constraints - Use .env for Secrets - Never commit
.envto git - Generate Secure Keys -
openssl rand -hex 32for SECRET_KEY - Write Tests - Use the included test structure
- Migration Strategy - Create migration for every model change
- Type Hints - FastAPI works best with full type annotations
- API Versioning - Keep using
/api/v1/prefix for backwards compatibility - Documentation - Add docstrings to your endpoints
- Virtual Environment - Always activate venv before working
- Docker for Production - Use docker-compose for deployment
# Check Python version (need 3.8+)
python --version
# Reinstall CLI tool
cd /Users/pinkleshparjapati/Desktop/fastapi-create-project
source venv/bin/activate
pip install --upgrade pip
pip install -e .cd your-project
source venv/bin/activate
pip install --upgrade pip poetry
poetry install -vvv # Verbose modeCheck your .env file:
# For SQLite
DATABASE_URL=sqlite:///./app.db
# For PostgreSQL
DATABASE_URL=postgresql://user:password@localhost:5432/dbname
# For MySQL
DATABASE_URL=mysql://user:password@localhost:3306/dbname# Reset database (development only!)
poetry run alembic downgrade base
poetry run alembic upgrade head
# Or create fresh migration
poetry run alembic revision --autogenerate -m "Initial"
poetry run alembic upgrade head# Use different port
poetry run uvicorn app.main:app --reload --port 8001
# Or kill existing process
lsof -ti:8000 | xargs kill -9 # macOS/Linux
netstat -ano | findstr :8000 # Windows# Reinstall dependencies
poetry install
# Verify installation
poetry show
# Check Python path
poetry run python -c "import fastapi; print(fastapi.__version__)"β
Production-ready project structure
β
Virtual environment automatically created
β
Poetry installed and configured (latest versions)
β
All dependencies installed via poetry add (no hardcoded versions)
β
Database initialized with Alembic
β
.env file created with auto-generated JWT_SECRET_KEY
β
Working CRUD example
β
API documentation (Swagger + ReDoc)
β
JWT authentication (optional: register, login, protected routes)
β
Argon2 password hashing (more secure than bcrypt)
β
SQLAlchemy 2.0 compatible code
β
Alembic migrations reading from .env
β
Testing framework with pytest (optional)
β
Docker setup with docker-compose (optional)
β
Beautiful README in your project
Want to improve this tool?
- Edit
fastapi_scaffold/cli.py- Command-line interface - Edit
fastapi_scaffold/generator.py- Project generation logic - Edit
fastapi_scaffold/templates.py- File templates - Run
pip install -e .to test changes - Create a test project to verify
Version: 0.1.0
Created: October 7, 2025
Python: 3.8+
License: MIT
# Global installation (use from anywhere)
cd /Users/pinkleshparjapati/Desktop/fastapi-create-project
pipx install .
# or: pip install .fastapi-create-project --version
# or: fastapi-create-project -Vfastapi-create-project
# Just press Enter for defaults!cd your-project
source venv/bin/activate
poetry run uvicorn app.main:app --reload- β
Auto SQLite (change to PostgreSQL/MySQL in
.env) - β
Auto-generated unique
JWT_SECRET_KEY - β
Latest package versions via
poetry add - β Argon2 password hashing
- β SQLAlchemy 2.0 compatible
- β
All settings from
.envfile - β No hardcoded values
GET /api/v1/health- Health checkGET /api/v1/health/db- Database checkPOST /api/v1/auth/register- Register (if JWT enabled)POST /api/v1/auth/login- Login (if JWT enabled)GET /api/v1/auth/me- Current user (if JWT enabled)GET /api/v1/users- List usersGET /api/v1/users/{id}- Get userPUT /api/v1/users/{id}- Update userDELETE /api/v1/users/{id}- Delete user
If this tool saved you time, give it a star! β
Made with β€οΈ for FastAPI developers who want to start coding faster!
Questions? Issues? Check the generated project's README for more details.
Happy Coding! π