docs(react_frontend): add comprehensive documentation & AGENTS.md

- docs/README.md: overview and table of contents
- docs/tech_stack.md: full dependency inventory and design decisions
- docs/project_structure.md: directory tree with conventions
- docs/architecture.md: data flow, layer responsibilities, key patterns
- docs/routing.md: route table, code splitting, discover categories
- docs/state_management.md: Zustand stores and React Query conventions
- docs/api_layer.md: all API modules with endpoint mappings
- docs/components.md: layout, entries, collections, charts, dialogs, UI primitives
- docs/pages.md: all 16 pages with features and routes
- docs/styling.md: theming, CSS tokens, responsive breakpoints, animations
- AGENTS.md: architecture summary, code conventions, data flow, key files
This commit is contained in:
Mohammed Abad committed 2026-04-10 02:44:06 +01:00
1 parent 6bff2055b4
commit d28b4caa7e
14 files changed
+1266 -78

No files matched your search

+101
View File
@@ -0,0 +1,101 @@
# Agents & Copilot Instructions
> **Last reviewed:** 2026-04-09
---
## Project Overview
Showy React frontend — a single-page application for personal movie & TV series tracking. Built with React 19, TypeScript, Vite, Tailwind CSS 4, and shadcn/ui.
---
## Architecture Summary
| Layer | Directory | Purpose |
| ----------- | ------------------ | ----------------------------------------------------------------------- |
| Pages | `src/pages/` | Route entry-points, compose components, manage local UI state |
| Components | `src/components/` | Reusable UI blocks (entries, dialogs, charts, layout, skeletons) |
| Hooks | `src/hooks/` | React Query wrappers — queries, mutations, cache invalidation |
| API | `src/api/` | Thin Axios wrappers (one file per backend domain) |
| Stores | `src/stores/` | Zustand stores — library cache (`Map<id, Entry>`), theme preference |
| Lib | `src/lib/` | Utilities — Axios instance, media URLs, normalisers, `cn()` |
| Types | `src/types/` | All TypeScript interfaces (`index.ts`) |
| UI | `src/components/ui/` | shadcn/ui primitives (copied, not installed as a dependency) |
---
## Code Conventions
| Rule | Detail |
| ------------------------ | --------------------------------------------------------------------------- |
| File naming | PascalCase for components/pages; camelCase for hooks, api, utils, stores |
| Exports | Named exports for hooks & utils; default exports for pages |
| Path alias | `@/` → `src/` |
| State management | Zustand for sync client state; React Query for async server state |
| Data fetching | Always through `hooks/` → `api/` → Axios. Never fetch directly in components |
| Normalisation | `lib/normalizers.ts` transforms backend responses before caching |
| Styling | Tailwind CSS utility classes + CSS custom property tokens |
| Component lib | shadcn/ui primitives in `components/ui/`, extended via `cn()` utility |
| Forms | React Hook Form + Zod resolvers |
| Toasts | Sonner — `toast.success()` / `toast.error()` on mutations |
| Charts | Recharts with `ResponsiveContainer` |
| Lazy loading | All pages via `React.lazy()` + `<Suspense>` with skeleton fallbacks |
| Infinite pagination | `useInfiniteQuery` for TMDB browse/search endpoints |
---
## Data Flow
```
Page → Hook (useQuery/useMutation) → API module (Axios) → Backend REST API
↓ normalise
Zustand store (library entries)
```
- Library entries are cached in a Zustand `Map<number, Entry>` for O(1) lookups.
- TMDB entries are checked against the library store by TMDB ID — if present, the richer local version is displayed.
- Mutations update the Zustand store immediately, then invalidate React Query caches.
---
## Backend API
- **Base URL:** `/api/v1` (proxied via Vite dev server to the backend)
- **Configurable:** `VITE_API_URL` environment variable
- **Proxy config** in `vite.config.ts`: `/api` → backend origin
All backend endpoints are documented in `backend/docs/api_reference.md`.
---
## Key Files
| File | Purpose |
| ------------------------ | -------------------------------------------------------------- |
| `src/main.tsx` | Entry point — `ReactDOM.createRoot` |
| `src/App.tsx` | Root component — `QueryClientProvider` + `RouterProvider` |
| `src/router.tsx` | Route definitions with lazy imports and Suspense wrappers |
| `src/index.css` | Global styles, Tailwind imports, OKLCH theme tokens |
| `src/lib/api.ts` | Axios instance, base URL, image URL helpers |
| `src/lib/normalizers.ts` | Backend → frontend data transformation |
| `src/types/index.ts` | All TypeScript interfaces |
| `components.json` | shadcn/ui CLI configuration |
| `vite.config.ts` | Vite config — Tailwind plugin, React plugin, API proxy |
---
## Documentation
Detailed documentation lives in `docs/`:
- [README](docs/README.md) — Overview
- [Tech Stack](docs/tech_stack.md)
- [Project Structure](docs/project_structure.md)
- [Architecture](docs/architecture.md)
- [Routing](docs/routing.md)
- [State Management](docs/state_management.md)
- [API Layer](docs/api_layer.md)
- [Components](docs/components.md)
- [Pages](docs/pages.md)
- [Styling & Theming](docs/styling.md)