What problem does it solve?
It solves the problem of messy, duplicated list-query logic by providing a consistent three-layer feature structure and a reusable filtering mechanism for paginated endpoints.
Core Features & Use Cases
- Router → Service → Repository separation: keep tRPC wiring, business rules, and Drizzle database access cleanly partitioned so each layer is easier to evolve and test.
- Composable filter classes: implement one filter per key and apply them consistently across both row queries and total-count queries.
- Pagination contract with filtered totals: return
{ rows, total } where the total matches the active filters, using the same filter set for both queries.
- Use case: refactor an existing inline Drizzle router into a
features/<name>/ folder shape, then add new list filters without touching unrelated router/service code.
Quick Start
Tell the AI to scaffold a new @loyalty/api feature folder using the filters pattern so a list endpoint supports filterable search and returns paginated rows plus a filter-aware total count.