Skip to content

Code Patterns

Implementation patterns used throughout the codebase. These are the how of the architecture.


API Patterns

Pattern Purpose
CQRS Command/Query separation with MediatR
Validation FluentValidation for requests
Caching MediatR pipeline response caching
Soft Delete ISoftDeletable for non-destructive deletion
Concurrency Optimistic locking with PostgreSQL xmin
Middleware Request pipeline, security headers
Authorization Module-based access control
Interceptors EF Core SaveChanges automation
Behaviors MediatR behaviors (CAPTCHA, honeypot)
Jobs Hangfire background jobs
Email Outbox Reliable email delivery via DB queue
Pagination Consistent pagination format
Error Handling Exception handling patterns

Client Patterns

Pattern Purpose
API Layer TanStack Query for data fetching
State Management Zustand stores
Forms React Hook Form + Yup
i18n Internationalization
Hooks Custom React hooks
Dialogs Modal and dialog patterns
Components Reusable component patterns
Image Upload Client compression + R2 upload
Token Refresh JWT management and auto-refresh
PWA Service worker and caching
Error Handling Client-side error handling

See also: Project Structure for where patterns are implemented, Architecture for why they exist.