Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,31 +17,31 @@ repos:
entry: black --config pyproject.toml --check .
language: python
types: [python]
additional_dependencies: ['black>=24.10.0']
additional_dependencies: ['black==26.10.1']
pass_filenames: false

- id: isort-check
name: isort check
entry: isort --sp pyproject.toml --check-only --diff .
language: python
types: [python]
additional_dependencies: ['isort>=5.13.2']
additional_dependencies: ['isort==9.0.1']
pass_filenames: false

- id: isort-fix
name: isort fix
entry: isort --sp pyproject.toml .
language: python
types: [python]
additional_dependencies: ['isort>=5.13.2']
additional_dependencies: ['isort==9.0.1']
pass_filenames: false

- id: black-fix
name: black fix
entry: black --config pyproject.toml .
language: python
types: [python]
additional_dependencies: ['black>=24.10.0']
additional_dependencies: ['black==26.10.1']
pass_filenames: false

- id: mypy
Expand All @@ -50,12 +50,12 @@ repos:
language: python
types: [python]
additional_dependencies:
- mypy>=1.12.0
- rich>=13.9.2
- click>=8.1.7
- pyyaml>=6.0.0
- jinja2>=3.1
- types-PyYAML>=6.0.12
- mypy==2.3.1
- rich==15.0.0
- click==8.3.2
- pyyaml==6.0.3
- jinja2==3.1.6
- types-PyYAML==6.0.12.20260408
pass_filenames: false

ci:
Expand Down
34 changes: 22 additions & 12 deletions CHANGELOG.md

Large diffs are not rendered by default.

88 changes: 36 additions & 52 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ This project was inspired by the `SpringBoot initializer` & Python Django's `dja
## Key Features

