Metadata-Version: 2.4
Name: fastisan
Version: 0.1.1
Summary: A CLI for scaffolding FastAPI components and project boilerplate.
Author: Arun Yadav
License-Expression: MIT
Project-URL: Homepage, https://github.com/itsdevcode/fastisan
Project-URL: Repository, https://github.com/itsdevcode/fastisan
Project-URL: Issues, https://github.com/itsdevcode/fastisan/issues
Keywords: fastapi,cli,scaffolding,code-generator,python
Classifier: Development Status :: 2 - Pre-Alpha
Classifier: Environment :: Console
Classifier: Framework :: FastAPI
Classifier: Intended Audience :: Developers
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: Software Development :: Code Generators
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: typer>=0.12
Requires-Dist: jinja2>=3.1
Requires-Dist: tomli>=2.0
Requires-Dist: inflect>=7.0
Provides-Extra: dev
Requires-Dist: pytest>=8.0; extra == "dev"
Requires-Dist: build>=1.2; extra == "dev"
Dynamic: license-file

<div align="center">
  <img src="assets/hero_banner.jpg" alt="Fastisan Hero Banner" />

# Fastisan

### Scaffold FastAPI applications without writing the same boilerplate again.

Generate models, schemas, repositories, services, routers, middleware,
database foundations, and complete CRUD resources from the command line.

