Skip to content

Phase 5: Simple mode entity templates#8

Merged
manavgup merged 1 commit into
mainfrom
phase-5/entity-templates
Mar 30, 2026
Merged

Phase 5: Simple mode entity templates#8
manavgup merged 1 commit into
mainfrom
phase-5/entity-templates

Conversation

@manavgup
Copy link
Copy Markdown
Owner

Summary

9 Jinja2 entity templates that generate per-entity code:

  • model.py.j2 — SQLAlchemy model with enums, FKs, relationships, 13 field types, TYPE_CHECKING imports
  • schema.py.j2 — Pydantic v2 Create/Update/Response/DetailResponse with nested relationships
  • repository.py.j2 — extends SqlAlchemyRepository, conditional search method
  • service.py.j2 — extends CrudService with lifecycle hook stubs
  • router.py.j2 — FastAPI CRUD with query param filtering and search
  • factory.py.j2 — polyfactory ModelFactory
  • fake_repository.py.j2 — in-memory Protocol implementation for testing
  • test_unit_service.py.j2 — service tests using fakes
  • test_integration.py.j2 — API endpoint test stubs

Test coverage

56 new tests (337 total) — every template renders valid Python for 4 entity types (User, Post, Category, minimal Tag)

How to test

make check     # 337 tests pass

Part of

Phase 5 in #1 — After this merges, Phase 6 (CLI commands) is the final phase.

🤖 Generated with Claude Code

9 Jinja2 templates that generate per-entity code:

- model.py.j2 — SQLAlchemy model with enums, FKs, relationships,
  TYPE_CHECKING imports, all 13 field types
- schema.py.j2 — Pydantic v2 Create/Update/Response/DetailResponse
  with nested relationships and audit fields
- repository.py.j2 — extends SqlAlchemyRepository, optional search()
- service.py.j2 — extends CrudService with lifecycle hook stubs
- router.py.j2 — FastAPI CRUD endpoints with query param filtering
- factory.py.j2 — polyfactory ModelFactory
- fake_repository.py.j2 — in-memory dict-based Protocol implementation
- test_unit_service.py.j2 — service tests with fake repository
- test_integration.py.j2 — API endpoint test stubs

56 new tests (337 total) verifying:
- All 9 templates render valid Python for User/Post/Category/Tag entities
- Cross-template consistency (names, imports, classes)
- Model: tablename, base class, enums, FKs, relationships
- Schema: four classes, required fields, response ID
- Repository: inherits SqlAlchemyRepository, conditional search
- All templates handle minimal entities (single field) cleanly

Part of Phase 5 in #1

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@manavgup manavgup merged commit 386027e into main Mar 30, 2026
4 checks passed
@manavgup manavgup deleted the phase-5/entity-templates branch March 30, 2026 21:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant