Layer contracts
ImtehanHub's read-write flow uses six fixed layers — types, repositories, services, stores, hooks, components — walked end-to-end via "submit a test."
Routing
React Router 7 with every path declared in src/config/routes.ts as a typed constant. No magic strings, one rename point, explicit back-button targets.
State management
Three state buckets — Zustand for client state, TanStack Query for server state, RHF for form state. Persisted via a Capacitor-aware storage adapter.
Forms
Every form uses React Hook Form + Zod with a shared field-component library. One pattern, full type-safety, isolated re-renders, accessible by default.
Storage adapter
One adapter routes persistent storage to @capacitor/preferences on Android and localStorage on the web. Zustand stores and ad-hoc reads share one API.
Theme architecture
Radix theme surface + Zustand store + Capacitor storage adapter + Firestore sync on sign-in + boot loader that prevents the wrong-theme flash on cold start.
Analytics & errors
Every tracked action fans out to Firebase Analytics, Amplitude, and Microsoft Clarity. Errors go to Sentry with PII scrubbed. All four fail-open on missing env keys.