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