# baophamdev/webxemphim architecture

> Architecture diagram of the GitHub repository baophamdev/webxemphim, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-06). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/baophamdev/webxemphim
- Repository: https://github.com/baophamdev/webxemphim

## Overview

BảoNhànCinema is a personal film-browsing and streaming application: a React web client discovers films, opens details, and plays source-provided streams; an Express API resolves catalog data and persists it in PostgreSQL. The README also documents device-local watch progress and favorites, subtitle support, and Android/TV clients. The graph preserves these capabilities; some connections for unsampled pages and API routes are based on README statements or SOURCE INDEX references rather than inspected implementations.

Main entry points: [`apps/web/src/App.tsx`](https://github.com/baophamdev/webxemphim/blob/main/apps/web/src/App.tsx) (Web app), [`services/api/src/server.ts`](https://github.com/baophamdev/webxemphim/blob/main/services/api/src/server.ts) (Express API), [`apps/web/src/api.ts`](https://github.com/baophamdev/webxemphim/blob/main/apps/web/src/api.ts) (API client), [`apps/web/src/pages/Watch.tsx`](https://github.com/baophamdev/webxemphim/blob/main/apps/web/src/pages/Watch.tsx) (Playback)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web experience"]
  node_webapp["Web app<br/>[App.tsx]"]
  node_discovery["Browse and search<br/>[Browse.tsx]"]
  node_detail["Film details<br/>[Detail.tsx]"]
  node_watch["Playback<br/>[Watch.tsx]"]
  node_subtitles["Subtitle controls<br/>[useSubtitles.ts]"]
  node_api_client["API client<br/>[api.ts]"]
  node_remote_nguonc["NguonC browser access<br/>[nguonc.ts]"]
end

subgraph group_clientdata["Client data"]
  node_library["Library model<br/>[library.ts]"]
  node_library_store[("Local library storage<br/>[libraryStore.ts]")]
  node_subtitle_store[("Subtitle storage<br/>[store.ts]")]
end

subgraph group_backend["Catalog API"]
  node_api_server["Express API<br/>[server.ts]"]
  node_importer["Background importer<br/>[importer.ts]"]
  node_resolver["Catalog resolver<br/>[index.ts]"]
  node_normalizer["Provider normalization<br/>[normalize.ts]"]
  node_provider_adapters["Catalog adapters"]
end

subgraph group_storage["Persistence"]
  node_postgres[("PostgreSQL<br/>[db.ts]")]
end

subgraph group_clients["Device clients"]
  node_android["Android WebView app<br/>[MainActivity.java]"]
  node_tv_remote["TV remote controls<br/>[tv-remote.js]"]
end

node_viewer(("Viewer"))
node_catalog_sources["Catalog services"]
node_database_service[("Supabase PostgreSQL")]

node_viewer -->|"uses"| node_webapp
node_webapp -->|"routes to"| node_discovery
node_webapp -->|"routes to"| node_detail
node_webapp -->|"routes to"| node_watch
node_discovery -->|"requests catalog"| node_api_client
node_detail -->|"loads film data"| node_api_client
node_watch -->|"requests playback data"| node_api_client
node_api_client -->|"calls"| node_api_server
node_api_client -->|"falls back to"| node_remote_nguonc
node_remote_nguonc -.->|"queries directly"| node_catalog_sources
node_watch -->|"uses"| node_subtitles
node_subtitles -->|"reads and writes"| node_subtitle_store
node_watch -->|"records progress"| node_library_store
node_library_store -->|"uses model"| node_library
node_api_server -->|"reads and writes"| node_postgres
node_api_server -->|"starts jobs"| node_importer
node_api_server -->|"requests catalog"| node_resolver
node_importer -.->|"loads catalog data"| node_resolver
node_resolver -->|"dispatches requests"| node_provider_adapters
node_provider_adapters -->|"normalizes responses"| node_normalizer
node_provider_adapters -->|"fetches catalog"| node_catalog_sources
node_postgres -->|"connects to"| node_database_service
node_viewer -->|"uses"| node_android
node_android -->|"fetches film data"| node_api_server
node_viewer -->|"uses remote"| node_tv_remote
node_tv_remote -.->|"controls"| node_webapp

click node_webapp "https://github.com/baophamdev/webxemphim/blob/main/apps/web/src/App.tsx"
click node_discovery "https://github.com/baophamdev/webxemphim/blob/main/apps/web/src/pages/Browse.tsx"
click node_detail "https://github.com/baophamdev/webxemphim/blob/main/apps/web/src/pages/Detail.tsx"
click node_watch "https://github.com/baophamdev/webxemphim/blob/main/apps/web/src/pages/Watch.tsx"
click node_subtitles "https://github.com/baophamdev/webxemphim/blob/main/apps/web/src/subs/useSubtitles.ts"
click node_api_client "https://github.com/baophamdev/webxemphim/blob/main/apps/web/src/api.ts"
click node_remote_nguonc "https://github.com/baophamdev/webxemphim/blob/main/apps/web/src/nguonc.ts"
click node_library "https://github.com/baophamdev/webxemphim/blob/main/apps/web/src/library.ts"
click node_library_store "https://github.com/baophamdev/webxemphim/blob/main/apps/web/src/libraryStore.ts"
click node_subtitle_store "https://github.com/baophamdev/webxemphim/blob/main/apps/web/src/subs/store.ts"
click node_api_server "https://github.com/baophamdev/webxemphim/blob/main/services/api/src/server.ts"
click node_importer "https://github.com/baophamdev/webxemphim/blob/main/services/api/src/importer.ts"
click node_resolver "https://github.com/baophamdev/webxemphim/blob/main/services/api/src/providers/index.ts"
click node_normalizer "https://github.com/baophamdev/webxemphim/blob/main/services/api/src/providers/normalize.ts"
click node_provider_adapters "https://github.com/baophamdev/webxemphim/tree/main/services/api/src/providers"
click node_postgres "https://github.com/baophamdev/webxemphim/blob/main/services/api/src/db.ts"
click node_android "https://github.com/baophamdev/webxemphim/blob/main/android/app/src/main/java/com/localcinema/android/MainActivity.java"
click node_tv_remote "https://github.com/baophamdev/webxemphim/blob/main/apps/web/public/tv/tv-remote.js"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_webapp,node_discovery,node_detail,node_watch,node_subtitles,node_api_client,node_remote_nguonc,node_viewer toneBlue
class node_library,node_library_store,node_subtitle_store,node_database_service toneAmber
class node_api_server,node_importer,node_resolver,node_normalizer,node_provider_adapters toneMint
class node_postgres toneRose
class node_android,node_tv_remote,node_catalog_sources toneIndigo
```

## Components

### Web experience

- [Web app](https://github.com/baophamdev/webxemphim/blob/main/apps/web/src/App.tsx): `apps/web/src/App.tsx`
- [Browse and search](https://github.com/baophamdev/webxemphim/blob/main/apps/web/src/pages/Browse.tsx): `apps/web/src/pages/Browse.tsx`
- [Film details](https://github.com/baophamdev/webxemphim/blob/main/apps/web/src/pages/Detail.tsx): `apps/web/src/pages/Detail.tsx`
- [Playback](https://github.com/baophamdev/webxemphim/blob/main/apps/web/src/pages/Watch.tsx): `apps/web/src/pages/Watch.tsx`
- [Subtitle controls](https://github.com/baophamdev/webxemphim/blob/main/apps/web/src/subs/useSubtitles.ts): `apps/web/src/subs/useSubtitles.ts`
- [API client](https://github.com/baophamdev/webxemphim/blob/main/apps/web/src/api.ts): `apps/web/src/api.ts`
- [NguonC browser access](https://github.com/baophamdev/webxemphim/blob/main/apps/web/src/nguonc.ts): `apps/web/src/nguonc.ts`

### Client data

- [Library model](https://github.com/baophamdev/webxemphim/blob/main/apps/web/src/library.ts): `apps/web/src/library.ts`
- [Local library storage](https://github.com/baophamdev/webxemphim/blob/main/apps/web/src/libraryStore.ts): `apps/web/src/libraryStore.ts`
- [Subtitle storage](https://github.com/baophamdev/webxemphim/blob/main/apps/web/src/subs/store.ts): `apps/web/src/subs/store.ts`

### Catalog API

- [Express API](https://github.com/baophamdev/webxemphim/blob/main/services/api/src/server.ts): `services/api/src/server.ts`
- [Background importer](https://github.com/baophamdev/webxemphim/blob/main/services/api/src/importer.ts): `services/api/src/importer.ts`
- [Catalog resolver](https://github.com/baophamdev/webxemphim/blob/main/services/api/src/providers/index.ts): `services/api/src/providers/index.ts`
- [Provider normalization](https://github.com/baophamdev/webxemphim/blob/main/services/api/src/providers/normalize.ts): `services/api/src/providers/normalize.ts`
- [Catalog adapters](https://github.com/baophamdev/webxemphim/tree/main/services/api/src/providers): `services/api/src/providers`

### Persistence

- [PostgreSQL](https://github.com/baophamdev/webxemphim/blob/main/services/api/src/db.ts): `services/api/src/db.ts`

### Device clients

- [Android WebView app](https://github.com/baophamdev/webxemphim/blob/main/android/app/src/main/java/com/localcinema/android/MainActivity.java): `android/app/src/main/java/com/localcinema/android/MainActivity.java`
- [TV remote controls](https://github.com/baophamdev/webxemphim/blob/main/apps/web/public/tv/tv-remote.js): `apps/web/public/tv/tv-remote.js`

### Other components

- **Viewer**
- **Catalog services**
- **Supabase PostgreSQL**

## Connections

- Viewer → Web app: uses (evidence: `README.md`)
- Web app → Browse and search: routes to (evidence: `apps/web/src/App.tsx`)
- Web app → Film details: routes to (evidence: `apps/web/src/App.tsx`)
- Web app → Playback: routes to (evidence: `apps/web/src/App.tsx`)
- Browse and search → API client: requests catalog
- Film details → API client: loads film data (evidence: `apps/web/src/api.ts`)
- Playback → API client: requests playback data (evidence: `apps/web/src/pages/Watch.tsx`)
- API client → Express API: calls (evidence: `README.md`)
- API client → NguonC browser access: falls back to (evidence: `apps/web/src/api.ts`)
- NguonC browser access → Catalog services: queries directly
- Playback → Subtitle controls: uses (evidence: `apps/web/src/pages/Watch.tsx`)
- Subtitle controls → Subtitle storage: reads and writes (evidence: `apps/web/src/subs/useSubtitles.ts`)
- Playback → Local library storage: records progress (evidence: `apps/web/src/pages/Watch.tsx`)
- Local library storage → Library model: uses model (evidence: `apps/web/src/libraryStore.ts`)
- Express API → PostgreSQL: reads and writes (evidence: `services/api/src/server.ts`)
- Express API → Background importer: starts jobs (evidence: `services/api/src/server.ts`)
- Express API → Catalog resolver: requests catalog (evidence: `services/api/src/server.ts`)
- Background importer → Catalog resolver: loads catalog data (evidence: `services/api/src/server.ts`)
- Catalog resolver → Catalog adapters: dispatches requests (evidence: `services/api/src/providers/index.ts`)
- Catalog adapters → Provider normalization: normalizes responses (evidence: `services/api/src/providers/kkphim.ts`)
- Catalog adapters → Catalog services: fetches catalog (evidence: `README.md`)
- PostgreSQL → Supabase PostgreSQL: connects to (evidence: `README.md`)
- Viewer → Android WebView app: uses (evidence: `README.md`)
- Android WebView app → Express API: fetches film data (evidence: `README.md`)
- Viewer → TV remote controls: uses remote (evidence: `README.md`)
- TV remote controls → Web app: controls (evidence: `README.md`)
