System Architecture
Separation of Concerns
The codebase follows a strict layered architecture:| Layer | Responsibility | Location |
|---|---|---|
| UI | React components, presentation only | components/ |
| Logic | Business logic via custom hooks | hooks/ |
| Data | API calls and data fetching | lib/api/ |
| State | Global state via Context providers | context/ |
Design Principles
API-First Security
API-First Security
The mobile app calls Supabase directly via
supabase.rpc(), supabase.from(), and supabase.auth for all reads, writes, and authentication. There are no web API route dependencies — everything goes through the Supabase client SDK with RLS policies as the primary security layer.The web client (Phase 2) will route all data mutations through API routes (/api/*) with the Supabase service key used only server-side. RLS policies act as the last line of defense.Component Reusability
Component Reusability
UI components live in
componentlibrary/ (shadcn/ui). Feature components are organized by domain: auth/, recipe/, user/. Check existing components before creating new ones.Type Safety
Type Safety
Strict TypeScript throughout — no
any types. Database types use snake_case, API responses use camelCase. Conversion utilities handle the mapping.Shared Code
Shared Code