FastKit CLI
A code generation tool for the FastKit ecosystem. Generate complete, production-ready FastAPI modules — models, schemas, repositories, services, and routers — in seconds, not hours.
Introduction
FastKit CLI is inspired by Laravel's php artisan — a command-line tool that generates boilerplate so you can focus on business logic, not infrastructure setup.
Every FastAPI project needs the same building blocks: a model, validation schemas, a repository, a service layer, and a router with CRUD endpoints. Writing these files by hand on every new module is repetitive, error-prone, and inconsistent across a team. FastKit CLI generates all of them in one command, following the FastKit Core architecture conventions.
Why FastKit CLI?
When building a FastAPI application with FastKit Core, every new feature requires the same set of files. Without a generator, a developer either writes them from scratch each time or copy-pastes from a previous module — introducing subtle inconsistencies and wasting time.
A complete module with 6 files generated in one command. Start coding business logic immediately.
Everyone generates the same structure. No more "how did you organize your service?" debates.
Generated code follows FastKit Core architecture — repository pattern, service layer, type hints throughout.
Add --async to generate async-ready files using AsyncSession and get_async_db.
Alembic commands simplified — fastkit migrate make, run, rollback.
fastkit server starts Uvicorn with sensible defaults and auto-reload.
FastKit CLI generates code that uses FastKit Core patterns — it requires fastkit-core to be installed in your project. The generated files are regular Python — you own them completely, edit them freely.
Generated Structure
Running fastkit make module Invoice creates a complete module with one file per architectural layer:
__init__.py
Package init
models.py
SQLAlchemy model with FastKit Core mixins
schemas.py
Pydantic schemas — Create, Update, Response
repository.py
Data access layer using FastKit Repository
service.py
Business logic layer extending BaseCrudService
router.py
FastAPI router with full CRUD endpoints
Each file is immediately runnable — it only needs your domain-specific fields. The router generates five REST endpoints out of the box:
| Method | Path | Handler | Description |
|---|---|---|---|
| GET | /invoices |
index |
Paginated list |
| GET | /invoices/{id} |
show |
Single record |
| POST | /invoices |
store |
Create record |
| PUT | /invoices/{id} |
update |
Update record |
| DELETE | /invoices/{id} |
destroy |
Delete record |
Commands Overview
FastKit CLI is organized into four top-level command groups:
Generate modules, models, schemas, repositories, services, and routers. The primary command you'll use most.
Alembic wrapper — make, run, rollback, status. No more memorizing Alembic flags.
Run database seeders — all at once or a specific seeder class by name.
Start the Uvicorn development server with auto-reload and configurable host and port.
Naming Conventions
FastKit CLI automatically converts any input format to all the correct naming conventions. Pass the name in any form — it always does the right thing:
| Input | Model class | snake_case | Table | Folder |
|---|---|---|---|---|
Invoice |
Invoice |
invoice |
invoices |
invoices/ |
invoice |
Invoice |
invoice |
invoices |
invoices/ |
InvoiceItem |
InvoiceItem |
invoice_item |
invoice_items |
invoice_items/ |
invoice_item |
InvoiceItem |
invoice_item |
invoice_items |
invoice_items/ |
Category |
Category |
category |
categories |
categories/ |
Pluralization handles irregular forms automatically — Category → categories, Person → people. No configuration needed.
Typical Workflow
From zero to a running, migrated, fully-wired feature:
# 1. Generate the complete module
fastkit make module Invoice --async
# 2. Define your model fields
# Edit: modules/invoices/models.py
# 3. Define your schemas
# Edit: modules/invoices/schemas.py
# 4. Generate and run the migration
fastkit migrate make -m "create_invoices"
fastkit migrate run
# 5. Register the router in your main app
# from modules.invoices.router import router as invoices_router
# app.include_router(invoices_router, prefix="/api/v1")
# 6. Start the dev server
fastkit server
At step 6 you have a fully working CRUD API for invoices — with pagination, validation, service layer, and standardized responses — without having written a single line of boilerplate.