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

+30 -11
View File
@@ -1,6 +1,6 @@
# Agents & Autonomous Logic
> **Last reviewed:** 2026-03-30
> **Last reviewed:** 2026-04-09
---
@@ -109,16 +109,17 @@ GET /people/:id
These are not autonomous but are invoked by the managers above:
| Service | File | Role |
| ------------------------ | ------------------------------------ | ----------------------------------------------------------------------------------------- |
| `tmdbService` | `services/tmdbService.js` | HTTP client wrapping TMDB API v3 (entries, seasons, credits, people, collections, images) |
| `mediaDownloaderService` | `services/mediaDownloaderService.js` | Downloads remote images to local filesystem |
| `mediaOptimizerService` | `services/mediaOptimizerService.js` | Generates low-resolution preview variants (JPEG/PNG) |
| `configService` | `services/configService.js` | Reads/writes `settings.json`; provides TMDB API credentials and data paths |
| `storageService` | `services/storageService.js` | Low-level file write abstraction |
| `networkService` | `services/networkService.js` | Creates or updates TV network records |
| `importerService` | `services/importerService.js` | Bulk-import orchestration with TMDB rate-limit handling (35 req / 10 s) |
| `maintenanceService` | `services/maintenanceService.js` | Detects and cleans orphan files and DB records |
| Service | File | Role |
| ------------------------ | ------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------- |
| `tmdbService` | `services/tmdbService.js` | HTTP client wrapping TMDB API v3 (entries, seasons, credits, people, collections, images, trending, popular, top-rated, upcoming, search) |
| `mediaDownloaderService` | `services/mediaDownloaderService.js` | Downloads remote images to local filesystem |
| `mediaOptimizerService` | `services/mediaOptimizerService.js` | Generates low-resolution preview variants (JPEG/PNG) |
| `configService` | `services/configService.js` | Reads/writes `settings.json`; provides TMDB API credentials and data paths |
| `storageService` | `services/storageService.js` | Low-level file write abstraction |
| `networkService` | `services/networkService.js` | Creates or updates TV network records |
| `importerService` | `services/importerService.js` | Bulk-import orchestration with TMDB rate-limit handling (35 req / 10 s) |
| `maintenanceService` | `services/maintenanceService.js` | Detects and cleans orphan files and DB records |
| `statisticsController` | `controllers/statisticsController.js` | Aggregates watch-time, watch-count, and weekday-distribution statistics via raw SQL |
---
@@ -148,3 +149,21 @@ The manager pattern is well-suited for upgrading to a true agentic architecture
- **Observation loop** — The lazy-fetch pattern (`fully_fetched` checks) already implements observe → decide → act semantics.
No such integration exists today. All decision logic is deterministic and rule-based.
---
## TMDB Proxy Layer
The backend exposes a set of **proxy endpoints** under `/api/v1/entries/tmdb/*` and `/api/v1/people/tmdb/*` that forward paginated requests to the TMDB API. This keeps the TMDB API key server-side and provides a uniform interface for the frontend's discover/search features:
| Endpoint | TMDB Operation |
| ----------------------------------- | --------------------- |
| `GET /entries/tmdb/trending/:type` | Trending movies / TV |
| `GET /entries/tmdb/popular/:type` | Popular movies / TV |
| `GET /entries/tmdb/top-rated/:type` | Top-rated movies / TV |
| `GET /entries/tmdb/upcoming/movie` | Upcoming movies |
| `GET /entries/tmdb/search?query=` | Multi-search |
| `GET /people/tmdb/popular` | Popular people |
| `GET /people/tmdb/search?query=` | Search people |
These are stateless pass-through calls — no local data is written.
+126
View File
@@ -22,6 +22,8 @@
12. [Settings](#12-settings)
13. [Maintenance](#13-maintenance)
14. [Killer (Debug)](#14-killer-debug)
15. [TMDB Proxy — Entries](#15-tmdb-proxy--entries)
16. [TMDB Proxy — People](#16-tmdb-proxy--people)
---
@@ -903,6 +905,19 @@ Get all credits (roles) for a person.
---
### `GET /api/v1/people/:id/tmdb-filmography`
Get the full combined filmography for a person directly from TMDB (includes entries not in the local library).
| Parameter | In | Type | Required | Description |
| --------- | ---- | ------- | -------- | ----------- |
| `id` | path | integer | yes | Person ID |
**Response** `200` — TMDB combined credits object (`{ cast: [...], crew: [...] }`).
**Response** `404` — Person not found or missing TMDB ID.
---
### `POST /api/v1/people/:id/media`
Upload a profile picture for a person.
@@ -1014,6 +1029,20 @@ Get monthly watch count (number of items watched) for a given year.
---
### `GET /api/v1/statistics/watch-weekday`
Get watch count grouped by day of the week (1 = Sunday … 7 = Saturday).
**Response** `200`
```json
{
"episodes": [{ "day": 2, "count": 120 }, { "day": 7, "count": 45 }],
"movies": [{ "day": 6, "count": 15 }]
}
```
---
## 12. Settings
### `GET /api/v1/settings`
@@ -1100,6 +1129,103 @@ Intentionally crashes the backend process (used by Electron to manage the backen
---
## 15. TMDB Proxy — Entries
These endpoints proxy requests to the TMDB API through the backend, enabling discovery features in the frontend without exposing the TMDB API key to the client.
### `GET /api/v1/entries/tmdb/trending/:type`
Get trending entries from TMDB.
| Parameter | In | Type | Required | Description |
| --------- | ----- | ------- | -------- | ------------------------ |
| `type` | path | string | yes | `movie` or `tv` |
| `page` | query | integer | no | Page number (default: 1) |
**Response** `200` — TMDB paginated response (`{ page, results, total_pages, total_results }`).
---
### `GET /api/v1/entries/tmdb/popular/:type`
Get popular entries from TMDB.
| Parameter | In | Type | Required | Description |
| --------- | ----- | ------- | -------- | ------------------------ |
| `type` | path | string | yes | `movie` or `tv` |
| `page` | query | integer | no | Page number (default: 1) |
**Response** `200` — TMDB paginated response.
---
### `GET /api/v1/entries/tmdb/top-rated/:type`
Get top-rated entries from TMDB.
| Parameter | In | Type | Required | Description |
| --------- | ----- | ------- | -------- | ------------------------ |
| `type` | path | string | yes | `movie` or `tv` |
| `page` | query | integer | no | Page number (default: 1) |
**Response** `200` — TMDB paginated response.
---
### `GET /api/v1/entries/tmdb/upcoming/movie`
Get upcoming movies from TMDB.
| Parameter | In | Type | Required | Description |
| --------- | ----- | ------- | -------- | ------------------------ |
| `page` | query | integer | no | Page number (default: 1) |
**Response** `200` — TMDB paginated response.
---
### `GET /api/v1/entries/tmdb/search`
Search TMDB for movies and TV series (multi-search).
| Parameter | In | Type | Required | Description |
| --------- | ----- | ------- | -------- | ------------------------ |
| `query` | query | string | yes | Search term |
| `page` | query | integer | no | Page number (default: 1) |
**Response** `200` — TMDB paginated response.
**Response** `400` — Missing `query` parameter.
---
## 16. TMDB Proxy — People
### `GET /api/v1/people/tmdb/popular`
Get popular people from TMDB.
| Parameter | In | Type | Required | Description |
| --------- | ----- | ------- | -------- | ------------------------ |
| `page` | query | integer | no | Page number (default: 1) |
**Response** `200` — TMDB paginated response of person objects.
---
### `GET /api/v1/people/tmdb/search`
Search TMDB for people by name.
| Parameter | In | Type | Required | Description |
| --------- | ----- | ------- | -------- | ------------------------ |
| `query` | query | string | yes | Search term |
| `page` | query | integer | no | Page number (default: 1) |
**Response** `200` — TMDB paginated response of person objects.
**Response** `400` — Missing `query` parameter.
---
## Error Responses
All endpoints use a global error-handling middleware. Common shapes:
+2 -2
View File
@@ -310,8 +310,8 @@ Polymorphic asset table. The target entity is identified by the `(mediaable, med
| `is_local` | BOOLEAN | True if stored locally |
| `is_selected` | BOOLEAN | DEFAULT false — currently active asset |
| `is_custom` | BOOLEAN | DEFAULT false — user-uploaded |
| `is_favorit` | BOOLEAN | DEFAULT false |
| `is_favorit` | BOOLEAN | DEFAULT false | | `createdAt` | DATETIME | Sequelize-managed |
| `updatedAt` | DATETIME | Sequelize-managed |
---
## 3. Entity Relationship Diagram
+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)
+27 -65
View File
@@ -1,73 +1,35 @@
# React + TypeScript + Vite
# Showy — React Frontend Documentation
This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.
> **Last reviewed:** 2026-04-09
Currently, two official plugins are available:
## Table of Contents
- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react) uses [Oxc](https://oxc.rs)
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react-swc) uses [SWC](https://swc.rs/)
1. [Overview](#overview)
2. [Tech Stack](docs/tech_stack.md)
3. [Project Structure](docs/project_structure.md)
4. [Architecture](docs/architecture.md)
5. [Routing](docs/routing.md)
6. [State Management](docs/state_management.md)
7. [API Layer](docs/api_layer.md)
8. [Components](docs/components.md)
9. [Pages](docs/pages.md)
10. [Styling & Theming](docs/styling.md)
## React Compiler
---
The React Compiler is not enabled on this template because of its impact on dev & build performances. To add it, see [this documentation](https://react.dev/learn/react-compiler/installation).
## Overview
## Expanding the ESLint configuration
Showy's React frontend is a **single-page application** for tracking movies and TV series. It communicates with the Showy backend REST API and proxies TMDB discovery requests through it.
If you are developing a production application, we recommend updating the configuration to enable type-aware lint rules:
**Key capabilities:**
```js
export default defineConfig([
globalIgnores(['dist']),
{
files: ['**/*.{ts,tsx}'],
extends: [
// Other configs...
// Remove tseslint.configs.recommended and replace with this
tseslint.configs.recommendedTypeChecked,
// Alternatively, use this for stricter rules
tseslint.configs.strictTypeChecked,
// Optionally, add this for stylistic rules
tseslint.configs.stylisticTypeChecked,
// Other configs...
],
languageOptions: {
parserOptions: {
project: ['./tsconfig.node.json', './tsconfig.app.json'],
tsconfigRootDir: import.meta.dirname,
},
// other options...
},
},
])
```
You can also install [eslint-plugin-react-x](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-x) and [eslint-plugin-react-dom](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-dom) for React-specific lint rules:
```js
// eslint.config.js
import reactX from 'eslint-plugin-react-x'
import reactDom from 'eslint-plugin-react-dom'
export default defineConfig([
globalIgnores(['dist']),
{
files: ['**/*.{ts,tsx}'],
extends: [
// Other configs...
// Enable lint rules for React
reactX.configs['recommended-typescript'],
// Enable lint rules for React DOM
reactDom.configs.recommended,
],
languageOptions: {
parserOptions: {
project: ['./tsconfig.node.json', './tsconfig.app.json'],
tsconfigRootDir: import.meta.dirname,
},
// other options...
},
},
])
```
- Browse, search, and discover movies & TV series via TMDB
- Manage a personal media library (add/remove/favourite/watchlist/hide)
- Track watch history for movies and individual episodes
- Organize entries into user-defined or TMDB-sourced collections
- View cast & crew details with filmography
- Dashboard with watch-time, activity, and rating statistics
- Calendar view for upcoming episode air dates
- Manage custom media assets (posters, backdrops, logos)
- Light / dark theme with persistent preference
- Responsive design (mobile-first)
+141
View File
@@ -0,0 +1,141 @@
# API Layer
> **HTTP Client:** Axios · **Base URL:** `/api/v1` (proxied to backend via Vite dev server)
---
## Configuration
**File:** `src/lib/api.ts`
Creates a shared Axios instance with:
- `baseURL` derived from `VITE_API_URL` environment variable (defaults to `/api/v1`)
- Image URL helpers for constructing media paths
---
## API Modules
Each file in `src/api/` provides functions for one backend domain. All functions return the Axios response `.data` directly and run normalisation where applicable.
### `entries.ts`
| Function | Method | Endpoint |
| ------------------------------------ | -------- | ---------------------------------- |
| `getAll()` | `GET` | `/entries` |
| `getById(id)` | `GET` | `/entries/:id` |
| `create(tmdb_id, is_tvserie)` | `POST` | `/entries` |
| `update(id, data)` | `PUT` | `/entries/:id` |
| `updateRatings(id, ratings)` | `PUT` | `/entries/:id/ratings` |
| `updateIds(id, ids)` | `PUT` | `/entries/:id/ids` |
| `delete(id)` | `DELETE` | `/entries/:id` |
| `refresh(id)` | `PUT` | `/entries/:id/refresh` |
| `fetchCollection(id)` | `PUT` | `/entries/:id/fetch-collection` |
| `getSeasons(id)` | `GET` | `/entries/:id/seasons` |
| `uploadMedia(id, formData)` | `POST` | `/entries/:id/media` |
| `setMediaSelected(entryId, mediaId)` | `PUT` | `/entries/:entryId/media/:mediaId` |
| `deleteMedia(entryId, mediaId)` | `DELETE` | `/entries/:entryId/media/:mediaId` |
### `collections.ts`
| Function | Method | Endpoint |
| ------------------------------------ | -------- | --------------------------------------------- |
| `getAll()` | `GET` | `/collections` |
| `getById(id)` | `GET` | `/collections/:id` |
| `create(data)` | `POST` | `/collections` |
| `update(id, data)` | `PUT` | `/collections/:id` |
| `updateWithMedia(id, formData)` | `PUT` | `/collections/:id` (multipart) |
| `delete(id)` | `DELETE` | `/collections/:id` |
| `addEntry(collectionId, entryId)` | `POST` | `/collections/:collectionId/entries/:entryId` |
| `removeEntry(collectionId, entryId)` | `DELETE` | `/collections/:collectionId/entries/:entryId` |
### `entry-seen.ts`
| Function | Method | Endpoint |
| --------------------- | -------- | ------------------------------- |
| `getAll()` | `GET` | `/entry-seen` |
| `getByEntry(entryId)` | `GET` | `/entry-seen/by-entry/:entryId` |
| `create(data)` | `POST` | `/entry-seen` |
| `update(id, data)` | `PUT` | `/entry-seen/:id` |
| `delete(id)` | `DELETE` | `/entry-seen/:id` |
### `episode-seen.ts`
| Function | Method | Endpoint |
| ------------------------- | -------- | ------------------------------------- |
| `getAll()` | `GET` | `/episode-seen` |
| `getById(id)` | `GET` | `/episode-seen/:id` |
| `getByEpisode(episodeId)` | `GET` | `/episode-seen/by-episode/:episodeId` |
| `create(data)` | `POST` | `/episode-seen` |
| `update(id, data)` | `PUT` | `/episode-seen/:id` |
| `delete(id)` | `DELETE` | `/episode-seen/:id` |
### `episodes.ts`
| Function | Method | Endpoint |
| -------------------------------- | ------ | ------------------------------------- |
| `getByMonth(startDate, endDate)` | `GET` | `/episodes/month/:startDate/:endDate` |
### `seasons.ts`
| Function | Method | Endpoint |
| ------------------ | -------- | ----------------------- |
| `getAll()` | `GET` | `/seasons` |
| `getById(id)` | `GET` | `/seasons/:id` |
| `getEpisodes(id)` | `GET` | `/seasons/:id/episodes` |
| `create(data)` | `POST` | `/seasons` |
| `update(id, data)` | `PUT` | `/seasons/:id` |
| `delete(id)` | `DELETE` | `/seasons/:id` |
### `people.ts`
| Function | Method | Endpoint |
| ------------------------ | ------ | ------------------------------ |
| `getAll()` | `GET` | `/people` |
| `getById(id)` | `GET` | `/people/:id` |
| `getCredits(id)` | `GET` | `/people/:id/credits` |
| `getTmdbFilmography(id)` | `GET` | `/people/:id/tmdb-filmography` |
| `fetchByTmdbId(tmdb_id)` | `POST` | `/people/fetch` |
### `tmdb.ts`
| Function | Method | Endpoint |
| --------------------------- | ------ | ------------------------------- |
| `getTrendingMovies(page)` | `GET` | `/entries/tmdb/trending/movie` |
| `getTrendingTv(page)` | `GET` | `/entries/tmdb/trending/tv` |
| `getPopularMovies(page)` | `GET` | `/entries/tmdb/popular/movie` |
| `getPopularTv(page)` | `GET` | `/entries/tmdb/popular/tv` |
| `getTopRatedMovies(page)` | `GET` | `/entries/tmdb/top-rated/movie` |
| `getTopRatedTv(page)` | `GET` | `/entries/tmdb/top-rated/tv` |
| `getUpcomingMovies(page)` | `GET` | `/entries/tmdb/upcoming/movie` |
| `search(query, page)` | `GET` | `/entries/tmdb/search` |
| `getPopularPeople(page)` | `GET` | `/people/tmdb/popular` |
| `searchPeople(query, page)` | `GET` | `/people/tmdb/search` |
### `statistics.ts`
| Function | Method | Endpoint |
| --------------------------- | ------ | ------------------------------------ |
| `getAllTimeWatchTime()` | `GET` | `/statistics/watch-time` |
| `getYearlyWatchTime(year)` | `GET` | `/statistics/watch-time/year/:year` |
| `getYearlyWatchCount(year)` | `GET` | `/statistics/watch-count/year/:year` |
| `getWatchdayDistribution()` | `GET` | `/statistics/watch-weekday` |
### `settings.ts`
| Function | Method | Endpoint |
| -------------- | ------ | ----------- |
| `get()` | `GET` | `/settings` |
| `update(data)` | `PUT` | `/settings` |
---
## Normalisation
**File:** `src/lib/normalizers.ts`
Transforms backend responses into the frontend type contract:
- Handles singular ↔ plural aliases (`entryRating` → `entryRatings`)
- Maps nested includes to flat arrays
- Marks entries loaded from the library as `isInLibrary: true`
+70
View File
@@ -0,0 +1,70 @@
# Architecture
## Data Flow
```
┌──────────────┐ ┌───────────────┐ ┌──────────────────┐ ┌──────────────┐
│ Pages / │────▶│ React Query │────▶│ API modules │────▶│ Backend │
│ Components │ │ Hooks │ │ (src/api/*.ts) │ │ REST API │
│ │◀────│ (src/hooks/) │◀────│ │◀────│ │
└──────┬───────┘ └───────────────┘ └──────────────────┘ └──────────────┘
│ │
│ reads / writes │ normalizeEntry()
▼ │ normalizeCollection()
┌──────────────┐ │
│ Zustand │◀──────────────────────────────────┘
│ Stores │ (library store updated on fetch & mutation)
└──────────────┘
```
1. **Pages** call React Query hooks (e.g. `useLibrary()`, `useEntry(id)`).
2. **Hooks** invoke API module functions which make Axios HTTP requests to the backend.
3. **Responses** are run through normaliser functions (`normalizeEntry`, `normalizeCollection`) to transform snake_case backend data and alias inconsistencies into a consistent frontend shape.
4. On library-level fetches and mutations, the **Zustand library store** is also updated so that all components reflect changes instantly without waiting for cache invalidation.
---
## Layer Responsibilities
| Layer | Directory | Responsibility |
| -------------- | ---------------- | ---------------------------------------------------------------------------------------------------- |
| **Pages** | `pages/` | Route entry-points. Compose components, call hooks, manage local UI state (search, filters, dialogs) |
| **Components** | `components/` | Reusable UI building blocks. Receive data via props. Emit events via callbacks |
| **Hooks** | `hooks/` | Encapsulate React Query queries & mutations. Define cache keys, stale times, invalidation |
| **API** | `api/` | Thin Axios wrappers. One function per endpoint. Run normalisation on responses |
| **Stores** | `stores/` | Zustand global state. Library entry cache (Map), theme preference |
| **Lib** | `lib/` | Pure utility functions — class merging, media URL building, data normalisation |
| **Types** | `types/` | All TypeScript interfaces and type aliases |
| **UI** | `components/ui/` | shadcn/ui primitives — buttons, dialogs, inputs, etc. |
---
## Key Patterns
### Normalisation
Backend responses use a mix of casing conventions and singular/plural aliases. The normaliser layer (`lib/normalizers.ts`) transforms these into a consistent frontend shape:
- `entryRating` → `entryRatings`
- `entryId` → `entryIds`
- `entrySeen` → `entrySeens`
- Snake-case object keys preserved for domain fields; camelCase for discriminators
### Lazy Loading
All pages are loaded with `React.lazy()` and wrapped in `<Suspense>` with route-specific skeleton fallbacks. This code-splits each page into a separate chunk.
### Infinite Queries
TMDB browse endpoints (trending, popular, top-rated, search) use React Query's `useInfiniteQuery` with:
- `initialPageParam: 1`
- `getNextPageParam: (lastPage) => lastPage.page < lastPage.total_pages ? lastPage.page + 1 : undefined`
- Pages are flattened via `.data?.pages.flatMap(p => p.results)`
### Library Merge
When displaying TMDB entries alongside library entries (e.g. on the Home or Discover pages), the `EntryCard` component checks the Zustand library store by TMDB ID. If an entry is already in the library, the richer local version (with ratings, favourite status, etc.) is displayed instead of the raw TMDB data.
### Mutation Optimism
Mutations (add/remove/update) update the Zustand store immediately on success, then invalidate related React Query caches for eventual consistency.
+149
View File
@@ -0,0 +1,149 @@
# Components
## Layout
### `AppLayout`
**File:** `src/components/layout/AppLayout.tsx`
Root layout component rendered around all routes via React Router's `<Outlet />`.
- **Desktop:** Fixed left sidebar (`w-56`) + main content area
- **Mobile:** Top header with hamburger menu → `Sheet` overlay sidebar
- Responsive padding adjustments (`pt-18` on mobile for fixed header)
### `Sidebar`
**File:** `src/components/layout/Sidebar.tsx`
Navigation sidebar with grouped links:
| Group | Items |
| ------- | -------------------------------------- |
| Main | Dashboard, Home |
| Library | Library, Watchlist, Collections, Media |
| Other | Calendar, People |
| Footer | Settings, Theme toggle |
Active route highlighted with `bg-sidebar-accent`. Tooltips on all items.
---
## Entry Components
### `EntryCard`
**File:** `src/components/entries/EntryCard.tsx`
Versatile card for displaying a movie or TV series. Accepts either a library `Entry` or a `TmdbEntry`.
- Poster image with `aspect-[2/3]` ratio
- Overlays: title, year, rating badge, type badge (Movie/TV)
- Action button: "Add to Library" for TMDB entries, "Remove" (with confirm) for library entries
- Checks Zustand library store to determine if a TMDB entry is already in the library
- Skeleton loading state
### `EntryLibraryGrid`
**File:** `src/components/entries/EntryLibraryGrid.tsx`
Responsive grid for displaying `EntryCard` items with infinite scroll.
- Responsive columns: 2 → 3 → 4 → 5 → 6 → 7 cols across breakpoints
- `IntersectionObserver` for lazy loading / load-more trigger
- Loading skeletons and empty state
- Animated card entrance (`animate-card-enter`)
### `TrendingSlider`
**File:** `src/components/entries/TrendingSlider.tsx`
Auto-rotating hero carousel for featured entries.
- Displays top 10 entries as full-width backdrop heroes
- Auto-rotates every 6 seconds
- Manual navigation (prev/next arrows)
- Gradient overlay with title, description, rating, type badge
- Add/remove library actions
### `TrendingGrid`
**File:** `src/components/entries/TrendingGrid.tsx`
Tabbed grid showing entries by category (trending, popular, etc.).
- Tab switcher: Movies / TV Series
- Shows up to 14 items + "More" link to discover page
- Animated card entrance
### `CastList`
**File:** `src/components/entries/CastList.tsx`
Horizontal scrollable list of cast members for an entry.
- Filters credits to `cast_type === 'cast'` only
- Avatar + name + character name
- Clickable → links to person details page
### `SeasonsContainer`
**File:** `src/components/entries/SeasonsContainer.tsx`
Expandable seasons list for TV series entries.
### `EpisodeWatchHistory`
**File:** `src/components/entries/EpisodeWatchHistory.tsx`
Watch history display for individual episodes.
---
## Collection Components
### `CollectionsGrid`
**File:** `src/components/collections/CollectionsGrid.tsx`
Grid of collection cards showing poster with gradient overlay and name. Includes skeleton and empty states.
---
## Dashboard Charts
All chart components use **Recharts** with `ResponsiveContainer`. Common pattern: card wrapper + filter controls in `CardHeader` + chart in `CardContent`.
| Component | Chart Type | Data Source | Controls |
| -------------------- | ------------- | -------------------------- | -------------------------- |
| `WatchActivityChart` | Area chart | Yearly watch count | Year selector, type filter |
| `WatchTimeChart` | Bar chart | Yearly watch time | Year selector |
| `RatingsChart` | Bar chart | Rating distribution | — |
| `TopGenresChart` | Bar/Pie chart | Genre frequency | — |
| `CouchDayChart` | Bar chart | Weekday watch distribution | — |
| `LibraryGrowthChart` | Line chart | Library size over time | — |
| `MediaTypeChart` | Pie chart | Movies vs TV split | — |
---
## Dialog Components
All dialogs follow a controlled pattern: `open` + `onOpenChange` props from parent, mutation hooks for actions, loading states on submit buttons.
| Component | Purpose |
| ---------------------------- | ------------------------------------------------ |
| `ConfirmDialog` | Generic confirmation modal (default/destructive) |
| `EntrySettingsDialog` | Toggle entry flags (favourite, hidden, etc.) |
| `EntrySeenDialog` | Add/edit movie watch record or TV episode watch |
| `RatingDialog` | 10-star rating picker with hover preview |
| `EntryMediaDialog` | Upload custom posters/backdrops for an entry |
| `MovieWatchHistoryDialog` | View/edit/delete movie watch records |
| `AddEntryToCollectionDialog` | Add an entry to one or more collections |
| `CollectionEditDialog` | Edit collection metadata and media |
| `EpisodeSeenEditDialog` | Edit an episode watch record |
---
## Skeleton Components
**File:** `src/components/skeletons/PageSkeletons.tsx`
Loading placeholder components matching the layout of their target pages. Used as `<Suspense>` fallbacks for lazy-loaded routes.
---
## UI Primitives (shadcn/ui)
Located in `src/components/ui/`. These are copy-pasted from the shadcn/ui registry and customised via CSS variables. They are **not** installed as a package.
`avatar` · `badge` · `button` · `calendar` · `card` · `checkbox` · `dialog` · `dropdown-menu` · `input` · `label` · `popover` · `progress` · `scroll-area` · `select` · `separator` · `sheet` · `skeleton` · `sonner` · `switch` · `tabs` · `textarea` · `tooltip`
+206
View File
@@ -0,0 +1,206 @@
# Pages
All pages are **lazy-loaded** via `React.lazy()` with per-route skeleton fallbacks. Each page fetches data through React Query hooks.
---
## `HomePage`
**File:** `src/pages/HomePage.tsx` · **Route:** `/`
Landing page with hero carousel and TMDB browse grids.
- **TrendingSlider** — auto-rotating top-10 hero banner
- **Search bar** — debounced (400 ms); switches between search results and browse mode
- **Browse sections:** Trending, Popular, Top Rated, Upcoming (each as `TrendingGrid`)
- Pre-loads library on mount via `useLibrary()`
---
## `DashboardPage`
**File:** `src/pages/DashboardPage.tsx` · **Route:** `/dashboard`
Statistics overview with summary cards and charts.
- **Stats cards:** Movies count, TV count, Favourites, Watchlist, Total watch time
- **Charts:** WatchActivityChart, WatchTimeChart, RatingsChart, TopGenresChart, CouchDayChart, MediaTypeChart, LibraryGrowthChart
- **Recently Watched:** grid of 14 entries sorted by `date_last_seen` descending
- Year selector controls for time-scoped charts
---
## `LibraryPage`
**File:** `src/pages/LibraryPage.tsx` · **Route:** `/library`
Filterable and sortable library grid.
- **Tabs:** All / Movies / TV / Favourites / Hidden
- **Search:** debounced text search
- **Filters:** Genre, Rating range, Year range (via popovers)
- **Sort:** Last Watched, Date Added, Title, Release Date, Rating
- **Pagination:** 28 items per page with "Load More" button
- Responsive: stacked controls on mobile, inline on desktop
---
## `WatchlistPage`
**File:** `src/pages/WatchlistPage.tsx` · **Route:** `/watchlist`
Similar to LibraryPage but filtered to entries with `watchlist: true`.
---
## `CollectionsPage`
**File:** `src/pages/CollectionsPage.tsx` · **Route:** `/collections`
- **Tabs:** All / Official (TMDB) / Custom (user-created)
- Search by collection name
- Grid of `CollectionsGrid` cards (2–6 cols)
---
## `CollectionDetailsPage`
**File:** `src/pages/CollectionDetailsPage.tsx` · **Route:** `/collections/:id`
Single collection view.
- Hero banner with backdrop
- Poster, name, description, entry count, user rating
- Entry grid (`EntryLibraryGrid`)
- Edit button → `CollectionEditDialog`
---
## `MediaPage`
**File:** `src/pages/MediaPage.tsx` · **Route:** `/media`
Custom media gallery.
- **Tabs:** All / Posters / Backdrops / Logos
- Search by entry title
- Responsive grid (1–6 cols; backdrops as `aspect-video`)
---
## `CalendarPage`
**File:** `src/pages/CalendarPage.tsx` · **Route:** `/calendar`
Monthly calendar for upcoming episode air dates.
- Monthly grid layout
- Episodes grouped by air date (up to 4 per day cell)
- Navigation: previous / next month buttons
- Today highlighted with primary colour
- Episode items show poster thumbnail + S##E## label
- Tooltip with full episode info
---
## `EntryDetailsPage`
**File:** `src/pages/EntryDetailsPage.tsx` · **Route:** `/entry/:id`
Full entry detail page.
- **Hero:** blurred backdrop banner with gradient overlay
- **Sticky poster** on left side
- **Metadata:** title, year, runtime, rating, type badge, genres
- **Description / storyline**
- **Actions:** Favourite toggle, Mark Watched dropdown, Rate, Watch History (movies), Hide/Unhide, Refresh, Add to Collection, Manage Media, Settings
- **Sections:** Cast list, Seasons (TV series), Watch history, Collections
---
## `SeasonPage`
**File:** `src/pages/SeasonPage.tsx` · **Route:** `/entry/:entryId/season/:seasonId`
Season detail with episode list.
- Poster + season header
- Progress bar (watched / total episodes)
- "Mark Season Watched" button
- Episode list: number, name, air date, runtime, ratings, watch status badge
- Mark individual episodes as watched
- Links to episode detail pages
---
## `EpisodePage`
**File:** `src/pages/EpisodePage.tsx` · **Route:** `/entry/:entryId/season/:seasonId/episode/:episodeId`
Single episode detail.
- Still image (or poster fallback)
- Metadata: episode number, air date, runtime
- Description / overview
- Guest stars (cast list)
- Watch history
- Back-links to season and entry
---
## `DiscoverPage`
**File:** `src/pages/DiscoverPage.tsx` · **Route:** `/discover/:category`
TMDB category browsing with infinite scroll.
- Category from URL param: `trending`, `popular`, `top-rated`, `upcoming`
- Tab: Movies / TV (hidden for `upcoming`)
- Infinite pagination via `useInfiniteQuery`
- `EntryCard` grid
---
## `PeoplePage`
**File:** `src/pages/PeoplePage.tsx` · **Route:** `/people`
People search and discovery.
- Search from TMDB Popular or search query
- Infinite scroll pagination
- Avatar grid (3–8 cols)
- Links to person detail pages
---
## `PersonDetailsPage`
**File:** `src/pages/PersonDetailsPage.tsx` · **Route:** `/people/:id`
Person biography and filmography.
- Profile photo + biographical info
- Known-for department
- Filmography: Cast credits + Crew credits
- Links to entry detail pages
---
## `PersonTmdbRedirectPage`
**File:** `src/pages/PersonTmdbRedirectPage.tsx` · **Route:** `/people/tmdb/:tmdbId`
Intermediate page that fetches a person from TMDB by ID, creates a local record if needed, then redirects to `/people/:id`.
---
## `SettingsPage`
**File:** `src/pages/SettingsPage.tsx` · **Route:** `/settings`
Application settings form.
- Fields: TMDB API Key, Backend Port
- Zod validation
- Save button with loading state
+138
View File
@@ -0,0 +1,138 @@
# Project Structure
```
react_frontend/
├── public/ # Static assets served as-is
├── src/
│ ├── api/ # API client modules (one per domain)
│ │ ├── collections.ts
│ │ ├── entries.ts
│ │ ├── entry-seen.ts
│ │ ├── episode-seen.ts
│ │ ├── episodes.ts
│ │ ├── people.ts
│ │ ├── seasons.ts
│ │ ├── settings.ts
│ │ ├── statistics.ts
│ │ └── tmdb.ts
│ ├── components/
│ │ ├── collections/ # Collection-specific components
│ │ │ └── CollectionsGrid.tsx
│ │ ├── dashboard/ # Dashboard chart widgets
│ │ │ ├── CouchDayChart.tsx
│ │ │ ├── LibraryGrowthChart.tsx
│ │ │ ├── MediaTypeChart.tsx
│ │ │ ├── RatingsChart.tsx
│ │ │ ├── TopGenresChart.tsx
│ │ │ ├── WatchActivityChart.tsx
│ │ │ └── WatchTimeChart.tsx
│ │ ├── dialogs/ # Modal dialog components
│ │ │ ├── AddEntryToCollectionDialog.tsx
│ │ │ ├── CollectionEditDialog.tsx
│ │ │ ├── ConfirmDialog.tsx
│ │ │ ├── EntryMediaDialog.tsx
│ │ │ ├── EntrySeenDialog.tsx
│ │ │ ├── EntrySettingsDialog.tsx
│ │ │ ├── EpisodeSeenEditDialog.tsx
│ │ │ ├── MovieWatchHistoryDialog.tsx
│ │ │ └── RatingDialog.tsx
│ │ ├── entries/ # Entry display components
│ │ │ ├── CastList.tsx
│ │ │ ├── EntryCard.tsx
│ │ │ ├── EntryLibraryGrid.tsx
│ │ │ ├── EpisodeWatchHistory.tsx
│ │ │ ├── SeasonsContainer.tsx
│ │ │ ├── TrendingGrid.tsx
│ │ │ └── TrendingSlider.tsx
│ │ ├── layout/ # App shell
│ │ │ ├── AppLayout.tsx
│ │ │ └── Sidebar.tsx
│ │ ├── skeletons/ # Loading placeholders
│ │ │ └── PageSkeletons.tsx
│ │ └── ui/ # shadcn/ui primitives
│ │ ├── avatar.tsx
│ │ ├── badge.tsx
│ │ ├── button.tsx
│ │ ├── calendar.tsx
│ │ ├── card.tsx
│ │ ├── checkbox.tsx
│ │ ├── dialog.tsx
│ │ ├── dropdown-menu.tsx
│ │ ├── input.tsx
│ │ ├── label.tsx
│ │ ├── popover.tsx
│ │ ├── progress.tsx
│ │ ├── scroll-area.tsx
│ │ ├── select.tsx
│ │ ├── separator.tsx
│ │ ├── sheet.tsx
│ │ ├── skeleton.tsx
│ │ ├── sonner.tsx
│ │ ├── switch.tsx
│ │ ├── tabs.tsx
│ │ ├── textarea.tsx
│ │ └── tooltip.tsx
│ ├── hooks/ # React Query custom hooks
│ │ ├── useCollections.ts
│ │ ├── useEntries.ts
│ │ ├── useEntrySeen.ts
│ │ ├── useEpisodes.ts
│ │ ├── useEpisodeSeen.ts
│ │ ├── usePeople.ts
│ │ ├── useSeasons.ts
│ │ ├── useStatistics.ts
│ │ └── useTmdb.ts
│ ├── lib/ # Shared utilities
│ │ ├── api.ts # Axios instance + base URL config
│ │ ├── media-utils.ts # Media URL helpers & formatters
│ │ ├── normalizers.ts # Backend → frontend data transforms
│ │ └── utils.ts # cn() class-name merger
│ ├── pages/ # Route-level page components
│ │ ├── CalendarPage.tsx
│ │ ├── CollectionDetailsPage.tsx
│ │ ├── CollectionsPage.tsx
│ │ ├── DashboardPage.tsx
│ │ ├── DiscoverPage.tsx
│ │ ├── EntryDetailsPage.tsx
│ │ ├── EpisodePage.tsx
│ │ ├── HomePage.tsx
│ │ ├── LibraryPage.tsx
│ │ ├── MediaPage.tsx
│ │ ├── PeoplePage.tsx
│ │ ├── PersonDetailsPage.tsx
│ │ ├── PersonTmdbRedirectPage.tsx
│ │ ├── SeasonPage.tsx
│ │ ├── SettingsPage.tsx
│ │ └── WatchlistPage.tsx
│ ├── stores/ # Zustand state stores
│ │ ├── useLibraryStore.ts
│ │ └── useThemeStore.ts
│ ├── types/
│ │ └── index.ts # All TypeScript interfaces
│ ├── assets/ # Images & static imports
│ ├── App.tsx # App root (QueryClientProvider + Router)
│ ├── router.tsx # Route definitions
│ ├── main.tsx # Entry point (ReactDOM.createRoot)
│ └── index.css # Global styles + theme variables
├── components.json # shadcn/ui CLI config
├── eslint.config.js
├── index.html # Vite HTML entry
├── vite.config.ts
├── tsconfig.json
├── tsconfig.app.json
└── tsconfig.node.json
```
---
## Conventions
| Convention | Rule |
| ------------- | ------------------------------------------------------------------- |
| File naming | PascalCase for components/pages, camelCase for hooks/utils/api |
| Exports | Named exports for hooks & utilities; default exports for pages |
| Path aliases | `@/` maps to `src/` |
| API modules | One file per backend domain, thin wrappers around Axios |
| Hooks | One file per domain, wrapping React Query `useQuery`/`useMutation` |
| Stores | One Zustand store per concern (`library`, `theme`) |
| UI primitives | Copied from shadcn/ui, live in `components/ui/`, customised via CSS |
+55
View File
@@ -0,0 +1,55 @@
# Routing
> **Router:** React Router v7 · **Strategy:** Lazy-loaded with Suspense boundaries
---
## Route Table
All routes are wrapped in the `AppLayout` component (sidebar + main content area).
| Path | Page Component | Description |
| ----------------------------------------------------- | ------------------------ | ------------------------------------------ |
| `/` | `HomePage` | Hero slider, search, TMDB browse grids |
| `/dashboard` | `DashboardPage` | Statistics cards and charts |
| `/library` | `LibraryPage` | Filterable / sortable library grid |
| `/watchlist` | `WatchlistPage` | Watchlisted entries grid |
| `/collections` | `CollectionsPage` | All / Official / Custom collection tabs |
| `/collections/:id` | `CollectionDetailsPage` | Single collection with its entries |
| `/media` | `MediaPage` | Custom media gallery (posters / backdrops) |
| `/calendar` | `CalendarPage` | Monthly episode air-date calendar |
| `/discover/:category` | `DiscoverPage` | Paginated TMDB category browse |
| `/entry/:id` | `EntryDetailsPage` | Full entry detail (info, cast, seasons) |
| `/entry/:entryId/season/:seasonId` | `SeasonPage` | Season detail with episode list |
| `/entry/:entryId/season/:seasonId/episode/:episodeId` | `EpisodePage` | Single episode detail |
| `/people` | `PeoplePage` | People search / popular people grid |
| `/people/tmdb/:tmdbId` | `PersonTmdbRedirectPage` | Fetches person from TMDB → redirects to DB |
| `/people/:id` | `PersonDetailsPage` | Person bio + filmography |
| `/settings` | `SettingsPage` | Application settings form |
---
## Code Splitting
Each page is imported via `React.lazy()`:
```tsx
const HomePage = lazy(() => import('@/pages/HomePage'));
```
Wrapped in `<Suspense fallback={<PageSkeleton />}>` per route, with skeleton components that match the target page layout.
---
## Discover Categories
The `/discover/:category` route accepts:
| Category | Description |
| ----------- | --------------------- |
| `trending` | Trending movies / TV |
| `popular` | Popular movies / TV |
| `top-rated` | Top-rated movies / TV |
| `upcoming` | Upcoming movies only |
Each category has a Movies / TV tab switcher (except `upcoming` which is movies only).
+83
View File
@@ -0,0 +1,83 @@
# State Management
## Stores Overview
Showy uses **Zustand** for synchronous client-side state and **React Query** for all server-side (async) state. The two layers work together:
| Store | Scope | Persistence | Purpose |
| ----------------- | -------- | -------------- | -------------------------------------------- |
| `useLibraryStore` | App-wide | In-memory | Cache of all library entries as a Map |
| `useThemeStore` | App-wide | `localStorage` | Light / dark theme preference |
| React Query cache | Per-hook | In-memory | Server state caching, refetching, pagination |
---
## `useLibraryStore`
**File:** `src/stores/useLibraryStore.ts`
Holds the full set of user library entries in a `Map<number, Entry>` for O(1) lookups by ID.
### State
| Property | Type | Description |
| ---------- | -------------------- | --------------------------------- |
| `entries` | `Map<number, Entry>` | All library entries keyed by ID |
| `isLoaded` | `boolean` | Whether the initial fetch has run |
### Actions
| Action | Signature | Description |
| ------------- | -------------------------------------------- | ------------------------------------------------- |
| `setEntries` | `(entries: Entry[]) => void` | Batch-replace all entries, mark `isLoaded = true` |
| `addEntry` | `(entry: Entry) => void` | Add a single entry (marks it as `isInLibrary`) |
| `updateEntry` | `(id: number, data: Partial<Entry>) => void` | Merge-update an existing entry |
| `removeEntry` | `(id: number) => void` | Delete an entry from the store |
### Derived Selector
```ts
useLibraryEntries() // returns Entry[] (array from the Map values)
```
### Usage Pattern
1. `useLibrary()` hook (in `useEntries.ts`) fetches all entries on mount and calls `setEntries()`.
2. Mutation hooks (`useCreateEntry`, `useDeleteEntry`, etc.) update the store immediately on success.
3. `EntryCard` and other components read from the store to check `isInLibrary` for TMDB entries.
---
## `useThemeStore`
**File:** `src/stores/useThemeStore.ts`
Manages the light/dark theme and persists the choice to `localStorage` under the key `showy-theme`.
### State
| Property | Type | Description |
| -------- | ------------------- | -------------------- |
| `theme` | `'dark' \| 'light'` | Current active theme |
### Actions
| Action | Description |
| ------------- | -------------------------------------------------------- |
| `setTheme` | Set theme explicitly and apply the CSS class to `<html>` |
| `toggleTheme` | Toggle between dark ↔ light |
Theme is applied by toggling the `dark` / `light` class on `document.documentElement`, which Tailwind CSS uses for its dark-mode variant.
---
## React Query Conventions
| Convention | Pattern |
| -------------------- | ----------------------------------------------------------------------- |
| **Query keys** | Domain-scoped arrays: `['entries']`, `['entry', id]`, `['collections']` |
| **Stale time** | 2–10 minutes depending on volatility |
| **Error handling** | 404 responses return empty arrays/objects as fallback |
| **Enabled flag** | Conditional fetching via `enabled: !!id` for dependent queries |
| **Infinite queries** | Used for TMDB pagination (trending, popular, search) |
| **Invalidation** | Mutations invalidate related query keys on success |
+108
View File
@@ -0,0 +1,108 @@
# Styling & Theming
## CSS Architecture
- **Framework:** Tailwind CSS 4 via `@tailwindcss/vite` plugin
- **Colour space:** OKLCH (CSS `oklch()` function)
- **Theming:** CSS custom properties on `:root`, switched via `.dark` / `.light` class on `<html>`
- **Font:** Geist Variable (loaded locally)
- **Border radius:** `0.625rem` (global `--radius` token)
---
## Theme Variables
Defined in `src/index.css` as CSS custom properties. All colours use OKLCH values.
### Core Tokens
| Variable | Purpose |
| ---------------------- | -------------------------- |
| `--background` | Page background |
| `--foreground` | Default text colour |
| `--card` | Card background |
| `--card-foreground` | Card text colour |
| `--primary` | Brand / accent colour |
| `--primary-foreground` | Text on primary background |
| `--secondary` | Secondary surfaces |
| `--muted` | Muted backgrounds |
| `--muted-foreground` | Muted text |
| `--accent` | Interactive accent colour |
| `--destructive` | Error / delete actions |
| `--border` | Default border colour |
| `--input` | Input field border |
| `--ring` | Focus ring colour |
### Chart Tokens
| Variable | Purpose |
| ----------- | -------------- |
| `--chart-1` | Chart colour 1 |
| `--chart-2` | Chart colour 2 |
| `--chart-3` | Chart colour 3 |
| `--chart-4` | Chart colour 4 |
| `--chart-5` | Chart colour 5 |
### Sidebar Tokens
| Variable | Purpose |
| ---------------------- | ------------------ |
| `--sidebar-background` | Sidebar background |
| `--sidebar-foreground` | Sidebar text |
| `--sidebar-primary` | Active item text |
| `--sidebar-accent` | Active item bg |
| `--sidebar-border` | Sidebar border |
| `--sidebar-ring` | Sidebar focus ring |
---
## Dark / Light Mode
Theme toggling is managed by `useThemeStore` (Zustand, persisted to `localStorage`).
The `setTheme` action applies the corresponding class to `document.documentElement`:
```ts
document.documentElement.classList.remove('light', 'dark');
document.documentElement.classList.add(theme);
```
Tailwind's `darkMode: 'class'` strategy detects the class and applies `dark:` variants.
Both `.dark` and `.light` rulesets are defined in `index.css` with different OKLCH values for all tokens.
---
## Responsive Breakpoints
Standard Tailwind defaults:
| Breakpoint | Min-width | Typical usage |
| ---------- | --------- | -------------------- |
| `sm` | 640 px | 3-col grids |
| `md` | 768 px | 4-col grids, sidebar |
| `lg` | 1024 px | 5-col grids |
| `xl` | 1280 px | 6-col grids |
| `2xl` | 1536 px | 7-col grids |
---
## Animation Utilities
| Class | Effect |
| -------------------- | ------------------------------------------ |
| `animate-page-enter` | Fade + slide-up on page mount |
| `animate-card-enter` | Staggered fade-in for card grids |
| `animate-in fade-in` | Generic fade-in with configurable duration |
Card staggering is achieved via inline `animation-delay` based on the card index.
---
## Component Styling (shadcn/ui)
UI primitives in `src/components/ui/` use:
- `class-variance-authority` (via shadcn internals) for variant props
- `cn()` utility (`src/lib/utils.ts`) = `clsx` + `tailwind-merge` for conflict-free class composition
- All colours reference CSS custom property tokens, not hard-coded values
+30
View File
@@ -0,0 +1,30 @@
# Tech Stack
| Category | Technology | Version |
| --------------------- | --------------------------- | ------- |
| **Framework** | React | 19 |
| **Build Tool** | Vite | 8 |
| **Language** | TypeScript | 5.9 |
| **Styling** | Tailwind CSS | 4 |
| **Component Library** | shadcn/ui (base-nova style) | — |
| **Icons** | Lucide React | 1.7 |
| **State Management** | Zustand | 5 |
| **Server State** | TanStack React Query | 5 |
| **Routing** | React Router | 7 |
| **HTTP Client** | Axios | 1.14 |
| **Forms** | React Hook Form | 7 |
| **Validation** | Zod | 4 |
| **Charts** | Recharts | 3.8 |
| **Date Utilities** | date-fns | 4 |
| **Toasts** | Sonner | 2 |
---
## Key Design Decisions
- **Zustand** for synchronous client state (library cache, theme) — avoids prop drilling and provides instant updates across components.
- **React Query** for all server state — handles caching, background refetching, pagination (infinite queries), and mutation invalidation.
- **shadcn/ui** — copy-pasted, customizable primitives (not a package dependency). Located in `src/components/ui/`.
- **Tailwind CSS 4** — utility-first styling with design tokens defined as CSS custom properties in OKLCH colour space.
- **Vite** — fast HMR, native ESM, and simple proxy configuration for the backend API.
- **Lazy-loaded pages** via `React.lazy()` + `Suspense` — each page is code-split for faster initial load.