What problem does it solve?
It prevents accidental coupling between UI routes/components, server functions, and database access so your TanStack Start app stays maintainable and testable as features grow.
Core Features & Use Cases
- Fixed dependency chain: Enforces that routes/components/hooks/queries call server functions in src/fn/, which only call use cases or data-access, with Drizzle/database calls confined to src/data-access/.
- Correct placement for infra I/O: Ensures third-party SDK calls (e.g., Stripe, S3/R2 presigning, email send) are wrapped and placed under src/data-access/ and invoked from fn/use cases instead of being called directly from fn/ or use-cases.
- Query correctness with TanStack Query: Requires queryOptions and query keys to live in src/queries/ and be reused by hooks and route loaders via ensureQueryData to avoid cache key drift.
- Business-rule guardrails: Routes multi-step invariants (plan limits, ownership across entities, cross-entity orchestration) into src/use-cases/, keeping data-access as a thin DB shim.
- Auth boundary clarity: Keeps authentication/ownership checks at the fn handler boundary (with authenticatedMiddleware and row ownership comparisons), not inside data-access or use cases.
Quick Start
Ask the AI to add or change a feature by following the dependency chain and placing database access only in src/data-access/, business rules only in src/use-cases/, and query/mutation behavior through src/queries/ and src/hooks/ with no cross-layer shortcutting.