[![PyPI version](https://img.shields.io/pypi/v/fastisan.svg)](https://pypi.org/project/fastisan/)
[![Python](https://img.shields.io/pypi/pyversions/fastisan.svg)](https://pypi.org/project/fastisan/)
[![License](https://img.shields.io/pypi/l/fastisan.svg)](LICENSE)
[![GitHub stars](https://img.shields.io/github/stars/itsdevcode/fastisan?style=flat)](https://github.com/itsdevcode/fastisan/stargazers)

**[Installation](#installation) • [Quick Start](#quick-start) • [What it Generates](#what-fastisan-generates) • [Architecture](#architecture) • [Commands](#commands) • [Roadmap](#roadmap)**

</div>

---

## ⚡ What is Fastisan?

Building scalable FastAPI applications often requires repetitive setup: defining SQLAlchemy models, Pydantic schemas, setting up a Repository pattern, creating Service layers for business logic, mapping them to Routers, and configuring Alembic migrations.

**Fastisan** automates much of this scaffolding process. With a single command, you can generate a robust, layered architecture for any resource, allowing you to focus on the actual business logic rather than writing boilerplate code.

---

## 🚀 Installation

Install Fastisan globally or in your project's virtual environment via pip:

```bash
pip install fastisan
```

---

## 🚦 Quick Start

Initialize a new Fastisan project and generate your first complete CRUD resource in seconds:

```bash
mkdir my-api && cd my-api

# 1. Initialize the FastAPI foundation (database, alembic, core files, requirements.txt)
fastisan init

# 2. Install the generated application dependencies
pip install -r requirements.txt

# 3. Scaffold a complete User resource with specific fields
fastisan make:resource User \
  --fields "name:str,email:str,age:int?"
```

### What it Generates

When you run the `make:resource` command, Fastisan automatically sets up the complete layered structure for you:

```text
app/
├── models/
│   └── user.py        # SQLAlchemy Model
├── schemas/
│   └── user.py        # Pydantic Schemas (Create, Update, Read)
├── repositories/
│   └── user.py        # Async Database Operations
├── services/
│   └── user.py        # Business Logic Layer
└── routers/
    └── user.py        # FastAPI API Endpoints
```

### From one command to a complete resource

```text
                    fastisan make:resource User
                              │
             ┌────────────────┼────────────────┐
             │                │                │
             ▼                ▼                ▼
           Model            Schema         Repository
                                                │
                                                ▼
                                             Service
                                                │
                                                ▼
                                             Router
                                                │
                                                ▼
                                             FastAPI
```

---

## 🛠 What Fastisan Generates

| Command | Generates | Description |
|---|---|---|
| `fastisan init` | Application foundation | Sets up FastAPI, runtime dependencies (`requirements.txt`), SQLAlchemy db config, Alembic migrations, and directory structure. |
| `make:model` | SQLAlchemy model | Creates a SQLAlchemy declarative model. |
| `make:schema` | Pydantic schemas | Scaffolds Create, Update, and Response schemas for validation. |
| `make:repository` | Async repository | Sets up the data access layer for CRUD operations. |
| `make:service` | Service layer | Creates a service class for separating business logic from routers. |
| `make:router` | FastAPI router | Generates standard RESTful API endpoints mapped to the service layer. |
| `make:middleware` | ASGI middleware | Creates a skeleton for custom request/response interception. |
| `make:resource` | **Complete CRUD resource** | Coordinates the generation of a full, layered API resource instantly. |

---

## 🏗 Architecture

Fastisan generates a clean, layered architectural pattern, keeping your codebase maintainable and scalable as it grows:

```text
   Client Request
         │
         ▼
      FastAPI (app)
         │
         ▼
      Router  <───────── Request Validation (Schemas)
         │
         ▼
      Service <───────── Business Logic
         │
         ▼
    Repository <──────── Data Access Abstraction
         │
         ▼
   AsyncSession
         │
         ▼
       Database
```

---

## 💻 Commands

Fastisan provides a variety of commands to streamline your workflow. You can view all available commands by running `fastisan --help`. Below are the core commands:

- `fastisan init`: Scaffolds the initial FastAPI project structure and dependency manifest (`requirements.txt`).
- `fastisan make:resource <name>`: Generates a complete API resource (Model, Schema, Repository, Service, Router).
- `fastisan make:model <name>`: Generates a SQLAlchemy model.
- `fastisan make:schema <name>`: Generates Pydantic schemas.
- `fastisan make:repository <name>`: Generates an async repository class.
- `fastisan make:service <name>`: Generates a business logic service layer.
- `fastisan make:router <name>`: Generates a FastAPI APIRouter.
- `fastisan make:middleware <name>`: Generates an ASGI middleware.

---

## 📦 Project Dependencies

When you run `fastisan init`, Fastisan generates a `requirements.txt` manifest tailored to the chosen ORM:

- **SQLAlchemy (`1`)**: includes runtime dependencies for the FastAPI app and async database stack:
  ```text
  fastapi>=0.110.0
  uvicorn>=0.30.0
  pydantic>=2.7.0
  pydantic-settings>=2.2.0
  sqlalchemy[asyncio]>=2.0.0
  alembic>=1.13.0
  asyncpg>=0.29.0
  ```
- **None (`2`)**: includes only core application dependencies without database drivers or ORM libraries:
  ```text
  fastapi>=0.110.0
  uvicorn>=0.30.0
  pydantic>=2.7.0
  ```

To install the generated dependencies in your virtual environment:

```bash
pip install -r requirements.txt
```

---

## 📦 Database & Alembic

When SQLAlchemy is selected, Fastisan generates async SQLAlchemy session wiring and an Alembic migration foundation. The `fastisan init` command prepares everything you need to start migrating.

```bash
# After generating a new resource, create a migration
alembic revision --autogenerate -m "Added User resource"

# Apply the migration to your database
alembic upgrade head
```

---

## 🚧 Current Limitations (v0.1.0)

- **Early Stage (Pre-Alpha):** Fastisan is currently in early development and APIs/generated structures may change.
- **Database Support:** Defaults to **async SQLAlchemy** (tested with PostgreSQL + asyncpg). Synchronous repositories and other database engines are not explicitly supported yet.
- **Relationships:** Relationships between models (e.g., One-to-Many, Many-to-Many) must be configured manually after scaffolding.
- **Field Constraints:** Advanced field constraints (like unique, index, length) via CLI arguments are limited and may require manual updates to the generated models.

---

## 🗺 Roadmap

- [ ] Support for richer field constraints via CLI (e.g., `email:str:unique:index`).
- [ ] Automatic generation of model relationships and Foreign Keys.
- [ ] Generated-project dependency management (automatic additions to requirements).
- [ ] Dry-run mode (`--dry-run`) to preview generated files without writing them.
- [ ] `fastisan inspect` or `doctor` commands to check project health and configuration.

---

## 🤝 Contributing

We welcome contributions! If you'd like to help improve Fastisan, please check out our [Contributing Guidelines](CONTRIBUTING.md).

1. Fork the repository
2. Create a feature branch (`git checkout -b feature/amazing-feature`)
3. Commit your changes (`git commit -m 'Add some amazing feature'`)
4. Push to the branch (`git push origin feature/amazing-feature`)
5. Open a Pull Request

---


## ☕ Support Fastisan

If Fastisan saves you time or helps with your FastAPI projects, consider supporting its development.

<a href="https://www.buymeacoffee.com/itsdevcode">
  <img src="https://img.buymeacoffee.com/button-api/?text=Buy%20me%20a%20coffee&emoji=%E2%98%95&slug=itsdevcode&button_colour=FFDD00&font_colour=000000&font_family=Cookie&outline_colour=000000&coffee_colour=ffffff" alt="Buy me a coffee" />
</a>

---

## 👤 Author

**Arun Yadav** — [@itsdevcode](https://github.com/itsdevcode)

---

<div align="center">
  Built with ❤️ for the FastAPI ecosystem.
</div>
