- Status: Accepted
- Date: 2026-08-30
- Deciders: Lily Protocol Core Team
- Related Issue: #47
Lily Frontend is a contributor-first foundation where product UI is introduced through scoped issues rather than prebuilt screens. The repository needs an architecture that:
- Keeps route files in
src/appthin and declarative. - Centralizes route metadata (path, section, purpose, Figma scope) in a single source of truth.
- Allows contributors to implement one issue-sized slice at a time from approved Figma designs without restructuring routing.
- Avoids duplication of layout, metadata, and scaffold logic across dozens of pages.
Without a documented decision, contributors risk adding ad-hoc logic directly into route files, fragmenting the scaffold contract and making future refactors expensive.
We adopt a centralized route scaffold architecture:
- All route metadata lives in
src/config/routes.ts(routeScaffoldsarray andsectionDefinitions). - Route files in
src/appremain thin wrappers that callcreateScaffoldPage(routeId)fromsrc/features/scaffold/page-factory.tsx. - Shared layout primitives live in
src/components/scaffold/page-scaffold.tsxand consume theRouteScaffoldtype. - Implementation work is scoped via Figma references stored in each scaffold entry (
figmaScope,implementationAreas). - New routes are added by extending
routes.tsand creating a minimal page file that delegates to the factory.
This makes the route registry the authoritative map of the site, keeps pages declarative, and ensures every screen inherits consistent structure, metadata, and contribution workflow.
Each page.tsx would export its own config object alongside the component.
- Pros: No separate registry; changes stay local.
- Cons: No single source of truth for navigation, sitemaps, or section grouping; duplicated layout logic; harder to enforce consistency across 30+ routes.
- Rejected because: It undermines the contributor-friendly scaffold contract and creates drift between route definitions and shared layouts.
Rely entirely on Next.js App Router conventions and infer sections from folder names.
- Pros: Zero configuration; idiomatic Next.js.
- Cons: Cannot express purpose, Figma scope, or implementation areas without inventing custom file conventions; section metadata becomes implicit and fragile; sitemap and navigation generation require scanning and guessing.
- Rejected because: Lily needs explicit, typed route metadata to coordinate Figma-driven contributions and maintain operational surfaces (docs, status, legal) alongside product screens.
Store route configs in MDX frontmatter or JSON files and generate pages at build time.
- Pros: Non-developers could edit route metadata; separation of content and code.
- Cons: Adds a codegen step; loses TypeScript safety for route IDs and section keys; complicates the contributor workflow for a repo that already targets developer contributors; over-engineered for the current scope.
- Rejected because: The current contributor base is developer-focused, and TypeScript-native config provides better safety and IDE support without extra tooling.
- Single source of truth for all routes, sections, and Figma scopes.
- Thin route files reduce merge conflicts and make PRs easier to review.
- Contributors can pick up issue-sized slices without understanding full routing internals.
- Navigation, sitemap, and section grouping derive from typed data, reducing bugs.
- Architecture is enforceable via linting and type checks.
- Adding a new route requires touching both
routes.tsand creating a page file (two-file change). - Contributors must learn the scaffold contract before implementing screens.
- Refactoring the scaffold shape requires coordinated updates across config, factory, and components.
- Risk: Contributors bypass the factory and add custom logic directly in route files.
- Mitigation: Document this ADR in README; add lint rule or PR template checklist item requiring
createScaffoldPageusage.
- Mitigation: Document this ADR in README; add lint rule or PR template checklist item requiring
- Risk:
routes.tsgrows unwieldy as routes multiply.- Mitigation: Group scaffolds by section; consider splitting into per-section modules if it exceeds ~200 lines.
- Risk: Figma links become stale.
- Mitigation: Treat
figmaScopeas living documentation; update during implementation PRs; link to specific Figma nodes rather than entire files.
- Mitigation: Treat
All existing routes in src/app already follow this pattern via createScaffoldPage. Future contributions must:
- Add or update an entry in
src/config/routes.ts. - Create a thin page file using
createScaffoldPage(routeId). - Reference this ADR in PR descriptions when modifying route structure.
src/config/routes.ts— Route registry and section definitionssrc/features/scaffold/page-factory.tsx— Factory function for scaffold pagessrc/components/scaffold/page-scaffold.tsx— Shared layout primitive- Figma — Lily Protocol — Design source for implementation scopes