Docs / fastkit-cli / Overview

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.

Open Source MIT License Python 3.12+ fastkit-core Alembic
$ pip install fastkit-cli

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.

Terminal
$ fastkit make module Invoice
Generating module: Invoice
Location : modules/invoices/
Model : Invoice
Table : invoices
Mode : sync
✓  __init__.py
✓  models.py
✓  schemas.py
✓  repository.py
✓  service.py
✓  router.py
✓  Registered model in alembic/env.py
Done! Next steps:
1. Define your fields in  modules/invoices/models.py
2. Add schemas in          modules/invoices/schemas.py
3. Run: fastkit migrate make -m 'create_invoices'

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.

Seconds, not hours

A complete module with 6 files generated in one command. Start coding business logic immediately.

Team consistency

Everyone generates the same structure. No more "how did you organize your service?" debates.

Best practices built in

Generated code follows FastKit Core architecture — repository pattern, service layer, type hints throughout.

Async / sync

Add --async to generate async-ready files using AsyncSession and get_async_db.

Migration wrapper

Alembic commands simplified — fastkit migrate make, run, rollback.

Dev server included

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:

modules/invoices/
__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:

MethodPathHandlerDescription
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:

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:

InputModel classsnake_caseTableFolder
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 — Categorycategories, Personpeople. No configuration needed.

Typical Workflow

From zero to a running, migrated, fully-wired feature:

bash
# 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.