--- title: Frontend tags: - frontend - react - typescript --- # Frontend ## Overview React 19 + TypeScript SPA built with Vite 8. Located in `react_frontend/`. | Concern | Solution | |---|---| | UI Components | shadcn/ui (base-nova theme) + Tailwind CSS 4 | | Server State | TanStack Query 5 (react-query) | | Client State | Zustand 5 → [[Stores]] | | Routing | React Router 7 → [[Routing]] | | Forms | react-hook-form 7 + Zod 4 | | Charts | Recharts 3 → [[Statistics]] | | Toasts | Sonner | | Icons | Lucide | | Dates | date-fns | | HTTP | Axios | ## Entry Point ``` main.tsx → App.tsx → QueryClientProvider → TooltipProvider → RouterProvider → Toaster ``` **QueryClient config:** - `retry: 1` - `refetchOnWindowFocus: false` - `staleTime: 2 minutes` ## Architecture ```mermaid graph TD subgraph UI["UI Layer"] Pages --> Components Components --> ShadcnUI[shadcn/ui] end subgraph State["State Layer"] Pages --> Hooks Hooks --> TQ[TanStack Query] Hooks --> Store[Zustand Store] TQ --> APIClients[API Clients] end APIClients --> |Axios| Backend[Backend REST API] ``` ### Data Flow 1. App mounts → `useLibrary()` fetches all entries → [[Stores|useLibraryStore]] loaded 2. Pages use [[Hooks]] wrapping TanStack Query for server data 3. Mutations update Zustand optimistically → invalidate Query caches 4. [[Normalizers]] transform backend responses to frontend [[Types]] ## Project Structure ``` react_frontend/src/ ├── api/ → [[API Clients]] (11 Axios modules) ├── components/ → [[Components]] (by category) │ ├── dashboard/ → Chart components │ ├── dialogs/ → Modal dialogs │ ├── entries/ → Entry-related components │ ├── layout/ → AppLayout, Sidebar │ ├── skeletons/ → Loading skeletons │ └── ui/ → shadcn/ui primitives ├── hooks/ → [[Hooks]] (10 hook files) ├── lib/ → Utilities │ ├── api.ts → Axios instance │ ├── media-utils.ts → [[Media Utilities]] │ ├── normalizers.ts → [[Normalizers]] │ └── utils.ts → cn() helper ├── pages/ → [[Pages]] (17 route pages) ├── stores/ → [[Stores]] (3 Zustand stores) └── types/ → [[Types]] (TypeScript interfaces) ``` ## Vite Configuration - React plugin + Tailwind CSS plugin - Path alias: `@/` → `src/` - Dev proxy: `/api` → `http://showyback.coolguy.space` ## Key Patterns ### Library-First Architecture The entire entry library is loaded into a Zustand `Map` on startup. This enables: - O(1) entry lookup by ID - TMDB entries checked against library by TMDB ID → if present, local version displayed - Optimistic UI updates ### Lazy Page Loading All 18 pages use `React.lazy()` with custom skeleton fallbacks via ``. See [[Routing]]. ### Form Pattern Forms use `react-hook-form` with `zodResolver`: ``` useForm({ resolver: zodResolver(schema), values }) → handleSubmit → mutation.mutate ``` ### Toast Notifications All mutation success/error feedback via Sonner toasts. ## See Also - [[Routing]] — All 18 routes - [[Pages]] — Every page component - [[Components]] — UI components by category - [[Hooks]] — Custom hooks - [[Stores]] — State management - [[API Clients]] — Backend communication - [[Types]] — TypeScript types - [[Navigation]] — Breadcrumbs - [[Discovery Videos]] — Personal video vault feature