Metadata-Version: 2.4
Name: fastgen-cli
Version: 0.4.0
Summary: FastAPI feature-based module manager (nest-cli style for FastAPI)
Author-email: YIbaikaishui <162815827+YIbaikaishui@users.noreply.github.com>
License: MIT
License-File: LICENSE
Keywords: cli,code-generator,fastapi,nest-cli,scaffold
Classifier: Development Status :: 4 - Beta
Classifier: Environment :: Console
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Software Development :: Code Generators
Classifier: Typing :: Typed
Requires-Python: >=3.11
Requires-Dist: jinja2>=3.1
Requires-Dist: rich>=13.7
Requires-Dist: typer>=0.12
Description-Content-Type: text/markdown

# fastgen

A `nest cli`-style module manager for FastAPI: it scaffolds a minimal,
zero-config module skeleton (entity, service, router, shared session
dependency) and keeps a module registry so AI agents and developers can see
the project structure at a glance. Fill in the business logic yourself.

## Install

```bash
pip install fastgen-cli
# or
uv add fastgen-cli
```

## Usage

```bash
fastgen --help

# Scaffold a feature module and register it
fastgen make module user

# List registered modules and their boundaries
fastgen list
```

Both commands support `--dir <root>` (project root, defaults to cwd),
`--dry-run` (preview without writing) and `--force` (overwrite existing
skeleton files).

Running `fastgen make module <feature>` generates:

```
app/
├── core/                        # auto-created on first use
│   ├── config.py                # pydantic-settings Settings (DATABASE_URL in .env)
│   └── database.py              # Base (AsyncAttrs), async engine, get_session dependency
└── modules/
    ├── __init__.py              # module registry (auto-maintained, do not edit)
    └── user/
        ├── __init__.py          # re-exports router
        ├── schemas.py           # Pydantic entity skeleton: class User(BaseModel): pass
        ├── service.py           # business layer boundary: class UserService
        └── router.py            # APIRouter + SessionDep (Annotated[AsyncSession, Depends(get_session)])
```

Existing code is never overwritten: `app/core/config.py` / `database.py` are
only generated when missing or empty.

## Conventions (fixed)

- Modules live in `app/modules/<feature>/`, one business unit per folder.
- The router exposes `prefix="/<plural>"` and tags; the shared session
  dependency is imported from `app.core.database`.
- `app/modules/__init__.py` is a fastgen-maintained registry
  (`modules: dict[str, str]`) mapping module name to import path; `fastgen list`
  reads it (and each module's docstring) to show the whole project.

## Roadmap

- Phase 1: `make module` (schemas + service skeleton) ✅
- Phase 2: module registry + `fastgen list` ✅
- Phase 3: `make resource` (full CRUD router), Alembic migration hints