- **⚡ Immediate FastAPI project creation** : Super-fast FastAPI workspace & project creation via CLI, inspired by `django-admin` feature of [Python Django](https://github.com/django/django)
- **✨ Interactive project builder**: Guided step-by-step feature selection for databases, authentication, caching, monitoring, and more with auto-generated code
- **✨ Guided project builder**: Pick a level from one `main.py` to a production layout, then customise databases, authentication, caching, monitoring, and more with auto-generated code
- **🎨 Prettier CLI output** : Beautiful CLI experience powered by [rich library](https://github.com/Textualize/rich)
- **📋 Standards-based FastAPI project templates** : Templates follow Python standards and common FastAPI patterns.
- **🔍 Automated template quality assurance** : Weekly automated testing ensures all templates remain functional and up-to-date
- **🚀 Multiple project templates** : Choose from various pre-configured templates for different use cases (async CRUD, Docker, PostgreSQL, etc.)
- **📦 Multiple package manager support** : Choose your preferred Python package manager (pip, uv, pdm, poetry) for dependency management
- **🧾 Reproducible project configs** : Save an interactive session to a `.json` / `.toml` / `.yaml` file and replay it with `fastkit init --config`
- **🧾 Reproducible project configs** : Save a project's choices to a `.json` / `.toml` / `.yaml` file and replay it with `fastkit init --config`
- **🏷️ Self-describing projects** : Every generated project records its template, preset, package manager, entrypoint and selected features in a `[tool.fastapi-fastkit]` block that `runserver` and `addroute` read back

## Installation
Expand All @@ -58,64 +58,49 @@ $ pip install FastAPI-fastkit
fastkit init [OPTIONS]
```
> [!TIP]
> Scaffolds an empty FastAPI project, creates a virtual environment, installs dependencies

> Asks for a project name and a level, then creates the project, sets up a virtual environment and installs the dependencies

- Levels, each one adds structure to the one above:
- `hello` (default): one `main.py` with three endpoints, in-memory data and tests
- `single-file`: the whole app in one module, with settings and tests
- `layered`: separate layers for routes, CRUD, schemas and core configuration
- `domain`: one package per domain with router, service and repository
- `production`: `domain` plus PostgreSQL, Alembic, JWT, CI and Docker
- Asks only what the options leave open: the project name, the level, the database (levels after `hello`) and whether to customise. The customise step covers authentication, background tasks, caching, monitoring, logging, testing, migrations, utilities, tooling, deployment, package manager and custom packages
- Key options:
- `--project-name`, `--author`, `--author-email`, `--description`
- `--package-manager` [pip|uv|pdm|poetry]
- `--project-name` (`--name`), `--level`, `--database` [PostgreSQL|MySQL|MongoDB|Redis|SQLite|None]
- `--feature AXIS=VALUE` (repeatable, e.g. `--feature authentication=JWT`; `fastkit list-features` shows the values) and `--extra-package`, for levels after `hello`
- `--template <name>`: copy a bundled template as it is instead of choosing a level (see below)
- `--author`, `--author-email` (default to `git config user.name` / `user.email`), `--description`
- `--package-manager` [pip|uv|pdm|poetry]: defaults to uv when installed, otherwise pip
- `--config <path>`: create the project from a saved config file (`.json` / `.toml`, and `.yaml` when PyYAML is installed) with no prompts
- `--save-config <path>`: with `--interactive`, record the answers for later reuse
- `--save-config <path>`: write the project's configuration to a file for reuse with `--config`
- `--in-place`: write into the current directory instead of a new folder
- `--dry-run`: print the files and packages that would be created, write nothing
- `--no-venv`: skip virtual environment creation (implies `--no-install`)
- `--no-install`: skip dependency installation
- `--yes` / `-y`: skip the "Overwrite these files?" confirmation when deploying in place
- Stack selection: `minimal` | `standard` | `full` (interactive)
- `--yes` / `-y`: use the defaults for every question that has one and create the project without asking; with `--in-place`, also allow overwriting files
- Without a terminal nothing is asked: pass `--project-name` (or `--config`) and everything else takes its default. Exit status: 0 created, previewed or cancelled, 1 refused or failed, 2 invalid options

### Create a project with interactive mode
```console
fastkit init --interactive
fastkit init --project-name api --level domain --database SQLite --feature authentication=JWT --no-venv -y
```
> [!TIP]
> Guided step-by-step project setup with intelligent feature selection

- Features:
- **Architecture preset**: `minimal` | `single-module` | `classic-layered` | `domain-starter` (default)
- **Database selection**: PostgreSQL, MySQL, MongoDB, Redis, SQLite
- **Authentication**: JWT, OAuth2, FastAPI-Users, Session-based
- **Background tasks**: Celery, Dramatiq
- **Caching**: Redis, fastapi-cache2
- **Monitoring**: Loguru, OpenTelemetry, Prometheus
- **Testing**: Basic (pytest), Coverage, Advanced (with faker, factory-boy)
- **Utilities**: Rate-Limiting, WebSocket (CORS and pagination are built into every project)
- **Logging**: structured JSON logging with a request-id middleware
- **Migrations**: Alembic (async env, baseline revision)
- **Tooling**: ruff, pre-commit, GitHub Actions, devcontainer, Makefile (multi-select)
- **Deployment**: Docker, docker-compose with auto-generated configs
- **Package manager**: pip, uv, pdm, poetry
- **Custom packages**: Add your own dependencies
- Auto-generates (varies by preset - see [the matrix](https://bnbong.github.io/FastAPI-fastkit/reference/preset-feature-matrix/) for details):
- `main.py` regenerated from selected features for `minimal` / `single-module`; for `classic-layered` / `domain-starter` the shipped `main.py` is kept and every feature is wired into it
- Database module and authentication package at preset-specific paths, with routes under `/api/v1`
- Docker deployment files (`Dockerfile`, `docker-compose.yml`) with the preset's correct uvicorn entrypoint
- Test configuration (pytest with coverage)
- `GET /health` on every generated project, and `GET /ready` when it has a database or cache
- Real working code with tests — not just installed packages — for background tasks, caching, WebSocket, rate limiting, OpenTelemetry, and JWT, FastAPI-Users, OAuth2 and session-based auth
- `--dry-run` previews the exact file tree a run would create, including logging/migrations/tooling artifacts

Every generated project serves `GET /health` at the root and mounts its API under `/api/v1`; with a database or cache it also serves `GET /ready`. Selected features come with real working code and tests, not just installed packages. See [the matrix](https://bnbong.github.io/FastAPI-fastkit/reference/preset-feature-matrix/) for where each feature lands per level.

### Create a project from a template
```console
fastkit startdemo [TEMPLATE] [OPTIONS]
fastkit init --template <TEMPLATE> [OPTIONS]
```
> [!TIP]
> Creates a project from a template (e.g., `fastapi-default`) and installs dependencies
> Copies a bundled template (e.g., `fastapi-default`) as it is and installs dependencies

- Key options:
- `--project-name`, `--author`, `--author-email`, `--description`
- `--package-manager` [pip|uv|pdm|poetry]
- `--dry-run`, `--no-venv`, `--no-install`, `--yes`/`-y` — same meaning as on `init`
- Refuses to run if the target project directory already exists (`--dry-run` excepted), and then exits with status 1
- Asks for the project name and whether to customise the package manager and project details. Author and email come from git config unless you pass `--author` and `--author-email`
- Takes the same `--project-name`, `--package-manager`, `--dry-run`, `--no-venv`, `--no-install`, `--yes`/`-y`, `--in-place` and `--save-config` options as `init`; `--level`, `--database`, `--feature` and `--extra-package` are refused
- Refuses to run if the target project directory already exists (`--dry-run` excepted), and then exits with status 1
- Tip: List available templates with `fastkit list-templates` (simplest first). A misspelled name suggests the closest match
- New to FastAPI? Start with `fastkit startdemo fastapi-hello`: one `main.py` with three endpoints and their tests
- New to FastAPI? Run `fastkit init` and press Enter at the level question, or start with `fastkit init --template fastapi-hello`: one `main.py` with three endpoints and their tests
- `fastkit startdemo [TEMPLATE]` is an alias of `init --template`, kept for scripts written for 1.x. It prints a one-line note and still asks for author, email and description

### Add a new route
```console
Expand Down Expand Up @@ -155,11 +140,10 @@ Available templates:

| Template | Description | Notes |
|---|---|---|
| [`fastapi-hello`](src/fastapi_fastkit/fastapi_project_template/fastapi-hello/README.md-tpl) | Smallest FastAPI app: three endpoints, one pydantic model, one test file | Start here |
| [`fastapi-default`](src/fastapi_fastkit/fastapi_project_template/fastapi-default/README.md-tpl) | Simple FastAPI project with a classic layered layout | Good first choice |
| [`fastapi-empty`](src/fastapi_fastkit/fastapi_project_template/fastapi-empty/README.md-tpl) | Minimal FastAPI template | Base for `minimal` preset |
| [`fastapi-single-module`](src/fastapi_fastkit/fastapi_project_template/fastapi-single-module/README.md-tpl) | Single-file FastAPI app | Base for `single-module` preset |
| [`fastapi-domain-starter`](src/fastapi_fastkit/fastapi_project_template/fastapi-domain-starter/README.md-tpl) | Domain-oriented, pyproject-first starter for medium-sized APIs | Base for `domain-starter` preset |
| [`fastapi-hello`](src/fastapi_fastkit/fastapi_project_template/fastapi-hello/README.md-tpl) | Smallest FastAPI app: three endpoints, one pydantic model, one test file | Level `hello`; start here |
| [`fastapi-default`](src/fastapi_fastkit/fastapi_project_template/fastapi-default/README.md-tpl) | Simple FastAPI project with a classic layered layout | Level `layered`; good first choice |
| [`fastapi-single-module`](src/fastapi_fastkit/fastapi_project_template/fastapi-single-module/README.md-tpl) | Single-file FastAPI app | Level `single-file` |
| [`fastapi-domain-starter`](src/fastapi_fastkit/fastapi_project_template/fastapi-domain-starter/README.md-tpl) | Domain-oriented, pyproject-first starter for medium-sized APIs | Levels `domain` and `production` |
| [`fastapi-auth-jwt`](src/fastapi_fastkit/fastapi_project_template/fastapi-auth-jwt/README.md-tpl) | JWT authentication with refresh-token rotation, argon2 hashing and scopes | New in v1.4.0 |
| [`fastapi-sqlmodel`](src/fastapi_fastkit/fastapi_project_template/fastapi-sqlmodel/README.md-tpl) | Async SQLModel + Alembic migrations + generic CRUD with pagination; SQLite, PostgreSQL or MySQL through one `DATABASE_URL` | New in v1.4.0 |
| [`fastapi-llm-agent`](src/fastapi_fastkit/fastapi_project_template/fastapi-llm-agent/README.md-tpl) | Streaming Claude chat agent (SSE) with a tool-call loop | New in v1.4.0 |
Expand All @@ -178,11 +162,11 @@ Exits with status 1 when the project does not exist, is not a fastkit project or

For comprehensive guides and detailed usage instructions, visit our documentation:

- 🧭 **[Which starter should I choose?](https://bnbong.github.io/FastAPI-fastkit/user-guide/choosing-a-starter/)** - Beginner decision guide for `startdemo` templates and interactive presets
- 🧭 **[Which starter should I choose?](https://bnbong.github.io/FastAPI-fastkit/user-guide/choosing-a-starter/)** - Beginner decision guide for levels and templates
- 📚 **[User Guide](https://bnbong.github.io/FastAPI-fastkit/user-guide/quick-start/)** - Detailed installation and usage guides
- 🎯 **[Tutorial](https://bnbong.github.io/FastAPI-fastkit/tutorial/getting-started/)** - Step-by-step tutorials for beginners
- 📖 **[CLI Reference](https://bnbong.github.io/FastAPI-fastkit/user-guide/cli-reference/)** - Complete command reference
- 🧱 **[Architecture Preset Matrix](https://bnbong.github.io/FastAPI-fastkit/reference/preset-feature-matrix/)** - Per-preset / per-feature contract for interactive generation
- 🧱 **[Architecture Preset Matrix](https://bnbong.github.io/FastAPI-fastkit/reference/preset-feature-matrix/)** - Per-preset / per-feature contract for guided generation
- 🔍 **[Template Quality Assurance](https://bnbong.github.io/FastAPI-fastkit/reference/template-quality-assurance/)** - Automated testing and quality standards

## Contributing
Expand Down
1 change: 0 additions & 1 deletion docs/de/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,6 @@ Verfügbare Vorlagen:
|---|---|---|
| [`fastapi-hello`](https://github.com/bnbong/FastAPI-fastkit/blob/main/src/fastapi_fastkit/fastapi_project_template/fastapi-hello/README.md-tpl) | Kleinste FastAPI-App: drei Endpunkte, ein pydantic-Modell, eine Testdatei | Hier beginnen |
| [`fastapi-default`](https://github.com/bnbong/FastAPI-fastkit/blob/main/src/fastapi_fastkit/fastapi_project_template/fastapi-default/README.md-tpl) | Einfaches FastAPI-Projekt mit klassischem Schichten-Layout | Gute erste Wahl |
| [`fastapi-empty`](https://github.com/bnbong/FastAPI-fastkit/blob/main/src/fastapi_fastkit/fastapi_project_template/fastapi-empty/README.md-tpl) | Minimale FastAPI-Vorlage | Basis für das Preset `minimal` |
| [`fastapi-single-module`](https://github.com/bnbong/FastAPI-fastkit/blob/main/src/fastapi_fastkit/fastapi_project_template/fastapi-single-module/README.md-tpl) | FastAPI-App in einer Datei | Basis für das Preset `single-module` |
| [`fastapi-domain-starter`](https://github.com/bnbong/FastAPI-fastkit/blob/main/src/fastapi_fastkit/fastapi_project_template/fastapi-domain-starter/README.md-tpl) | Domänenorientierter, pyproject-first Starter für mittelgroße APIs | Basis für das Preset `domain-starter` |
| [`fastapi-auth-jwt`](https://github.com/bnbong/FastAPI-fastkit/blob/main/src/fastapi_fastkit/fastapi_project_template/fastapi-auth-jwt/README.md-tpl) | JWT-Authentifizierung mit Refresh-Token-Rotation, argon2-Hashing und Scopes | Neu in v1.4.0 |
Expand Down
6 changes: 3 additions & 3 deletions docs/en/contributing/code-guidelines.md
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ class TestProjectCreation:
def test_create_project_with_valid_name(self, tmp_path):
"""Test project creation with valid project name."""
project_name = "test-project"
result = create_project(project_name, template="minimal", output=tmp_path)
result = create_project(project_name, template="fastapi-hello", output=tmp_path)

assert result.success is True
assert (tmp_path / project_name).exists()
Expand All @@ -364,7 +364,7 @@ class TestProjectCreation:
def test_create_project_with_invalid_name(self):
"""Test project creation fails with invalid name."""
with pytest.raises(ValueError, match="Invalid project name"):
create_project("invalid-project-name!", template="minimal")
create_project("invalid-project-name!", template="fastapi-hello")

def test_create_project_overwrites_existing(self, tmp_path):
"""Test project creation overwrites existing directory when forced."""
Expand All @@ -374,7 +374,7 @@ class TestProjectCreation:

result = create_project(
project_name,
template="minimal",
template="fastapi-hello",
output=tmp_path,
overwrite=True
)
Expand Down
Loading
Loading