CLI to generate scaffold for modular FastAPI projects
Project description
FastAPI Creator
fastapi-creator is a command-line interface (CLI) to easily scaffold and manage modular FastAPI projects. It automates the creation of standard folder structures, boilerplate code, and helps you keep your application organized as it scales.
Installation
As this is a Python project, it can be installed via pip (or your favorite dependency manager like uv, poetry, etc.):
# If installing locally from the cloned repository
pip install -e .
After installation, the CLI will be available as fastc.
Commands Overview
The CLI revolves around the create command group, which allows you to generate new projects from scratch, or add components to existing projects.
1. Create a New Project
Creates a complete FastAPI project structure in the specified directory, including core settings, database connection setup, security utilities, and a default users module.
Usage:
fastc create project <directory>
fastc create project ./my-app --module products
Options:
--module,-m: Name of an additional module to be created together with the defaultusersmodule.
Generated Structure Example:
my-app/
├── app/
│ ├── main.py # FastAPI application initialization
│ ├── lifespan.py # Application startup and shutdown events
│ ├── core/ # Core components (config, DB, security, etc.)
│ ├── workers/ # Async background workers (e.g. ARQ, Celery)
│ └── modules/ # Domain modules
│ └── users/ # Default module generated automatically
│ ├── router.py
│ ├── schemas.py
│ ├── models/
│ ├── repositories/
│ └── services/
├── pyproject.toml
├── requirements.txt
├── .env.example
├── .gitignore
└── README.md
2. Add a New Module
Adds a new domain module to an already existing project.
Usage:
# Make sure you are at the project root
fastc create module payments
fastc create module orders --dir ./my-app
Options:
--dir,-d: Root directory of the FastAPI project (defaults to current directory).
3. Create a Service
Scaffolds a service class file inside the services/ directory of the specified module. Services are meant to hold your business logic.
Usage:
fastc create service users/authentication
fastc create service products/inventory_manager
What it generates (e.g., users/authentication):
# app/modules/users/services/authentication.py
class AuthenticationService:
def __init__(self, repository):
self.repository = repository
Options:
--dir,-d: Root directory of the FastAPI project (defaults to current directory).
4. Create a Repository
Scaffolds a repository class inside the repositories/ directory of the given module. Repositories handle data access and database sessions.
Usage:
fastc create repository users/user_query
With standard CRUD methods:
You can append the --crud flag to generate empty boilerplate methods for generic CRUD operations.
fastc create repository users/user_query --crud
What it generates with --crud:
# app/modules/users/repositories/user_query.py
from sqlalchemy.ext.asyncio import AsyncSession
class UserQueryRepository:
def __init__(self, session: AsyncSession):
self.session = session
async def find_by_id(self, id: str):
...
async def find_all(self):
...
async def create(self, data):
...
async def update(self, id: str, data):
...
async def delete(self, id: str):
...
Options:
--crud: Generate standard CRUD methods (find_by_id,find_all,create,update,delete).--dir,-d: Root directory of the FastAPI project (defaults to current directory).
Getting Started with the Generated Project
Once you generate a new project using fastc create project my-app, go into the directory and run it:
cd my-app
pip install -r requirements.txt
uvicorn app.main:app --reload
Then visit http://127.0.0.1:8000/docs to see your FastAPI Swagger interface up and running!
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_creator-0.1.0.tar.gz.
File metadata
- Download URL: fastapi_creator-0.1.0.tar.gz
- Upload date:
- Size: 23.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9c9e04eb6254c31f4c1d7bc88fd1c1bc7ea8ede780535e7baeb7ff06f1575170
|
|
| MD5 |
70e06d6ec465c23293ec36a0d3d0c10c
|
|
| BLAKE2b-256 |
bae8aa91e017b9c94afd7c9cf7946ff1451f09710c79a0e3191b8bfb66fc322e
|
File details
Details for the file fastapi_creator-0.1.0-py3-none-any.whl.
File metadata
- Download URL: fastapi_creator-0.1.0-py3-none-any.whl
- Upload date:
- Size: 9.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f82c5a32e5710badbb401a3bba736bce5d75b633b5380f21a1df971abbe09653
|
|
| MD5 |
a87046fe8657aefe4e2810e538cbe030
|
|
| BLAKE2b-256 |
eff6403cf214f62e6625a95d3453b15c17466458443eadd911d6b4f897ab91f2
|