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 MiniatR
Validation FluentValidation for requests
Caching HybridCache with MiniatR pipeline
Soft Delete ISoftDeletable for non-destructive deletion
Group Scoping IGroupScoped for multi-tenant data isolation
Concurrency Optimistic locking with PostgreSQL xmin
Middleware Request pipeline, security headers
Authorization Module-based access control
Interceptors EF Core SaveChanges automation
Behaviors MiniatR behaviors (CAPTCHA, honeypot)
Jobs Hangfire background jobs
Email Outbox Reliable email delivery via DB queue
Email i18n Typed translations for email templates
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.