Updated the Obsidian docs-vault

This commit is contained in:
Mohammed Abad committed 2026-04-22 14:48:43 +01:00
1 parent 72fd77ee01
commit 260282a0e2
36 files changed
+3497 -144

No files matched your search

+110 -14
View File
@@ -1,23 +1,119 @@
---
title: Architecture
tags:
- architecture
- overview
---
# Architecture
## Overview
Showy is a media tracking application with three main layers:
Showy is a **single-user** media tracking application with three deployment 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
| Layer | Technology | Role |
|---|---|---|
| [[Backend]] | Node.js + Express + Sequelize + MySQL | REST API, data persistence, TMDB proxy |
| [[Frontend]] | React 19 + TypeScript + Vite | SPA with shadcn/ui components |
| [[Electron]] | Electron 34 | Desktop wrapper, spawns backend as child process |
## Key Flows
See [[Tech Stack]] for complete version inventory.
- 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
## System Diagram
## Important Files
```mermaid
graph TD
subgraph Desktop["Electron (Desktop)"]
E[Main Process] --> B
E --> FE
end
- `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
subgraph FE["React Frontend"]
Pages[Pages] --> Hooks
Hooks --> APIClients[API Clients]
Hooks --> LibStore[Zustand Library Store]
APIClients --> |Axios| API
end
subgraph B["Backend"]
API[Express Routes] --> Controllers
Controllers --> Services
Services --> Models[Sequelize Models]
Services --> TMDB[TMDB API]
Models --> DB[(MySQL - Showzy)]
end
```
## Data Flow
### Library Loading
1. App mounts → `useLibrary()` hook fires `GET /api/v1/entries`
2. Backend returns all entries with IDs, ratings, genres, networks, media, seasons, seens
3. Response normalized by [[Normalizers]] (`normalizeEntry`)
4. Entries loaded into [[Stores|useLibraryStore]] as `Map<number, Entry>` for O(1) lookup
5. `isLoaded` flag set → pages render
### Adding an Entry
1. User searches TMDB → selects result → `POST /api/v1/entries` with `{tmdb_id, is_tvserie}`
2. [[Services|EntryManager]] orchestrates the full pipeline:
- Fetch from TMDB → save entry + IDs + ratings + genres + networks
- If TV: fetch all seasons/episodes
- Fetch credits (cast/crew)
- Download media (posters, backdrops, logos) → generate previews
- Fetch collection if applicable
3. Response added to Zustand store → UI updates
### Lazy Refresh
- `getEntryById` checks `last_fetch` — if null or >24h old (and series not ended), triggers TMDB refresh
- Same pattern for [[People]] via `getUpdatedPerson`
### Media Serving
1. Frontend requests `/api/v1/media/:category/:type/:size/:fileName`
2. Backend reads from `{userDataPath}/images/...` directory
3. Preview files: `{uuid}_preview.jpg` — full files: `{uuid}.ext`
## File Structure
```
Showy/
├── backend/ → [[Backend]]
│ ├── server.js → Express entry point
│ ├── config/ → DB, relations, hooks, initializer
│ ├── controllers/ → Route handlers
│ ├── services/ → Business logic
│ ├── models/ → Sequelize models → [[Models]]
│ ├── routes/ → Express routers → [[API Reference]]
│ ├── errors/ → Custom errors → [[Error Handling]]
│ ├── middleware/ → Error handler
│ ├── mappers/ → Entry mapper
│ └── utils/ → asyncWrapper, moment
├── react_frontend/ → [[Frontend]]
│ └── src/
│ ├── api/ → Axios clients → [[API Clients]]
│ ├── components/ → UI components → [[Components]]
│ ├── hooks/ → TanStack Query hooks → [[Hooks]]
│ ├── lib/ → Utilities, normalizers
│ ├── pages/ → Route pages → [[Pages]]
│ ├── stores/ → Zustand stores → [[Stores]]
│ └── types/ → TypeScript types → [[Types]]
├── electron/ → [[Electron]]
├── frontend/ → Legacy Angular app (unused)
├── docs-vault/ → This documentation
└── docker-compose.yml → [[Deployment]]
```
## Security Model
> [!warning] No Authentication
> Showy is designed as a single-user local application. There is **no authentication or authorization**. CORS is set to `*`. The TMDB API key is stored server-side in `settings.json`.
## See Also
- [[Backend]] — Server-side details
- [[Frontend]] — Client-side details
- [[Database]] — Data layer
- [[Deployment]] — Docker setup