Skip to content

[FEAT, TEMPLATE, DOCS] v2.0.0 stage 3: unified fastkit init with levels - #96

Merged
bnbong merged 2 commits into
devfrom
feat/v2.0.0
Dec 2, 2026
Merged

bnbong merged 2 commits into
devfrom
feat/v2.0.0

Conversation

@bnbong

@bnbong bnbong commented Dec 2, 2026

Copy link
Copy Markdown
Owner

Requesting Merging

Description

Third staged PR for v2.0.0. fastkit init becomes the single way to create a project:

fastkit init
Project name -> Level (hello, single-file, layered, domain, production)
-> Database (levels after hello) -> Customise features? -> summary -> confirm

fastkit init --template <name> copies a bundled template, startdemo stays as an alias, and without a terminal nothing is asked. The stack question (minimal / standard / full) and the fastapi-empty template are removed. The level-to-project mapping lives in the generation layer, so the web generator in a later stage uses the same code.

Type of Change

  • BUG FIX
  • ADDING NEW TEMPLATE
  • FEATURE ADDED/UPDATED
  • HOTFIX
  • DELETING UNNECESSARY FEATURES
  • DOCUMENTATION & DEVOPS
  • Etc..

Test Environment

  • macOS (Apple Silicon), Python 3.12
  • Full suite: 4405 passed, 61 skipped
  • Full suite with EncodingWarning from fastapi_fastkit as errors: 4405 passed, 61 skipped
  • C locale (LC_ALL=C, PYTHONUTF8=0), -m "not extended": 4309 passed, 61 skipped
  • Simulated Windows (POSIX-only os / signal attributes removed): 4397 passed, 69 skipped
  • black 26.10.1, isort 9.0.1, mypy 2.3.1: clean; every pre-commit hook passes
  • mkdocs build --strict: passes
  • Diff coverage against dev: 99%
  • Four real sessions recorded in a pseudo-terminal: default hello, customised production, --template fastapi-sqlmodel, fully non-interactive
  • Eight config files written by v1.5.2's own code generate the same projects as before (three that named minimal now generate fastapi-single-module, as intended)
  • All nine templates and six feature combinations generated and installed: their tests, ruff check, ruff format --check, black, isort, mypy src and shipped lint scripts pass; /openapi.json is byte-identical before and after for all fifteen
  • Two projects generated by v1.5.2 (fastapi-empty, minimal preset) still work with doctor, addroute and runserver

Not verified on real Windows. Docker images of three templates were built but not run.

Major Changes

fastkit init

  • Guided by default. Levels: hello (one main.py), single-file, layered, domain, production (domain plus PostgreSQL, Alembic, JWT, coverage, structured logs, ruff, CI, Docker). Default level is hello.
  • A level chosen without a database or feature changes is the level's template as it is; anything else, and production always, is generated from the feature selection. In the customise step every default equals what "No" would have produced.
  • New options: --level, --database, --feature AXIS=VALUE (repeatable), --extra-package, --template, --in-place, --name (alias of --project-name). No existing option is renamed.
  • Without a terminal init never prompts: it uses options and defaults and exits 1 naming the option it needs. Every question gives up after 10 invalid answers or when input ends.
  • Author and email default to git config; the package manager defaults to uv when installed, otherwise pip.
  • --save-config works for every run except --dry-run, which writes nothing. project_name is the only required config key; --project-name, --author, --author-email and --description override a config file's values.
  • --interactive is accepted and does nothing. -y uses the defaults without asking.

Removed

  • The stack question and the fastapi-empty template. The minimal preset is an alias of single-module. Saved 1.x configs and projects generated by 1.x keep working.

startdemo

  • Unchanged behaviour; prints a one-line note pointing to fastkit init --template.

