Files
Showy/docs-vault/Frontend.md
T
Mohammed AbadandCopilot 3448142242 feat(frontend): add Spotlight-style command palette with recent tracking
- Add CommandPalette component with keyboard navigation (arrows, Enter, Shift+Enter, Esc)
- Add useCommandPaletteStore Zustand store with localStorage-persisted recently viewed
- Show two distinct sections: Library results and TMDB Results (no duplicates)
- Exclude library entries from TMDB Results section by TMDB ID index
- Add "View all" links: Library section → /library, TMDB section → /search
- Persist non-library TMDB entries in localStorage for recently viewed support
- Register global Ctrl+P / Cmd+P / slash shortcuts in AppLayout
- Track entry visits in EntryDetailsPage for recently viewed
- Track TMDB preview visits in TmdbPreviewPage for recently viewed
- Updated related docs files

Co-authored-by: Copilot <copilot@github.com>
2026-05-04 08:33:27 +01:00

3.5 KiB

title, tags
title tags
Frontend
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

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 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<number, Entry> 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 17 pages use React.lazy() with custom skeleton fallbacks via <Suspense>. 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