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
176 changes: 73 additions & 103 deletions CHANGELOG.md

Large diffs are not rendered by default.

55 changes: 37 additions & 18 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,29 @@ This document will also be a good indicator for you to gain insight into the dir
FastAPI-fastkit uses following stacks:

- Python 3.12+
- click 8.1.7+
- click 8.2.0+
- rich 13.9.2+
- Jinja2 3.1+
- pre-commit
- pytest for testing
- black for code formatting
- isort for import sorting
- mypy for static type checking

### Current Source Structure (Version 1.X.X+)
### Current Source Structure (Version 2.X.X+)

![fastkit diagram](docs/img/fastkit_diagram.png)
```
src/fastapi_fastkit/
├── cli.py # `fastkit` command group and the smaller commands
├── commands/ # init and startdemo
├── backend/ # interactive prompts, package managers, addroute, doctor, inspection
├── catalog/ # catalog.toml (levels, features, templates) and i18n overlays
├── generation/ # prompt-free generate() used by the CLI and the web generator
├── core/ # settings and exceptions
├── utils/ # file I/O, platform and output helpers
├── fragments/ # Jinja2 fragments for init features
└── fastapi_project_template/ # bundled templates; modules/ holds the files addroute writes
```

### Quick Setup with Makefile

Expand All @@ -55,7 +67,8 @@ This single command will:
- Install the package in development mode with all dev dependencies
- Install documentation dependencies
- Set up pre-commit hooks
- Create a ready-to-use development environment

The tests that start generated applications also need the `test-runtime` dependency group; without it they are skipped. Install it with `pip install --group test-runtime` (pip 25.1 or later). [Development setup](docs/en/contributing/development-setup.md) shows the same setup with pdm or uv.

### Manual Setup (Alternative)

Expand Down Expand Up @@ -234,6 +247,8 @@ When adding a new FastAPI template project, follow these guidelines:

1. Directory Structure:

A template needs at least `README.md-tpl`, `pyproject.toml-tpl` (with `fastapi` in `[project].dependencies`), a `main.py-tpl` that creates the `FastAPI` application (at the template root, in `src/` or in `src/app/`) and a `tests/` folder with a `test_*.py-tpl` module. Most templates also ship the files below (`fastapi-hello` deliberately ships only `main.py-tpl`, its tests, the requirements files, `README.md-tpl` and `.gitignore-tpl`):

```
template-name/
├── src/
Expand All @@ -256,7 +271,7 @@ template-name/

2. File Extensions:
- All Python source files must use `.py-tpl` extension
- Template files must include proper configuration files (`.env.example-tpl`, `.gitignore-tpl`, `.gitattributes-tpl`, etc.), never `.env-tpl` (fastkit generates `.env`)
- A template that reads settings ships `.env.example-tpl` (and `.gitattributes-tpl`), never `.env-tpl` (fastkit generates `.env`)
- `.gitignore-tpl` must ignore `.env` and `.env.*` and keep `!.env.example`

3. Dependencies:
Expand All @@ -269,18 +284,21 @@ template-name/
- `core/pagination.py-tpl` and `core/responses.py-tpl` identical to `fastapi_project_template/modules/core/`
- Every `ENVIRONMENT` except `development` (`staging`, `production`) refuses a missing, example, or shorter than 32-byte `SECRET_KEY`

5. Catalog registration:
- Add a `[[templates]]` entry to `src/fastapi_fastkit/catalog/catalog.toml` and its translations to every `catalog/i18n/<lang>.toml` overlay (see the Template Creation Guide)

See [Template Creation Guide](docs/en/contributing/template-creation-guide.md) for the full rules and the conventions checklist.

### Security Requirements

1. Implementation Requirements:
1. Implementation Requirements (for templates with settings, that is every template except `fastapi-hello`):
- Environment variables management (`.env.example` committed, `.env` git-ignored)
- Basic authentication system
- CORS configuration
- Authentication where the template's purpose needs it
- CORS origins only from `BACKEND_CORS_ORIGINS`, with credentials off for `*`
- Exception handling and logging

2. Security Checks:
- All template code must pass `inspector.py` validation
- The template must pass the template inspection: `make inspect-template TEMPLATES="your-template-name"`
- Include security middleware configurations
- Follow security guidelines in SECURITY.md

Expand Down Expand Up @@ -320,12 +338,12 @@ Additionally, a **Weekly Template Inspection** runs every Wednesday to validate
- ⚡ No manual test file creation needed
- 🛡️ Consistent quality standards applied

**Comprehensive Test Coverage:**
- ✅ **Project Creation**: Template copying and metadata injection
- ✅ **Package Manager Support**: UV, PDM, Poetry, and PIP compatibility
- ✅ **Virtual Environment**: Creation and dependency installation
- ✅ **Project Structure**: File and directory validation
- ✅ **FastAPI Integration**: Project identification and functionality
**What the tests check:**
- ✅ **Project Creation**: Every template is generated with `--no-venv`; metadata is injected and no placeholder is left
- ✅ **Project Structure**: `README.md-tpl` and `pyproject.toml-tpl` exist, no `setup.py-tpl`, and the expected files and folders are generated
- ✅ **Project Identification**: The generated project is recognised as a fastkit project

These tests do not create a virtual environment or install anything. The template inspection (`make inspect-template`) installs the dependencies and runs the template's own tests.

**Test Execution:**
```bash
Expand Down Expand Up @@ -392,11 +410,12 @@ $ fastkit startdemo your-template-name --package-manager pip
```bash
make dev-check # Must pass all checks
```
- [ ] All files use .py-tpl extension
- [ ] FastAPI-fastkit dependency included
- [ ] All Python files use the `.py-tpl` extension
- [ ] No FastAPI-fastkit dependency
- [ ] Template registered in `catalog.toml` and the `i18n/<lang>.toml` overlays
- [ ] Security requirements met
- [ ] Documentation complete
- [ ] inspector.py validation passes
- [ ] `make inspect-template TEMPLATES="your-template-name"` passes
- [ ] All make dev-check tests pass
- [ ] **Automatic template tests pass** (new templates tested automatically)
- [ ] **Package manager compatibility verified** (tested with UV, PDM, Poetry, PIP)
Expand Down
Loading
Loading