One command to scaffold a production-ready FastAPI project — just like
laravel newbut for Python.
python create_fastapi_app.py my-projectTired of setting up the same folder structure, installing the same packages, and writing the same boilerplate code every time you start a new FastAPI project?
This script does everything in one shot:
- 📁 Creates a clean, production-ready folder structure
- 🐍 Sets up a virtual environment automatically
- 📦 Installs all required packages
- 🗄️ Wires up SQLAlchemy + PostgreSQL connection
- 🔐 Sets up JWT Auth structure
- 📋 Creates
.env,.gitignore,requirements.txt,README.md - 🚀 Ready to run in under 60 seconds
curl -O https://raw.githubusercontent.com/DS-dk/fastapi-boilerplate/main/create_fastapi_app.pypython create_fastapi_app.py my-projectcd my-project
# Edit .env and add your PostgreSQL credentialsvenv\Scripts\activate # Windows
source venv/bin/activate # Mac/Linux
uvicorn main:app --reloadhttp://127.0.0.1:8000/docs
That's it! 🎉
my-project/
│
├── main.py # Entry point — registers routes, middleware
├── requirements.txt # All dependencies
├── .env # Environment variables (DB, JWT, etc.)
├── .gitignore # Pre-configured
│
└── app/
├── database.py # SQLAlchemy engine + session + Base
│
├── models/ # SQLAlchemy ORM models (like Eloquent)
│ ├── __init__.py
│ └── user.py # User model (ready to use)
│
├── routers/ # API route handlers (like Controllers)
│ ├── __init__.py
│ └── users.py # User CRUD routes (ready to use)
│
├── schemas/ # Pydantic schemas (Request validation + Response)
│ ├── __init__.py
│ └── user.py # UserCreate, UserUpdate, UserResponse
│
├── services/ # Business logic layer
│ └── __init__.py
│
└── dependencies/ # Auth & reusable dependencies (like Middleware)
├── __init__.py
└── auth.py # JWT token verification
| Package | Purpose | Laravel Equivalent |
|---|---|---|
fastapi |
Web framework | Laravel |
uvicorn |
ASGI server | php artisan serve |
sqlalchemy |
ORM | Eloquent |
alembic |
Migrations | Laravel Migrations |
psycopg2-binary |
PostgreSQL driver | doctrine/dbal |
pydantic |
Validation + Serialization | FormRequest + Resources |
pydantic-settings |
.env config | Laravel Config |
python-dotenv |
.env loader | vlucas/phpdotenv |
passlib[bcrypt] |
Password hashing | Hash::make() |
python-jose |
JWT tokens | Laravel Sanctum/Passport |
python-multipart |
Form data support | — |
- Python 3.10+
- PostgreSQL installed and running
- pip
Edit your .env file:
DATABASE_URL=postgresql://postgres:yourpassword@localhost:5432/your_db_name
SECRET_KEY=your-super-secret-jwt-key
ALGORITHM=HS256
ACCESS_TOKEN_EXPIRE_MINUTES=30PRs are welcome! If you have ideas to improve the boilerplate feel free to open an issue or submit a pull request.
MIT — free to use in personal and commercial projects.
If this saved you time, give it a star! ⭐ It helps others find it too.