An interactive CLI tool that scaffolds production-ready FastAPI projects with sensible defaults.
Project description
FastAPI Initializer
An interactive CLI tool that scaffolds production-ready FastAPI projects with sensible defaults - so you can skip the boilerplate and start building right away.
โจ What Does It Do?
Run a single command, answer a few prompts, and get a fully structured FastAPI project with:
- ๐๏ธ Clean project layout -
api/,core/,models/,schemas/,services/ - ๐๏ธ Database support - SQLite, MySQL, or PostgreSQL
- ๐ง ORM of your choice - SQLAlchemy or SQLModel
- ๐งช Testing setup - pytest / pytest-asyncio with httpx, ready to go
- ๐งน Linter config - Black or Ruff
- ๐ณ Docker ready - optional
Dockerfile&docker-compose.yml - โ๏ธ Environment config - pydantic-settings with
.envsupport - ๐ Documentation - every folder gets a README explaining its purpose
๐ฆ Installation
Install from PyPI
pip install fastapi-initializer
Or with uv:
uv pip install fastapi-initializer
Install from Source (for development)
# Clone the repository
git clone https://github.com/DasunNethsara-04/fastapi-initializer.git
cd fastapi-initializer
# Create a virtual environment and install dependencies
uv sync
# Run the CLI directly
uv run fastapi-init my-project
๐ Usage
fastapi-init my-project
You'll be guided through interactive prompts:
โฏ FastAPI Initializer
Creating project: my-project
โฏ What kind of database do you want to use?
> SQLite / MySQL / PostgreSQL / None
โฏ Which ORM do you want to use?
> SQLAlchemy / SQLModel / None
โฏ What linter do you want to use?
> Ruff / Black / None
โฏ What testing framework do you like to use?
> PyTest / pytest-async-io / None
โฏ Do you want to create a Docker file for this project?
> Yes / No
โ FastAPI project 'my-project' created successfully!
Then get started in seconds:
cd my-project
uv sync
uv run uvicorn app.main:app --reload
Open http://127.0.0.1:8000/docs to see the interactive API docs.
Screenshorts
๐ Generated Project Structure
The generated project follows a modular, production-style layout:
my-project/
โโโ app/
โ โโโ api/
โ โ โโโ v1/
โ โ โ โโโ users.py # User endpoints
โ โ โโโ __init__.py # Mounts versioned routers
โ โ โโโ deps.py # Shared dependencies (e.g. auth)
โ โโโ core/
โ โ โโโ config.py # App settings via pydantic-settings
โ โ โโโ security.py # OAuth2 / auth utilities
โ โโโ models/
โ โ โโโ user.py # ORM model (SQLAlchemy / SQLModel)
โ โโโ schemas/
โ โ โโโ user.py # Pydantic request / response models
โ โโโ services/
โ โ โโโ user_service.py # Business logic layer
โ โโโ db/
โ โ โโโ base.py # ORM Base class
โ โ โโโ session.py # Engine & get_session() dependency
โ โโโ main.py # FastAPI app entry-point
โโโ tests/
โ โโโ test_users.py # Smoke test with httpx
โโโ .env # Environment variables
โโโ .gitignore
โโโ pyproject.toml
โโโ Dockerfile # (optional)
โโโ docker-compose.yml # (optional)
โโโ README.md # Auto-generated project docs
Note: Folders like
models/,db/,tests/, and Docker files are only generated when you select the corresponding options.
What Each Folder Does
| Folder | Purpose |
|---|---|
app/api/ |
HTTP route definitions, versioned (v1/, v2/, โฆ). |
app/core/ |
App-wide settings (Settings class) and security helpers. |
app/models/ |
ORM model classes mapped to database tables. |
app/schemas/ |
Pydantic models for request validation and response serialisation. |
app/services/ |
Business-logic layer โ keeps route handlers thin and testable. |
app/db/ |
Database engine, session factory, and get_session() dependency. |
tests/ |
Automated test suite using pytest + httpx. |
๐ ๏ธ Configuration Options
| Prompt | Choices | What It Generates |
|---|---|---|
| Database | SQLite, MySQL, PostgreSQL, None | app/db/session.py with connection URL and driver dependency |
| ORM | SQLAlchemy, SQLModel, None | app/models/ with model classes and app/db/base.py |
| Linter | Ruff, Black, None | Adds the linter to pyproject.toml dependencies |
| Test framework | pytest, pytest-asyncio, None | tests/ directory with async smoke test |
| Docker | Yes, No | Dockerfile, docker-compose.yml, .dockerignore |
๐ค Contributing
Contributions are welcome! Here's how to get started:
# 1. Fork and clone
git clone https://github.com/DasunNethsara-04/fastapi-initializer.git
cd fastapi-initializer
# 2. Install dependencies
uv sync
# 3. Make your changes, then test
uv run fastapi-init test-project
# 4. Submit a pull request
๐ License
This project is licensed under the MIT License.
๐ Acknowledgements
Built with:
- FastAPI - the framework this tool scaffolds
- Typer - CLI framework
- InquirerPy - interactive prompts
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_initializer-1.0.1.tar.gz.
File metadata
- Download URL: fastapi_initializer-1.0.1.tar.gz
- Upload date:
- Size: 15.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.17 {"installer":{"name":"uv","version":"0.9.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fd129d6b46d2c99c350bb5810a1ee1f6578cc8dd25a94c5c5b99b5a1e8aa56cf
|
|
| MD5 |
260766bba3eb6fb18e4012f10cbb20e3
|
|
| BLAKE2b-256 |
de14688570173f4cbb321a5e53b899c2ef893d4353950ac1d59ec8aaa0fc3141
|
File details
Details for the file fastapi_initializer-1.0.1-py3-none-any.whl.
File metadata
- Download URL: fastapi_initializer-1.0.1-py3-none-any.whl
- Upload date:
- Size: 24.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.17 {"installer":{"name":"uv","version":"0.9.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d5cc3778d27f27577df294b4629e28271b20a5ea9e8e2680e7c676c12e0769de
|
|
| MD5 |
0a716b128b580269e5e45308b6444b8a
|
|
| BLAKE2b-256 |
4c8cf79e3b6df857c43d685c5720e23cc426cf8611e5e91881b5f3a0a3680257
|