Skip to content

[FEAT, TEMPLATE, DOCS] v2.0.0 stage 4: next steps, feature guide, SQL-backed items - #97

Merged
bnbong merged 1 commit into
devfrom
feat/v2.0.0
Dec 3, 2026
Merged

bnbong merged 1 commit into
devfrom
feat/v2.0.0

Conversation

@bnbong

@bnbong bnbong commented Dec 3, 2026 •

Copy link
Copy Markdown
Owner

Requesting Merging

Description

Fourth staged PR for v2.0.0: what the user gets right after generation.

  • fastkit init and fastkit startdemo end with a Next steps panel that is true for the run (package manager, --no-venv, --no-install, --in-place, database, migrations). The generated README carries the same list for a fresh checkout.
  • A project generated from a feature selection gets one README section per selected feature.
  • Level templates and feature code carry short comments that link the FastAPI docs page for the concept they show.
  • At layered, domain and production, the example /items API is stored in the selected SQL database.

The list and the sections are built as data in the generation layer, so the web generator in the next stage renders the same content.

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: 5595 passed, 33 skipped (about 4.5 minutes; about 8 before this PR)
  • Full suite with EncodingWarning from fastapi_fastkit as errors: 5595 passed, 33 skipped
  • C locale (LC_ALL=C, PYTHONUTF8=0), -m "not extended": 5499 passed, 33 skipped
  • Simulated Windows (POSIX-only os / signal attributes removed): 5587 passed, 41 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%
  • Generated projects installed in scratch virtual environments: layered, domain and production with PostgreSQL, MySQL and SQLite, with and without Alembic, plus domain with MongoDB and three single-file selections. Their own tests, ruff check, ruff format --check, black, isort and mypy src pass.
  • /openapi.json compared before and after: unchanged for layered + SQLite, domain, domain + PostgreSQL and production; for single-file with features only the /health operation id and summary change.
  • Real Docker Compose runs (Compose v2.18.1), items CRUD over HTTP and data kept across down / up:
    • production defaults (PostgreSQL, Alembic, JWT): migrate exits 0, then register, token and /users/me
    • domain + MySQL 8.4 + Alembic, with the default caching_sha2_password authentication
    • domain + SQLite + Alembic (database file in a volume)
    • domain + PostgreSQL + JWT without Alembic (tables created at startup)
    • layered + PostgreSQL + Alembic + Celery, and layered + PostgreSQL without Alembic
    • The PostgreSQL runs were repeated with a localhost DATABASE_URL in .env.
  • The 1.x config fixtures generate the same files as before except for the changes listed under Etc.

Not verified: MySQL and MongoDB under Docker Compose after the service URL change (checked with docker compose config; the MySQL run above was before it), real Windows.

Major Changes

After generation

  • Next steps panel after init and startdemo, replacing the single "run fastkit runserver" line. It leaves out steps the run already did and adds the ones it skipped.
  • README: the same steps for a fresh checkout, with native commands (uv run uvicorn ...), between <!-- fastkit:next-steps:start --> and <!-- fastkit:next-steps:end -->. Generating again into the same folder replaces only that block.
  • README feature sections: one per selected feature, with what it adds, its files, its .env settings and a link. Level templates used as they are, and --template projects, get the steps only.
  • All of this text lives in the option catalog.

Concept comments

  • Two lines at the place a concept first appears: one sentence and a FastAPI docs URL. Each concept appears once per project (hello 8, single-file 4, layered 12, domain 12, production 19). Code added by addroute has none.

SQL-backed /items

  • layered, domain and production with PostgreSQL, MySQL or SQLite: async SQLAlchemy model and data access in the level's own layout; tests run on in-memory SQLite. With Alembic the initial revision creates the table, otherwise it is created at startup.
  • At layered the JSON-file store, its mock data and its tests are not generated for such a project; routes, schemas and responses stay the same.
  • MongoDB and Redis keep the existing stores, and the README says so.
  • addroute in such a project still adds an in-memory resource and prints a note pointing at the SQL-backed example.

single-file

  • Features are wired into the template's src/main.py; no preset regenerates main.py any more. The settings move to src/core/config.py only when a generated module reads them.
  • An in-place run stops before writing anything when src/core/config.py exists and does not define settings.

Dependencies, Docker, config

  • Projects generated from a feature selection keep the template's minimum versions (for example fastapi>=0.141.1); a version the user pins wins.
  • PostgreSQL and MySQL projects always get aiosqlite as a dev dependency. MySQL projects install aiomysql[rsa].
  • docker-compose with Alembic: a one-shot migrate service runs alembic upgrade head before the app and worker start. With SQLite the database file is kept in a volume.
  • docker-compose service URLs (DATABASE_URL, MONGODB_URL) are set in the compose file and no longer taken from .env, so a localhost URL written there for running on the host does not reach the containers.
  • The app, migrate and worker services share one image, built once.
  • A config file's version (PEP 440) sets [project].version of the generated project.

Tests and docs

  • Tests that do not test installation no longer create real virtual environments.
  • CHANGELOG and English docs updated with real output. In the translated index.md pages only the sample output changed.

Screenshots (optional)

N/A

Etc

  • Changes to what 1.x configs generate: runtime dependencies keep the template's minimum versions; single-module and minimal projects keep the template's src/main.py and tests/test_main.py, and their database module moves from src/config/database.py to src/core/database.py; classic-layered with a SQL database gets src/models/items.py and no src/mocks/; domain-starter with PostgreSQL no longer gets src/app/db/.
  • Upgrade notes: for single-file projects with features, the /health operation id changes from health_check_health_get to health_health_get. A DATABASE_URL in .env or the shell no longer overrides the URL the containers use.
  • With the shared image, docker compose run migrate on a checkout that has not been built yet does not find the image; docker compose up --build builds it.
  • Known, not in this PR: addroute does not generate SQL-backed resources; an in-place run over an existing layered project that switches it to a SQL database leaves the old tests/test_item_store.py behind; the tests that need FastAPI installed are skipped in CI, because the dev dependency group does not include it.

@bnbong bnbong self-assigned this Dec 3, 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 3, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Dec 3, 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-03T04:11:51.888152Z 94a81ca 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 3, 2026

Copy link
Copy Markdown
Contributor

✅ Template Inspection Passed

All changed templates have been validated successfully.


Last updated: 2026-12-03T04:09:46.009Z

@codecov

codecov Bot commented Dec 3, 2026

Copy link
Copy Markdown

@bnbong
bnbong merged commit 275d113 into dev Dec 3, 2026
10 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