01
Server-first application architecture
The application follows a server-first architecture where database access and sensitive business logic remain on the server. Server Actions handle administrative CRUD operations, while API routes are used for authentication and payment-related workflows.
02
Secure authentication and authorization
Authentication is built around short-lived access tokens and refresh tokens. Refresh tokens are stored in HttpOnly cookies, while user roles are used for authorization and protecting admin-only routes and operations.
03
Server-authoritative business logic
Critical business logic such as product pricing, inventory validation, and order totals is handled on the server. Client-side values are treated as untrusted input rather than the source of truth for transactional data.
04
Consistent client-side state management
Redux Toolkit manages cart state across the application, while LocalStorage persists cart data between sessions. Server-side validation is used to reconcile persisted client state with the latest database values when necessary.
05
Data-aware caching strategy
Caching and revalidation are applied according to data volatility. Relatively stable data can benefit from caching, while frequently changing transactional data such as prices and inventory is validated against the server before critical operations.
06
URL-driven product discovery
Search, filtering, sorting, and pagination state are represented through URL search parameters. This makes product discovery shareable, refreshable, and compatible with browser navigation without relying entirely on local component state.