Valibot, Zod, ArkType, Yup, schema objects, parser helpers, safeParse, parse | schemas/..., schema/..., validation/..., or validation owner | Schema definitions, parser helpers, typed validation results | Import exported schema/parser/helper | Test fixtures, mocks, route-local thin wrappers when supported |
| FormData parsing, server action input validation, request body validation | action-specific schema owner, schemas/..., action validation helper | Reusable form/request parsers and validation error shaping | Call parser before service/repository logic | One-off tiny action parser if the repo already keeps action-local schemas |
unknown to domain type conversion, type guards, assertion replacement | schemas/..., guards/..., mappers/..., or transform owner | Type guards, decode/parse functions, assertion-free conversion | Call guard/parser, avoid as | Framework-required casts with documented narrow scope |
neverthrow, byethrow, Result, ResultAsync, error wrapping/unwrapping | repository, service, action, or adapter boundary that already translates errors | Conversion between thrown errors, infra errors, and domain/app errors | Consume the boundary result; do not re-wrap equivalent errors | Tests, adapter-specific normalization, framework response adapters |
| Action/route response serialization, domain error to HTTP/UI response mapping | action, route adapter, presenter, or existing response/result serialization owner | Framework response shape, status mapping, UI/action-safe error shape | Import serializer/mapper; keep domain errors separate | Local display copy, thin framework adapters, tests |
DB access, Drizzle, Prisma, Kysely, SQL, query builder, .select, .insert, .update, transaction tx | db/..., repository/..., repositories/..., or data-access owner | Queries, transactions, persistence mapping | Call repository/service API | Migrations, seeds, test setup, generated ORM artifacts |
Multi-repository transaction orchestration, unit-of-work, shared tx across writes | service/use-case boundary, repository transaction boundary, or existing unit-of-work owner | Transaction scope, write coordination, rollback/error policy | Pass intent/data; avoid threading raw tx across layers | Migrations, seeds, focused integration tests |
External API SDK/client, fetch to third-party services, webhook signature verification | clients/..., adapters/..., integrations/..., services/... when established | HTTP client setup, retries, response parsing, external error mapping | Call adapter/client function | Mock clients, local test stubs |
| Environment variables, feature flags, runtime config | config/..., env/..., settings/..., or config module | Env parsing, defaults, required variable validation | Import typed config values | Test env setup, build-tool config files |
| Auth/session/permission checks | auth/..., session/..., permissions/..., middleware/service owner | Session lookup, permission predicates, auth error normalization | Call auth helper/policy | Route-level guard composition, tests |
| Cache/Redis/storage concerns | cache/..., storage/..., repositories/..., adapter owner | Key construction, TTL policy, cache serialization | Call cache/storage helper | Test fakes, one-off migration scripts |
| Queue/job/scheduler concerns | jobs/..., queue/..., workers/..., adapter owner | Enqueue/dequeue payload schema, retry/error policy | Call job/queue API | Worker entrypoints, test helpers |
| Logging, metrics, tracing, telemetry | logger/..., observability/..., telemetry/..., infra helper | Logger construction, metric names, span helpers | Call shared logger/metric helper | Local debug logs during development should not be committed |
| DTO/domain mapping, API response shaping, presenter mapping | mappers/..., transformers/..., presenters/..., or established service/repository boundary | Conversion between persistence/API/domain/view shapes | Import mapper, avoid duplicate object reshaping | Trivial inline projection if local and not repeated |