Template Conventions
The heart of the scaffold is the templates/ directory: the files inside it are exactly what users end up with. Modifying a template is the same as modifying a generated project.
Each Stack Keeps Its Own Conventions
Section titled “Each Stack Keeps Its Own Conventions”The directory organization of different stacks is deliberately not unified, and instead follows each language’s community conventions:
| Template | Organization |
|---|---|
backend-python/ |
Domain-modular: app/core/ (infrastructure) + one package per business domain (auth/, user/, role/, permission/, menu/, …), each containing models.py / schemas.py / service.py / router.py; schema changes go through migrations/ (Alembic) |
backend-java/ |
Layered: controller/, service/, repository/, entity/, dto/, with infrastructure split by responsibility across common/, config/, catalog/, bootstrap/, web/, data/, security/; schema changes go through db/migration/ (Flyway) |
frontend-react/ and frontend-vue/ |
Feature-based: pages under pages/settings/<Domain>/, APIs split by domain under api/, types split by domain under types/ |
frontend-svelte/ |
SvelteKit file routing + src/lib/: pages under src/routes/(app)/settings/<domain>/, APIs/types under src/lib/api and src/lib/types |
Contract First
Section titled “Contract First”docs/contract/api.md is the API contract both backends follow, pinned by two executable test suites:
- Python:
templates/backend-python/tests/test_contract.py - Java:
templates/backend-java/src/test/java/com/hmilyld/fullstack/ContractTest.java
Change the contract first, then both implementations and both test suites. A drift on either side fails its tests.
Backend Implementation Conventions
Section titled “Backend Implementation Conventions”The structures are deliberately un-unified, but the quality bar is the same:
| Convention | Python | Java |
|---|---|---|
| Failure | Raise domain exceptions (AppException subclasses) |
Raise domain exceptions (AppException subclasses) |
| Transactions | get_db commits on return, rolls back on error |
@Transactional rolls back on error |
| Response types | Pydantic schemas + model_dump() |
dto/*Response records |
| Pagination out of range | Clamped | Clamped |
| Schema changes | Alembic migrations | Flyway migrations |
| Role-name checks | Only admin (all permissions) and admin-account protection, one place each |
Same |
Naming and Copy
Section titled “Naming and Copy”- Frontend and backend UI copy uniformly uses Chinese.
- API responses are fixed as
{ code: 0, message: "success", data }, withcode: -1for errors. - TS/JS variables use
camelCase, and components usePascalCase. - Python Pydantic schema fields use
camelCase(such asroleId), and ORM fields usesnake_case(such asrole_id).
Shared Infrastructure
Section titled “Shared Infrastructure”- Python’s
ApiResponse/PaginatedDatalive inapp/core/schemas.py. - The permission code catalog is the single source of truth: Python
app/catalogs/permissions.py, Javacatalog/PermissionCatalog.java. The two must stay identical;npm run sync:permissions:checkfails on drift, and the tables inreference/permissions.mdare generated by the same script — do not edit them by hand. Migrations no longer contain permission seed rows. - Menu presentation is separate from authorization:
permissionshandles authorization, whilemenu_groups/menu_itemsown groups, routes, icons, order, and visibility (hidden). - Menu permissions must be created through Menu & Permissions; built-in items cannot be deleted, and deleting a custom item cascades to its operation permissions and role grants.
- Export archives use
manifest.json + schema.sql + checksums.sha256 + data/*.jsonl, support only same-backend/same-version restore, and excludeapp_state. - The frontend HTTP layer is a lightweight fetch wrapper (
api/client.tsoverapi/http.ts); do not introduce axios. - The fetch wrapper must support binary downloads,
FormDatauploads, and custom status headers instead of assuming every response is JSON. - API docs URLs are identical in both stacks:
/docs(Swagger UI) and/openapi.json(OpenAPI description). Python serves them via FastAPI, Java via SpringDoc.