Fastman is a Laravel-inspired CLI tool for FastAPI. It eliminates boilerplate fatigue by generating project structures, handling database migrations, and scaffolding features, models, and middleware instantly.
Whether you prefer Vertical Slice (Feature) architecture or Layered architecture, Fastman sets it up for you in seconds.
- Zero-Dependency Core: Runs with standard library (Rich/Pyfiglet optional for UI)
- Smart Package Detection: Automatically uses uv, poetry, pipenv, or pip
- Multiple Architectures: Supports feature (default), api, and layer patterns
- Database Ready: First-class support for SQLite, PostgreSQL, MySQL, Oracle, and Firebase
- Interactive Shell: Includes a tinker command to interact with your app context
- Auth Scaffolding: One-command JWT or Keycloak authentication setup
- Extensible: Create custom CLI commands with
make:command
Install Fastman from PyPI:
pip install fastmanOr with uv (recommended):
uv pip install fastmanGenerate a new API with a specific architecture and package manager:
# Default (Feature pattern + UV + SQLite)
fastman new my-project
# Layered architecture with PostgreSQL and Poetry
fastman new blog_api --pattern=layer --database=postgresql --package=poetry
# Minimal project setup
fastman new minimal_api --minimalcd my-project
fastman serveVisit http://127.0.0.1:8000/docs to see your API documentation.
Fastman supports three directory structures out of the box:
Best for domain-driven design and vertical slices. Code is organized by "what it does" rather than "what it is."
app/
├── features/
│ └── auth/ # Router, Service, Models, Schemas all in one place
├── api/ # Simple endpoints
└── core/ # Shared config
Traditional MVC-style architecture.
app/
├── controllers/
├── services/
├── repositories/
├── models/
└── schemas/
Lightweight structure for simple microservices.
app/
├── api/
├── schemas/
└── models/
fastman new {name} [--minimal] [--pattern=feature] [--package=uv] [--database=sqlite]Create a new FastAPI project with your preferred architecture and database.
Options:
--minimal- Create minimal project structure--pattern- Architecture pattern:feature(default),layer, orapi--package- Package manager:uv(default),poetry, orpipenv--database- Database:sqlite(default),postgresql,mysql,oracle, orfirebase
Examples:
# Feature-based project with PostgreSQL
fastman new blog --pattern=feature --database=postgresql
# Layered project with MySQL
fastman new ecommerce --pattern=layer --database=mysql --package=poetry
# Minimal API with Firebase
fastman new notifications --minimal --database=firebasefastman initAdd Fastman support to an existing FastAPI project. This creates the necessary directory structure and configuration files.
fastman serve [--host=127.0.0.1] [--port=8000] [--reload]Start the Uvicorn development server with hot reload enabled by default.
Options:
--host- Host address (default: 127.0.0.1)--port- Port number (default: 8000)--reload- Enable auto-reload (enabled by default)
Examples:
# Start on default port
fastman serve
# Start on custom host and port
fastman serve --host=0.0.0.0 --port=3000fastman make:feature {name} [--crud]Create a complete vertical slice feature with router, service, model, and schema files.
Options:
--crud- Generate CRUD endpoints (Create, Read, Update, Delete)
Examples:
# Create basic feature
fastman make:feature posts
# Create feature with full CRUD
fastman make:feature users --crudfastman make:api {name} [--style=rest]Create a lightweight API endpoint for simpler use cases.
Options:
--style- API style:rest(default) orgraphql
Examples:
# REST API
fastman make:api products
# GraphQL API
fastman make:api search --style=graphqlfastman make:websocket {name}Create a WebSocket endpoint with connection manager for real-time communication.
Example:
fastman make:websocket chatfastman make:controller {name}Create a controller class for handling HTTP requests (useful in layered architecture).
Example:
fastman make:controller UserControllerfastman make:model {name} [--table=]Create a SQLAlchemy model for database operations.
Options:
--table- Specify custom table name
Examples:
# Model with auto-generated table name
fastman make:model User
# Model with custom table name
fastman make:model BlogPost --table=postsfastman make:service {name}Create a service class for business logic layer.
Example:
fastman make:service EmailServicefastman make:repository {name}Create a repository pattern class for data access abstraction.
Example:
fastman make:repository UserRepositoryfastman make:middleware {name}Create a FastAPI middleware for request/response processing.
Example:
fastman make:middleware LoggingMiddlewarefastman make:dependency {name}Create a FastAPI dependency for dependency injection.
Example:
fastman make:dependency get_current_userfastman make:exception {name}Create a custom exception class for error handling.
Example:
fastman make:exception ValidationExceptionfastman make:command {name}Create a custom Fastman CLI command for your project-specific needs.
Example:
fastman make:command ProcessPaymentsThis generates a command template in app/console/commands/ that you can customize. Your custom commands are automatically loaded by Fastman.
fastman make:test {name}Create a pytest test file with boilerplate code.
Example:
fastman make:test test_usersfastman make:migration {message}Create a new Alembic migration file.
Example:
fastman make:migration "add users table"fastman migrateRun all pending database migrations.
fastman migrate:rollback [--steps=1]Rollback the last N migrations.
Options:
--steps- Number of migrations to rollback (default: 1)
Example:
# Rollback last migration
fastman migrate:rollback
# Rollback last 3 migrations
fastman migrate:rollback --steps=3fastman migrate:resetRollback all migrations (reset database to initial state).
fastman migrate:statusDisplay the current status of all migrations.
fastman make:seeder {name}Create a database seeder for populating test data.
Example:
fastman make:seeder UsersSeederfastman db:seed [--class=]Run database seeders to populate your database with test data.
Options:
--class- Run specific seeder class
Examples:
# Run all seeders
fastman db:seed
# Run specific seeder
fastman db:seed --class=UsersSeederfastman make:test {name}Create a pytest test file with standard boilerplate.
Example:
fastman make:test test_authenticationfastman make:factory {name}Create a model factory for generating test data.
Example:
fastman make:factory UserFactoryfastman install:auth [--type=jwt] [--provider=]Scaffold complete authentication system with login, registration, and user management.
Options:
--type- Authentication type:jwt(default),oauth, orkeycloak--provider- OAuth provider (for OAuth type):google,github, etc.
Examples:
# Install JWT authentication
fastman install:auth
# Install OAuth with Google
fastman install:auth --type=oauth --provider=google
# Install Keycloak integration
fastman install:auth --type=keycloakThis generates:
app/features/auth/(Router, Service, Schemas)- JWT/OAuth handling utilities
- User model and migration
- Login/Register/Me endpoints
fastman import {package}Install a Python package using the detected package manager.
Example:
fastman import requestsfastman pkg:listDisplay all installed Python packages in the project.
fastman tinkerOpen an interactive Python shell with your app context loaded (settings, database session, models).
Example:
$ fastman tinker
Fastman Interactive Shell
Available: settings, SessionLocal, Base, db
>>> user = db.query(User).first()
>>> print(user.email)
admin@example.comfastman route:list [--path=] [--method=]Display a table of all registered API routes.
Options:
--path- Filter by path pattern--method- Filter by HTTP method (GET, POST, etc.)
Examples:
# List all routes
fastman route:list
# Filter by path
fastman route:list --path=/api/users
# Filter by method
fastman route:list --method=POSTfastman inspect {type} {name}Inspect a specific component (model, route, feature) in your project.
Example:
fastman inspect model User
fastman inspect route /api/users
fastman inspect feature authfastman generate:key [--show]Generate a secure secret key for your application.
Options:
--show- Display the key in terminal
Example:
fastman generate:key --showfastman config:cacheCache the environment configuration for faster loading.
fastman config:clearClear the cached configuration.
fastman cache:clearRemove all Python __pycache__ directories and .pyc files.
fastman optimize [--check]Format code, sort imports, and remove unused variables.
Options:
--check- Check only without making changes
Example:
# Optimize and fix
fastman optimize
# Check without changes
fastman optimize --checkfastman build [--docker]Build the project for production deployment.
Options:
--docker- Generate Dockerfile and docker-compose.yml
Examples:
# Standard build
fastman build
# Build with Docker configuration
fastman build --dockerfastman docs [--open]Display Fastman documentation or open it in browser.
Options:
--open- Open documentation in web browser
fastman listDisplay a list of all available Fastman commands with descriptions.
fastman versionDisplay the currently installed Fastman version.
Create project-specific CLI commands:
# Generate custom command
fastman make:command SendEmails
# Edit the generated file
# app/console/commands/send_emails_command.pyYour custom command structure:
from fastman import Command, register
@register
class SendEmailsCommand(Command):
signature = "emails:send {--queue}"
description = "Send pending emails"
def handle(self):
queue = self.flag("queue")
# Your logic here
self.info("Emails sent!")Run it with:
fastman emails:send --queueFor clean architecture, use the repository pattern:
# Create repository
fastman make:repository UserRepository
# Create service that uses it
fastman make:service UserServiceComplete testing setup:
# Create factories for test data
fastman make:factory UserFactory
fastman make:factory PostFactory
# Create test file
fastman make:test test_posts
# Create seeders for development
fastman make:seeder DevelopmentSeeder
# Run seeders
fastman db:seedFastman automatically detects your project setup:
- Package Manager: uv, poetry, pipenv, or pip
- Database: From
DATABASE_URLin settings - Project Pattern: From directory structure
All commands respect your project's configuration.
- Use Feature Pattern for domain-driven apps with complex business logic
- Use Layer Pattern for traditional MVC-style applications
- Use API Pattern for simple microservices
- Always run migrations after creating models
- Use seeders for development data, factories for testing
- Create custom commands for repetitive tasks
- Use repositories for clean separation of data access logic
# Generate Docker configuration
fastman build --docker
# Files created: Dockerfile, docker-compose.yml# In your pipeline
fastman migrate # Run migrations
fastman optimize --check # Lint check
fastman build # Production build# Setup test database
fastman db:seed --class=TestSeeder
# Run tests with pytest
pytest tests/Command not found: Ensure Fastman is installed in your active environment:
pip install --upgrade fastmanPackage manager not detected: Explicitly specify when creating projects:
fastman new myapp --package=poetryMigration errors: Check your database connection string in .env or settings.
Custom commands not loading: Ensure they're in app/console/commands/ and use the @register decorator.
Fastman is open source! Contributions are welcome.
Repository: https://github.com/fastman/fastman
This project is licensed under the Apache License 2.0.
- Documentation: Run
fastman docs --open - Issues: https://github.com/fastman/fastman/issues
- Discussions: https://github.com/fastman/fastman/discussions
Happy building with Fastman! 🚀
