Skip to content

[FEAT] Support architecture presets in dynamic project generation#55

Merged
bnbong merged 2 commits intomainfrom
dev
May 2, 2026
Merged

[FEAT] Support architecture presets in dynamic project generation#55
bnbong merged 2 commits intomainfrom
dev

Conversation

@bnbong
Copy link
Copy Markdown
Owner

@bnbong bnbong commented May 2, 2026

Requesting Merging

Description

Part of #41
Closes #45

This PR connects the architecture preset selected in fastkit init --interactive to the actual project generation flow.

Instead of always deploying the same base scaffold, interactive init now chooses a preset-specific template, writes generated config files into preset-appropriate paths, preserves richer template main.py files when needed, and surfaces compatibility warnings for feature combinations that still require manual wiring.

Type of Change

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

Test Environment

  • Local macOS (Apple Silicon / M1), zsh
  • Python via uv
  • Verified commands:
    • uv run pytest tests/test_backends/test_preset_layout.py tests/test_cli_operations/test_cli_interactive_integration.py -q
      • Result: 32 passed
    • uv run mkdocs build
      • Result: Documentation built in 14.87 seconds

Major Changes

  • Added preset-aware generation strategy

    • Introduced PresetLayoutStrategist and PresetProfile
    • Centralized preset-specific decisions for:
      • base template selection
      • main.py regeneration vs preservation
      • database config output path
      • auth config output path
      • compatibility warnings for preserve-main presets
  • Connected interactive init to architecture presets

    • fastkit init --interactive now uses the selected preset to choose the base template instead of always deploying fastapi-empty
    • Unknown or missing preset ids safely fall back to minimal to preserve backward compatibility
  • Implemented preset-specific layout behavior

    • minimal -> fastapi-empty
    • single-module -> fastapi-single-module
    • classic-layered -> fastapi-default
    • domain-starter -> fastapi-domain-starter
  • Added selective main.py overlay behavior

    • minimal and single-module regenerate main.py from selected features
    • classic-layered and domain-starter preserve the template-shipped main.py
    • This avoids clobbering router-aware template entrypoints for richer presets
  • Added preset-specific config file targets

    • Database and auth config files are now written into locations that match each preset’s structure
    • Examples:
      • minimal / single-module: src/config/...
      • classic-layered: src/core/...
      • domain-starter: src/app/core/...
  • Added compatibility warnings for preserve-main presets

    • The CLI now warns when selected features depend on dynamic main.py wiring that is intentionally skipped for preserved-main presets
    • Current warning targets include:
      • Rate-Limiting
      • Prometheus
    • CORS is documented separately as already wired in shipped templates and activated via .env configuration
  • Added reference documentation for the supported matrix

    • New docs page: docs/en/reference/preset-feature-matrix.md
    • Documents:
      • preset -> base template mapping
      • generated file locations
      • supported feature behavior per preset
      • manual wiring expectations for preserve-main presets
    • Added the page to MkDocs navigation
    • Linked it from the interactive-mode FAQ
  • Added regression coverage

    • New strategist unit tests for:
      • supported preset ids
      • base template mapping
      • regeneration policy
      • output paths
      • compatibility warnings
    • Expanded CLI interactive integration tests for:
      • per-preset layout generation
      • database config placement
      • preserved vs regenerated main.py
      • compatibility warning behavior

Screenshots (optional)

N/A

Etc

@bnbong bnbong added this to the v1.3.0 milestone May 2, 2026
@bnbong bnbong self-assigned this May 2, 2026
@bnbong bnbong added documentation Improvements or additions to documentation enhancement New feature or request template Add or editing a FastAPI template python Pull requests that update python code labels May 2, 2026
@bnbong
Copy link
Copy Markdown
Owner Author

bnbong commented May 2, 2026

@codex review

@codecov
Copy link
Copy Markdown

codecov Bot commented May 2, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Copy link
Copy Markdown

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

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: b48b4db24e

ℹ️ 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".


preset_id = config.get("architecture_preset")
strategist = PresetLayoutStrategist(preset_id)
template = strategist.base_template
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Derive Docker entrypoint from preset main module

Now that interactive init can select domain-starter as the base template, this line allows projects whose app entrypoint is src/app/main.py; however Docker generation still hardcodes src.main:app in DynamicConfigGenerator._generate_dockerfile. When users choose Docker deployment with domain-starter, the generated container fails to start because src.main does not exist. Please thread the preset-aware module path into Docker file generation (or derive it from the strategist) so the CMD matches the selected layout.

Useful? React with 👍 / 👎.

@bnbong bnbong merged commit 01ae6d5 into main May 2, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation enhancement New feature or request python Pull requests that update python code template Add or editing a FastAPI template

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE] Support architecture presets in dynamic project generation

1 participant