Templates

  • Every template except fastapi-hello ships the ruff configuration that init's ruff option writes, and passes it.
  • Every template ships requirements-dev.txt; requirements.txt lists runtime packages only.
  • fastapi-single-module projects pass isort and mypy src; fastapi-custom-response uses the Python 3.12 type parameter syntax, and addroute recognises both the old and the new form.
  • An empty author is left out of pyproject.toml for every package manager (it broke builds).

Tooling

  • black 26.10.1, isort 9.0.1, mypy 2.3.1 and ruff 0.17.6 are pinned identically in the pre-commit hooks, pdm.lock and uv.lock; a test fails when they drift. After pulling, run pdm sync -G dev --clean (or uv sync --extra dev).
  • cli.py is split: init and startdemo live in fastapi_fastkit/commands/.

Docs

  • CHANGELOG, README and English docs describe the level flow, the new options and init --template. Translations are not re-synced; reference/translation-status lists the pages.

Screenshots (optional)

N/A

Etc

  • Known, planned for the next stage: single-file with a database becomes a multi-module project; projects generated from a feature selection list unpinned base dependencies while templates keep version floors.

@bnbong bnbong self-assigned this Dec 2, 2026
@bnbong bnbong added bug Something isn't working documentation Improvements or additions to documentation enhancement New feature or request template Add or editing a FastAPI template fix Fix or improve source codes labels Dec 2, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Dec 2, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-12-02T11:36:54.809102Z 483ea4e PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions

github-actions Bot commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

✅ Template Inspection Passed

All changed templates have been validated successfully.


Last updated: 2026-12-02T13:19:44.398Z

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 483ea4e778

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/fastapi_fastkit/commands/common.py Outdated
Comment on lines +217 to +221
errors = validate_project_config(config)
if errors:
for error in errors:
print_error(f"Invalid project config '{path}': {error}")
return None

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Apply level defaults before validating config combinations

A config such as {"project_name":"demo","level":"production","authentication":"FastAPI-Users"} is rejected here because validate_project_config checks feature combinations against the raw file, treating the omitted database as None. Production actually bundles PostgreSQL, and choice_from_config correctly accepts this same configuration after applying the level defaults, but the CLI exits before reaching it. Validate combinations on the effective level selection so valid partial production configs can be used with init --config.

Useful? React with 👍 / 👎.

Comment thread src/fastapi_fastkit/commands/init.py Outdated
Comment on lines +664 to +666
# Refuse unusable level flags before anything is asked.
if level is not None:
check(flag_choice(level))

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Defer database-dependent checks until after the database prompt

In a terminal, init --level domain --feature authentication=FastAPI-Users --project-name demo exits here with a SQL-database requirement error instead of asking for the missing database. check validates the complete specification while database is still unset, even though the database question runs later in the guided flow. The same premature rejection occurs without an explicit level through the first-preset check. Keep early validation of individual flag values, but defer combination checks involving unanswered choices until the user has supplied them.

Useful? React with 👍 / 👎.

@codecov

codecov Bot commented Dec 2, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 98.86271% with 14 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/fastapi_fastkit/commands/init.py 97.94% 7 Missing ⚠️
src/fastapi_fastkit/commands/common.py 95.50% 4 Missing ⚠️
src/fastapi_fastkit/backend/interactive/guided.py 98.40% 2 Missing ⚠️
src/fastapi_fastkit/commands/startdemo.py 98.50% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

…abase before rule checks

- init --config: a 2.0 config's feature combinations are checked after the
  level's defaults apply, so production with FastAPI-Users and no database
  key is accepted
- init in a terminal: a rule that a database answer can satisfy no longer
  stops the run before the database question; an answer that does not
  satisfy it is refused with the reason and asked again
- tests: read the summary table and wrapped messages in any box style
  (legacy Windows console), skip the responses test without pydantic

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@bnbong
bnbong merged commit 09ebcc0 into dev Dec 2, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working documentation Improvements or additions to documentation enhancement New feature or request fix Fix or improve source codes template Add or editing a FastAPI template

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant