ADR 0002: The software template's layout¶
Context¶
The software template generates an application. It is built from
components chosen at generation: backend_django today, and later
frontend_nextjs, proxy_caddy, gateway_litellm and others. Component
boundaries let a project select only the stacks it runs while the root keeps
their shared build, composition and continuous-integration surface. The
backend uses the feature-oriented API layout recorded below.
Decision¶
- One repository, one folder per component. The backend is
backend/, and the frontend will befrontend/. Root files hold what the components share:compose.yaml, theMakefileand CI. - The Python project sits at the root, with its code in
backend/. So the shared toolchain,.dev-config/andmake/python.mk, work unchanged. Each shared config branches onbackend_djangoonly for paths and plugins, and the other templates render byte for byte as before. - Validation runs before rendering. A pre-generation hook refuses a project with no component, so no half-rendered project is left behind.
- A custom user model from the first migration. Django's documentation recommends one for every new project, because switching after the first migration means rewriting every table that points at users.
- A worked example app (
notes) shows the whole layout, with tests for every layer. The drift test and the guard tests are generic, so they keep working afternotesis deleted. - Postgres 18. A new project has no existing database compatibility constraint, and the version policy is "always the latest", so the template uses 18 with pgvector 0.8.7.
Consequences¶
make cineeds Docker: tests run on a real Postgres, and the smoke test builds and serves the production image.- django-stubs-ext is a runtime dependency, because
ModelAdmin[Note]must be subscriptable at runtime for the strict type check. - These declare support only up to Django 6.0 or Python 3.13 on PyPI:
drf-spectacular, pytest-django, whitenoise and gunicorn. All of them pass
the generated project's
make ciand smoke test on Python 3.14 with Django 6.1. - The frontend component (ADR 0003) adds
frontend/besidebackend/. Its checks joinmake cithe same waymake/django.mkjoins today.