From 1058274a6a754f59d56ae3f75f58b84bd327fc77 Mon Sep 17 00:00:00 2001 From: Mohammed Abad Date: Wed, 22 Apr 2026 02:09:10 +0100 Subject: [PATCH] Initiated the obsidian vault --- docs-vault/.gitignore | 2 ++ docs-vault/Architecture.md | 23 +++++++++++++++++++++++ docs-vault/Backend.md | 26 ++++++++++++++++++++++++++ docs-vault/Changelog.md | 16 ++++++++++++++++ docs-vault/Database.md | 21 +++++++++++++++++++++ docs-vault/Deployment.md | 12 ++++++++++++ docs-vault/Electron.md | 11 +++++++++++ docs-vault/Env.md | 16 ++++++++++++++++ docs-vault/Frontend.md | 32 ++++++++++++++++++++++++++++++++ docs-vault/Index.md | 20 ++++++++++++++++++++ docs-vault/Navigation.md | 25 +++++++++++++++++++++++++ docs-vault/Settings Page.md | 32 ++++++++++++++++++++++++++++++++ docs-vault/Statistics.md | 26 ++++++++++++++++++++++++++ 13 files changed, 262 insertions(+) create mode 100644 docs-vault/.gitignore create mode 100644 docs-vault/Architecture.md create mode 100644 docs-vault/Backend.md create mode 100644 docs-vault/Changelog.md create mode 100644 docs-vault/Database.md create mode 100644 docs-vault/Deployment.md create mode 100644 docs-vault/Electron.md create mode 100644 docs-vault/Env.md create mode 100644 docs-vault/Frontend.md create mode 100644 docs-vault/Index.md create mode 100644 docs-vault/Navigation.md create mode 100644 docs-vault/Settings Page.md create mode 100644 docs-vault/Statistics.md diff --git a/docs-vault/.gitignore b/docs-vault/.gitignore new file mode 100644 index 0000000..a6bdbb1 --- /dev/null +++ b/docs-vault/.gitignore @@ -0,0 +1,2 @@ +.trash +.obsidian diff --git a/docs-vault/Architecture.md b/docs-vault/Architecture.md new file mode 100644 index 0000000..b329489 --- /dev/null +++ b/docs-vault/Architecture.md @@ -0,0 +1,23 @@ +# Architecture + +## Overview + +Showy is a media tracking application with three main layers: + +- **[[Backend]]** — Node.js + Express REST API with Sequelize ORM and MySQL +- **[[Frontend]]** — React 18 + TypeScript SPA (Vite, TanStack Query, Zustand, shadcn/ui) +- **[[Electron]]** — Desktop wrapper using Electron + +## Key Flows + +- Library data is fetched on app load into a Zustand store (`useLibraryStore`) +- Pages use TanStack Query hooks for server state (seasons, episodes, statistics) +- Dashboard charts consume statistics endpoints and library store data +- Maintenance/cleanup operations use dedicated backend endpoints + +## Important Files + +- `backend/server.js` — Express app entry point +- `react_frontend/src/App.tsx` — React app entry + router +- `react_frontend/src/stores/useLibraryStore.ts` — Global library state +- `electron/main.js` — Electron main process diff --git a/docs-vault/Backend.md b/docs-vault/Backend.md new file mode 100644 index 0000000..2bc41ad --- /dev/null +++ b/docs-vault/Backend.md @@ -0,0 +1,26 @@ +# Backend + +## Overview + +Node.js + Express REST API with Sequelize ORM and MySQL database. + +## Key Endpoints + +- `GET/PUT /settings` — App settings +- `GET/DELETE /maintenance/orphan-files` — Orphan file scan/cleanup +- `GET/DELETE /maintenance/orphan-media-records` — Orphan DB record scan/cleanup +- `GET /statistics/watch-weekday` — Watchday distribution (filtered to EXACT accuracy) +- CRUD endpoints for entries, seasons, episodes, collections, people + +## Important Files + +- `server.js` — Express app setup +- `config/database.js` — Sequelize/MySQL connection +- `config/relations.js` — Model associations +- `controllers/` — Route handlers +- `services/` — Business logic +- `models/` — Sequelize models + +## Known Issues + +- Maintenance service `deleteOrphanFiles` uses synchronous `fs.existsSync` in a loop diff --git a/docs-vault/Changelog.md b/docs-vault/Changelog.md new file mode 100644 index 0000000..696077b --- /dev/null +++ b/docs-vault/Changelog.md @@ -0,0 +1,16 @@ +# Changelog + +## Milestone 001 + +### Backend +- Added accuracy filter (`WHERE accuracy = 'EXACT'`) to [[Statistics]] watchday distribution queries + +### Frontend +- Replaced Calendar popover with native date input in [[EntrySeenDialog]] and [[EpisodeSeenEditDialog]] +- Merged date + accuracy into a single row in both seen dialogs +- [[LibraryGrowthChart]]: uses `createdAt` only, includes all entries (watchlist + library) +- [[SeasonPage]] and [[EpisodePage]]: added `max-w-4xl` width constraint +- Breadcrumbs now show "Title / Season x / Episode x" instead of generic labels — see [[Navigation]] +- Fixed EpisodePage using `seasonId` (DB id) instead of `season.season_number` +- Added cleanup section to [[Settings Page]] for orphan files/media records +- Created `api/maintenance.ts` API client diff --git a/docs-vault/Database.md b/docs-vault/Database.md new file mode 100644 index 0000000..b27d9d6 --- /dev/null +++ b/docs-vault/Database.md @@ -0,0 +1,21 @@ +# Database + +## Overview + +MySQL database named "Showzy", managed by Sequelize ORM. Schema sync uses `{ alter: doUpdate }` where `doUpdate = false` by default. + +## Key Models + +- `Entry` — Movies and TV series +- `Season` — TV seasons (belongs to Entry) +- `Episode` — TV episodes (belongs to Season) +- `EntrySeen` — Movie watch records (has `accuracy` field: EXACT, ESTIMATED, UNKNOWN) +- `EpisodeSeen` — Episode watch records (has `accuracy` field: EXACT, ESTIMATED, UNKNOWN) +- `Media` — Image file references (posters, logos, backdrops, stills) +- `Collection`, `Genre`, `Network`, `People`, `Credit`, `Franchise` + +## Important Files + +- `backend/config/database.js` — Connection config +- `backend/config/relations.js` — Model associations +- `backend/models/` — All Sequelize model definitions diff --git a/docs-vault/Deployment.md b/docs-vault/Deployment.md new file mode 100644 index 0000000..33dfb43 --- /dev/null +++ b/docs-vault/Deployment.md @@ -0,0 +1,12 @@ +# Deployment + +## Overview + +Docker-based deployment using `docker-compose.yml` at project root. + +## Important Files + +- `docker-compose.yml` — Compose orchestration +- `backend/Dockerfile` — Backend container +- `frontend/Dockerfile` — Angular frontend container (legacy) +- `frontend/nginx.conf` — Nginx config for frontend serving diff --git a/docs-vault/Electron.md b/docs-vault/Electron.md new file mode 100644 index 0000000..d5ebc35 --- /dev/null +++ b/docs-vault/Electron.md @@ -0,0 +1,11 @@ +# Electron + +## Overview + +Desktop wrapper using Electron. Entry point: `electron/main.js`. + +## Important Files + +- `electron/main.js` — Main process +- `electron/preload.js` — Preload script +- `electron/package.json` — Electron dependencies diff --git a/docs-vault/Env.md b/docs-vault/Env.md new file mode 100644 index 0000000..df7466c --- /dev/null +++ b/docs-vault/Env.md @@ -0,0 +1,16 @@ +# Environment Variables + +## Overview + +Configuration is managed via `backend/settings.json` (see `settings.json.example`). + +## Key Settings + +- `tmdbApiKey` — TMDB API key for metadata fetching +- `backPort` — Backend server port +- Database connection configured in `backend/config/database.js` + +## Important Files + +- `backend/settings.json.example` — Template +- `backend/config/database.js` — DB connection config diff --git a/docs-vault/Frontend.md b/docs-vault/Frontend.md new file mode 100644 index 0000000..322f51b --- /dev/null +++ b/docs-vault/Frontend.md @@ -0,0 +1,32 @@ +# Frontend + +## Overview + +React 18 + TypeScript SPA built with Vite. Uses shadcn/ui for components, TanStack Query for server state, Zustand for client state, and Recharts for charts. + +## Key Patterns + +- **State Management**: `useLibraryStore` (Zustand) holds all entries; TanStack Query for server data +- **Forms**: react-hook-form + zod for validation +- **Routing**: React Router v6 with nested routes +- **Styling**: Tailwind CSS + shadcn/ui components + +## Important Pages + +- **Dashboard** — [[Statistics]] charts (CouchDayChart, LibraryGrowthChart) +- **Entry Details** — Entry info, seasons list, watch history +- **[[SeasonPage]]** — Season episodes with watch progress +- **[[EpisodePage]]** — Episode details with prev/next navigation +- **[[Settings Page]]** — App config + maintenance cleanup + +## Navigation + +See [[Navigation]] for breadcrumb patterns. + +## API Clients + +Located in `react_frontend/src/api/`: +- `settings.ts` — Settings CRUD +- `maintenance.ts` — Orphan file/record scan and cleanup +- `seasons.ts` — Season and episode data +- `entries.ts` — Entry CRUD diff --git a/docs-vault/Index.md b/docs-vault/Index.md new file mode 100644 index 0000000..ce790cf --- /dev/null +++ b/docs-vault/Index.md @@ -0,0 +1,20 @@ +# Showy Documentation Vault + +Welcome to the Showy project documentation. Use the links below to navigate. + +## Core Documentation + +- [[Architecture]] +- [[Frontend]] +- [[Backend]] +- [[Electron]] +- [[Database]] +- [[Deployment]] +- [[Env]] +- [[Changelog]] + +## Quick Links + +- [[Settings Page]] — App settings and maintenance cleanup +- [[Statistics]] — Dashboard charts and data queries +- [[Navigation]] — Breadcrumb and page navigation patterns diff --git a/docs-vault/Navigation.md b/docs-vault/Navigation.md new file mode 100644 index 0000000..5e15798 --- /dev/null +++ b/docs-vault/Navigation.md @@ -0,0 +1,25 @@ +# Navigation + +## Overview + +Breadcrumb-style navigation for detail pages. Pages use linked text segments separated by `/`. + +## Patterns + +### SeasonPage +`Title / Season x` +- "Title" links to `/entry/:entryId` +- "Season x" is the current page (non-linked, bold) +- Entry title fetched from `useLibraryStore` + +### EpisodePage +`Title / Season x / Episode x` +- "Title" links to `/entry/:entryId` +- "Season x" links to `/entry/:entryId/season/:seasonId` +- "Episode x" is the current page (non-linked, bold) +- Uses `useSeason()` hook to get `season_number` (not the DB `seasonId`) +- Entry title fetched from `useLibraryStore` + +## Width Constraints + +Detail pages (EntryDetailsPage, [[SeasonPage]], [[EpisodePage]]) use `mx-auto max-w-4xl` for consistent max width. diff --git a/docs-vault/Settings Page.md b/docs-vault/Settings Page.md new file mode 100644 index 0000000..8c38ef5 --- /dev/null +++ b/docs-vault/Settings Page.md @@ -0,0 +1,32 @@ +# Settings Page + +## Overview + +App configuration and maintenance tools at `/settings`. + +## Sections + +### General Settings +- **TMDB API Key** — Required for media metadata lookups +- **Backend Port** — Port the backend server runs on + +### Cleanup +Added in Milestone 001. Uses [[Backend]] maintenance endpoints. + +#### Orphan Files +- **Scan** (`GET /maintenance/orphan-files`) — Dry run, returns counts of orphan files by type +- **Delete** (`DELETE /maintenance/orphan-files`) — Removes orphan files from disk + +#### Orphan Media Records +- **Scan** (`GET /maintenance/orphan-media-records`) — Dry run, returns counts of DB records with no file +- **Delete** (`DELETE /maintenance/orphan-media-records`) — Removes orphan records from database + +### Response Format +Both endpoints return: `{ posters: number, logos: number, backdrops: number, stills: number }` + +## Important Files + +- `react_frontend/src/pages/SettingsPage.tsx` +- `react_frontend/src/api/maintenance.ts` +- `backend/controllers/maintenanceController.js` +- `backend/services/maintenanceService.js` diff --git a/docs-vault/Statistics.md b/docs-vault/Statistics.md new file mode 100644 index 0000000..c7e6af2 --- /dev/null +++ b/docs-vault/Statistics.md @@ -0,0 +1,26 @@ +# Statistics + +## Overview + +Dashboard charts powered by [[Backend]] statistics endpoints and the library store. + +## Charts + +### CouchDayChart +- Shows watch distribution by day of week (bar chart) +- Endpoint: `GET /statistics/watch-weekday` +- **Only counts records with `accuracy = 'EXACT'`** (Milestone 001) +- Queries both `EpisodeSeen` and `EntrySeen` tables + +### LibraryGrowthChart +- Shows cumulative library growth over time (area chart) +- Data source: Library store entries (client-side computation) +- Uses `createdAt` field as the entry date (Milestone 001) +- Includes all entries (library + watchlist) +- Supports year filter with "All" option + +## Important Files + +- `react_frontend/src/components/dashboard/CouchDayChart.tsx` +- `react_frontend/src/components/dashboard/LibraryGrowthChart.tsx` +- `backend/controllers/statisticsController.js` — `getWatchdayDistribution` method