First feature
Add a durable product capability from schema to UI without bypassing the architecture.
Use a new domain for durable product behavior. A feature is complete only when its data ownership, tenancy rules, validation, server policy, browser states, and verification all agree.
A maintained path
Define the behavior
Specify the owner (organization_id for product data, user_id only for personal account
data), lifecycle states, limits, and failure cases before choosing files or UI.
Make persistence explicit
Create a new dbmate-format SQL migration (bun run --cwd apps/server db:new <name>) and define
shared Zod v4 request/response schemas in packages/contracts.
Build the vertical slice
Create routes.ts, service.ts, and repository.ts under apps/server/src/domains/<domain>/,
mount sessionAuth and organizationContext, then add the typed web service and module under
apps/web/src/modules/<domain>/.
Prove it works
Cover authorization, cross-organization denial, validation, durable SQL behavior, and UI states,
then run bun run check, vp run -r typecheck, bun run test, and bun run knip.
Reference guides
Architecture and boundaries
Routes, services, repositories, organizations, and shared Zod contracts.
State machines
Persisted lifecycles, legal transitions, and SQL guards.
Authentication
Use Better Auth session identity and organization ownership correctly.
Worked feature recipe
Follow one bounded personal-domain walkthrough from schema to browser proof.
Customize safely
Replace neutral product choices without losing boundaries.
Web UI patterns
Compose accessible product screens from packages/ui primitives.
Do not skip the boundaries
Do not place product SQL in routes, read organization_id or user_id from untrusted request
input, use client state as the authorization source, or gate paid access solely in the browser.
These shortcuts are fast only until the first tenancy, billing, or data-loss edge case appears.
Copy a shipped vertical slice
Read apps/server/src/domains/files/ and apps/web/src/modules/files/ for a shipped
organization_id-scoped slice (or apps/server/src/domains/notifications/ for a user_id-scoped
personal slice) alongside AGENTS.md. Verify every change with bun run check, vp run -r typecheck, bun run test, and bun run knip.