Fastisan
Fastisan is a command-line tool for scaffolding FastAPI components and project boilerplate.
It aims to reduce repetitive setup work while keeping generated code simple, readable, and easy to customize.
Fastisan is currently in pre-alpha development. APIs, commands, and generated output may change before the first stable release.
Features
Fastisan currently supports:
- Project initialization with
fastisan init - ORM selection during project initialization
- SQLAlchemy project foundation generation
- FastAPI router generation
- ORM-aware model generation
- Pydantic schema generation
- Service generation
- ORM-aware repository generation
- Complete resource scaffolding
- ASGI middleware generation
- Automatic Python class-name normalization
- Automatic snake_case file naming
- Automatic pluralized SQLAlchemy table names
- Protection against accidentally overwriting generated files
More generators and project scaffolding features are planned.
Requirements
- Python 3.10 or newer
Installation
Fastisan is currently under active development and is not yet published as a stable PyPI release.
For local development, clone the repository and install it in editable mode:
git clone https://github.com/itsdevcode/fastisan.git
cd fastisan
python -m venv .venv
source .venv/bin/activate
python -m pip install -e .
Verify the installation:
fastisan --help
Quick Start
Initialize a project
From your FastAPI project directory, run:
fastisan init
Fastisan will ask which ORM the project should use:
Select your ORM:
1. SQLAlchemy
2. None
The selected configuration is stored in:
fastisan.toml
For example:
[project]
orm = "sqlalchemy"
When SQLAlchemy is selected, Fastisan generates the application foundation, including database components:
app/
├── __init__.py
├── main.py
├── db/
│ ├── __init__.py
│ ├── base.py
│ └── session.py
├── models/
│ └── __init__.py
├── schemas/
│ └── __init__.py
├── repositories/
│ └── __init__.py
├── services/
│ └── __init__.py
└── routers/
├── __init__.py
└── registry.py
app/main.py is a minimal, runnable FastAPI application (once application dependencies like FastAPI itself are installed) with a /health endpoint.
The registry.py file is deterministically managed by Fastisan and automatically aggregates all your generated routers.
Fastisan generates a reusable async SQLAlchemy session dependency inside session.py. It expects a database connection string via the DATABASE_URL environment variable (e.g., postgresql+asyncpg://...).
Database Migration and Dependencies
Fastisan generates the project foundation, but it does not manage your runtime dependencies. When scaffolding a SQLAlchemy project, ensure your project environment installs the required asynchronous driver, ORM, and migration tools:
pip install "sqlalchemy[asyncio]" alembic asyncpg
You must also configure your DATABASE_URL environment variable for migrations and application connectivity (e.g., export DATABASE_URL="postgresql+asyncpg://user:pass@localhost/dbname").
Generate a Router
fastisan make:router User
Generates a FastAPI router for the resource.
When the corresponding schema and service files exist, Fastisan automatically generates a service-aware CRUD router that:
- Delegates application logic to the service layer
- Handles HTTP 404 responses when resources are not found
- Defines an explicit composition boundary via a
get_user_servicedependency function
If all composition prerequisites exist (schema, repository, service, and database session), the router automatically generates fully wired dependency injection:
def get_user_service(
session: AsyncSession = Depends(get_session),
) -> UserService:
repository = UserRepository(session)
return UserService(repository)
If some prerequisites are missing, a raise NotImplementedError placeholder is generated instead for you to implement manually.
If the required components do not exist, a lightweight fallback router is generated instead.
Generate a Model
Model generation uses the ORM configured by fastisan init.
fastisan make:model User
With SQLAlchemy configured, Fastisan generates:
app/
└── models/
└── user.py
The generated model includes a primary key and timestamp fields.
Fastisan also normalizes model names:
fastisan make:model user
generates a User class with the users table.
Similarly:
fastisan make:model blog_post
generates:
class BlogPost(Base):
__tablename__ = "blog_posts"
Generate a Schema
fastisan make:schema User
Generates a Pydantic schema file for the model.
Generate a Repository
fastisan make:repository User
Generates an ORM-aware repository for the model (requires an ORM to be configured and the model file to exist).
Generate a Service
fastisan make:service User
Generates a service layer class for the model. When generated as part of a complete resource (or when the corresponding repository exists), the service will automatically integrate with and delegate to the repository.
Generate a Resource
fastisan make:resource User
You can also scaffold a resource with coordinated user-defined fields:
fastisan make:resource User \
--fields "name:str,email:str,age:int?,is_active:bool"
Supported v1 field types:
strintfloatbooldatetime
Appending ? to the field type (e.g., age:int?) marks the field as optional (nullable).
Generates a complete resource scaffold safely:
app/models/user.py
app/schemas/user.py
app/repositories/user.py
app/services/user.py
app/routers/user.py
After generating the resource, Fastisan automatically registers user.py into app/routers/registry.py so your main application immediately serves the new endpoints.
The generated router is fully integrated with the service and repository layers, providing complete CRUD functionality out of the box. Because init generates the SQLAlchemy session foundation, make:resource automatically wires AsyncSession, the repository, and the service together in the router's dependency function.
Generate a Middleware
fastisan make:middleware Auth
Generates a generic pass-through ASGI middleware:
app/
└── middleware/
└── auth.py
ORM Support
Current ORM support:
| ORM | Status |
|---|---|
| SQLAlchemy | Supported |
| None | Supported |
Fastisan's core is designed to remain ORM-agnostic where practical so additional ORM integrations can be introduced independently.
Project Status
Fastisan is currently pre-alpha.
The project is being developed incrementally with tests around generators, naming behavior, project configuration, and CLI behavior.
The current focus is establishing a reliable foundation before expanding the generator surface.
Roadmap
Potential future capabilities include:
- Resource generation
- Complete FastAPI project scaffolding
- Additional ORM integrations
- Improved project configuration
- Release automation
The roadmap may evolve as the project develops.
Development
Clone the repository:
git clone https://github.com/itsdevcode/fastisan.git
cd fastisan
Create and activate a virtual environment:
python -m venv .venv
source .venv/bin/activate
Install Fastisan with development dependencies:
python -m pip install -e ".[dev]"
Run the test suite:
pytest -v
Check for whitespace errors:
git diff --check
Contributing
Contributions are welcome.
Before contributing, please read CONTRIBUTING.md.
Bug reports and feature requests can be submitted through GitHub Issues.
Security
Please do not report security vulnerabilities through public GitHub issues.
See SECURITY.md for reporting guidance.
Code of Conduct
Participation in the Fastisan community is governed by the Code of Conduct.
License
Fastisan is released under the MIT License.
Metadata
Release files for fastisan 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| fastisan-0.1.0.tar.gz | 29.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| fastisan-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 57.3 kB
Release files / fastisan-0.1.0.tar.gz
| Download URL | fastisan-0.1.0.tar.gz |
|---|---|
| Size | 29.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5dca3f53c3d3d97c08a27bde1889186bb562166ff754eb98f14d562de97ee2e2
|
|
BLAKE2b-256 checksum How to use checksums |
5f48ed00989ddce41954baf8298886dc5e5ba14d5fbdec74f8ab6d2d4cbdaf84
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.3
|
Release files / fastisan-0.1.0-py3-none-any.whl
| Download URL | fastisan-0.1.0-py3-none-any.whl |
|---|---|
| Size | 28.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5ebae7dac28156c7406a9a98370af7ed5d03c756177b1ba12e030cfab5a39975
|
|
BLAKE2b-256 checksum How to use checksums |
6f2ed5ae275d3821c9fad331014f28a62f9b017b74b3e5715193bda3fe48c4b2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.3
|