# dinura99-del/onflixcmslk architecture

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

- Interactive diagram: https://gitdiagram.com/dinura99-del/onflixcmslk
- Repository: https://github.com/dinura99-del/onflixcmslk

## Overview

Onflix Automate is an admin dashboard and backend for discovering releases and automating Sinhala subtitle preparation. Admins configure filters, inspect the queue, trigger scans or processing, and manage subtitles; cron endpoints offer automated triggers. The documented worker stages cover release discovery, availability and subtitle checks, translation, storage, and OnFlix updates. The graph combines sampled calls and imports with explicitly documented capabilities; several integrations and dashboard sections are documented but their implementation was not sampled.

Main entry points: [`src/lib/engine.server.ts`](https://github.com/dinura99-del/onflixcmslk/blob/main/src/lib/engine.server.ts) (Automation engine), [`src/routes/index.tsx`](https://github.com/dinura99-del/onflixcmslk/blob/main/src/routes/index.tsx) (Admin dashboard), [`src/lib/admin.functions.ts`](https://github.com/dinura99-del/onflixcmslk/blob/main/src/lib/admin.functions.ts) (Admin operations), [`src/routes/api/public/copilot/chat.ts`](https://github.com/dinura99-del/onflixcmslk/blob/main/src/routes/api/public/copilot/chat.ts) (AI Co-Pilot API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_dashboard["Admin dashboard"]
  node_admin["Admin dashboard<br/>[index.tsx]"]
  node_tmdbview["TMDB explorer"]
  node_analytics["Analytics view<br/>[AnalyticsView.tsx]"]
  node_keyhealth["Key health view"]
  node_subtitleeditor["Subtitle editor"]
  node_polishvisualizer["Polish visualizer"]
end

subgraph group_automation["Queue automation"]
  node_engine["Automation engine<br/>[engine.server.ts]"]
  node_scanner["TMDB scanning<br/>[engine.server.ts]"]
  node_releaseprocessor["Release processing<br/>[engine.server.ts]"]
  node_queue[("Automation queue")]
  node_cron_scan["Scan endpoint<br/>[scan.ts]"]
  node_cron_process["Process endpoint<br/>[process.ts]"]
  node_manualstream["Manual progress stream<br/>[stream.ts]"]
end

subgraph group_translation["Subtitle translation"]
  node_translationengine["Gemini translation"]
  node_prompts["AI prompts<br/>[ai-prompts.ts]"]
  node_srtutils["SRT utilities<br/>[srt-utils.ts]"]
end

subgraph group_operations["Admin tools and APIs"]
  node_adminfunctions["Admin operations<br/>[admin.functions.ts]"]
  node_copilot["AI Co-Pilot API<br/>[chat.ts]"]
  node_keyhealthservice["Key health service"]
  node_copilotprompts["Co-Pilot prompts<br/>[ai-prompts.ts]"]
end

node_adminactor(("Administrator"))
node_cronactor(("External cron"))
node_supabase[("Supabase")]
node_onflix[("OnFlix catalog")]
node_tmdb["TMDB"]
node_embedmaster["EmbedMaster"]
node_wyzie["Wyzie subtitles"]
node_gemini["Gemini API"]
node_translationfallbacks["Translation fallbacks"]
node_storage[("Supabase Storage")]
node_tavily["Tavily search"]

node_adminactor -->|"uses dashboard"| node_admin
node_admin -->|"requests operations"| node_adminfunctions
node_admin -->|"renders view"| node_tmdbview
node_admin -->|"renders view"| node_analytics
node_admin -->|"renders view"| node_keyhealth
node_admin -->|"renders view"| node_subtitleeditor
node_admin -->|"renders view"| node_polishvisualizer
node_tmdbview -->|"searches and tracks"| node_adminfunctions
node_subtitleeditor -->|"loads and saves"| node_adminfunctions
node_subtitleeditor -->|"parses and formats"| node_srtutils
node_adminfunctions -->|"authorizes and delegates"| node_engine
node_keyhealth -->|"requests key data"| node_adminfunctions
node_keyhealth -->|"uses service"| node_keyhealthservice
node_engine -->|"translates cues"| node_translationengine
node_translationengine -->|"uses prompts"| node_prompts
node_cronactor -->|"triggers scan"| node_cron_scan
node_cronactor -->|"triggers processing"| node_cron_process
node_cron_scan -->|"invokes scan"| node_engine
node_cron_process -->|"invokes processing"| node_engine
node_manualstream -->|"streams manual run"| node_engine
node_engine -->|"reads and updates jobs"| node_queue
node_engine -->|"discovers releases"| node_tmdb
node_engine -->|"checks availability"| node_embedmaster
node_engine -->|"fetches English SRT"| node_wyzie
node_translationengine -->|"translates cues"| node_gemini
node_engine -->|"falls back per line"| node_translationfallbacks
node_engine -->|"uploads Sinhala SRT"| node_storage
node_engine -->|"updates catalog"| node_onflix
node_copilot -->|"builds prompt"| node_copilotprompts
node_adminactor -->|"asks Co-Pilot"| node_copilot
node_copilot -->|"reads and updates data"| node_supabase
node_copilot -.->|"searches web"| node_tavily
node_keyhealthservice -->|"checks translation keys"| node_translationengine
node_keyhealthservice -->|"checks engine keys"| node_engine

click node_admin "https://github.com/dinura99-del/onflixcmslk/blob/main/src/routes/index.tsx"
click node_tmdbview "https://github.com/dinura99-del/onflixcmslk/blob/main/src/components/TmdbExplorerView.tsx"
click node_analytics "https://github.com/dinura99-del/onflixcmslk/blob/main/src/components/AnalyticsView.tsx"
click node_keyhealth "https://github.com/dinura99-del/onflixcmslk/blob/main/src/components/KeyHealthDashboardView.tsx"
click node_subtitleeditor "https://github.com/dinura99-del/onflixcmslk/blob/main/src/components/SubtitleEditorView.tsx"
click node_polishvisualizer "https://github.com/dinura99-del/onflixcmslk/blob/main/src/components/PolishVisualizer.tsx"
click node_adminfunctions "https://github.com/dinura99-del/onflixcmslk/blob/main/src/lib/admin.functions.ts"
click node_engine "https://github.com/dinura99-del/onflixcmslk/blob/main/src/lib/engine.server.ts"
click node_scanner "https://github.com/dinura99-del/onflixcmslk/blob/main/src/lib/engine.server.ts"
click node_releaseprocessor "https://github.com/dinura99-del/onflixcmslk/blob/main/src/lib/engine.server.ts"
click node_translationengine "https://github.com/dinura99-del/onflixcmslk/blob/main/src/lib/gemini-polish.server.ts"
click node_prompts "https://github.com/dinura99-del/onflixcmslk/blob/main/src/lib/ai-prompts.ts"
click node_srtutils "https://github.com/dinura99-del/onflixcmslk/blob/main/src/lib/srt-utils.ts"
click node_cron_scan "https://github.com/dinura99-del/onflixcmslk/blob/main/src/routes/api/public/cron/scan.ts"
click node_cron_process "https://github.com/dinura99-del/onflixcmslk/blob/main/src/routes/api/public/cron/process.ts"
click node_manualstream "https://github.com/dinura99-del/onflixcmslk/blob/main/src/routes/api/public/manual/stream.ts"
click node_copilot "https://github.com/dinura99-del/onflixcmslk/blob/main/src/routes/api/public/copilot/chat.ts"
click node_keyhealthservice "https://github.com/dinura99-del/onflixcmslk/blob/main/src/lib/key-health.server.ts"
click node_copilotprompts "https://github.com/dinura99-del/onflixcmslk/blob/main/src/lib/ai-prompts.ts"

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_admin,node_tmdbview,node_analytics,node_keyhealth,node_subtitleeditor,node_polishvisualizer toneBlue
class node_engine,node_scanner,node_releaseprocessor,node_queue,node_cron_scan,node_cron_process,node_manualstream,node_supabase,node_onflix,node_storage toneAmber
class node_translationengine,node_prompts,node_srtutils,node_gemini toneMint
class node_adminfunctions,node_copilot,node_keyhealthservice,node_copilotprompts toneRose
class node_adminactor,node_cronactor,node_tmdb,node_embedmaster,node_wyzie,node_translationfallbacks,node_tavily toneIndigo
```

## Components

### Admin dashboard

- [Admin dashboard](https://github.com/dinura99-del/onflixcmslk/blob/main/src/routes/index.tsx): `src/routes/index.tsx`
- [TMDB explorer](https://github.com/dinura99-del/onflixcmslk/blob/main/src/components/TmdbExplorerView.tsx): `src/components/TmdbExplorerView.tsx`
- [Analytics view](https://github.com/dinura99-del/onflixcmslk/blob/main/src/components/AnalyticsView.tsx): `src/components/AnalyticsView.tsx`
- [Key health view](https://github.com/dinura99-del/onflixcmslk/blob/main/src/components/KeyHealthDashboardView.tsx): `src/components/KeyHealthDashboardView.tsx`
- [Subtitle editor](https://github.com/dinura99-del/onflixcmslk/blob/main/src/components/SubtitleEditorView.tsx): `src/components/SubtitleEditorView.tsx`
- [Polish visualizer](https://github.com/dinura99-del/onflixcmslk/blob/main/src/components/PolishVisualizer.tsx): `src/components/PolishVisualizer.tsx`

### Queue automation

- [Automation engine](https://github.com/dinura99-del/onflixcmslk/blob/main/src/lib/engine.server.ts): `src/lib/engine.server.ts`
- [TMDB scanning](https://github.com/dinura99-del/onflixcmslk/blob/main/src/lib/engine.server.ts): `src/lib/engine.server.ts`
- [Release processing](https://github.com/dinura99-del/onflixcmslk/blob/main/src/lib/engine.server.ts): `src/lib/engine.server.ts`
- **Automation queue**
- [Scan endpoint](https://github.com/dinura99-del/onflixcmslk/blob/main/src/routes/api/public/cron/scan.ts): `src/routes/api/public/cron/scan.ts`
- [Process endpoint](https://github.com/dinura99-del/onflixcmslk/blob/main/src/routes/api/public/cron/process.ts): `src/routes/api/public/cron/process.ts`
- [Manual progress stream](https://github.com/dinura99-del/onflixcmslk/blob/main/src/routes/api/public/manual/stream.ts): `src/routes/api/public/manual/stream.ts`

### Subtitle translation

- [Gemini translation](https://github.com/dinura99-del/onflixcmslk/blob/main/src/lib/gemini-polish.server.ts): `src/lib/gemini-polish.server.ts`
- [AI prompts](https://github.com/dinura99-del/onflixcmslk/blob/main/src/lib/ai-prompts.ts): `src/lib/ai-prompts.ts`
- [SRT utilities](https://github.com/dinura99-del/onflixcmslk/blob/main/src/lib/srt-utils.ts): `src/lib/srt-utils.ts`

### Admin tools and APIs

- [Admin operations](https://github.com/dinura99-del/onflixcmslk/blob/main/src/lib/admin.functions.ts): `src/lib/admin.functions.ts`
- [AI Co-Pilot API](https://github.com/dinura99-del/onflixcmslk/blob/main/src/routes/api/public/copilot/chat.ts): `src/routes/api/public/copilot/chat.ts`
- [Key health service](https://github.com/dinura99-del/onflixcmslk/blob/main/src/lib/key-health.server.ts): `src/lib/key-health.server.ts`
- [Co-Pilot prompts](https://github.com/dinura99-del/onflixcmslk/blob/main/src/lib/ai-prompts.ts): `src/lib/ai-prompts.ts`

### Other components

- **Administrator**
- **External cron**
- **Supabase**
- **OnFlix catalog**
- **TMDB**
- **EmbedMaster**
- **Wyzie subtitles**
- **Gemini API**
- **Translation fallbacks**
- **Supabase Storage**
- **Tavily search**

## Connections

- Administrator → Admin dashboard: uses dashboard (evidence: `src/routes/index.tsx`)
- Admin dashboard → Admin operations: requests operations (evidence: `src/routes/index.tsx`)
- Admin dashboard → TMDB explorer: renders view (evidence: `src/routes/index.tsx`)
- Admin dashboard → Analytics view: renders view (evidence: `src/routes/index.tsx`)
- Admin dashboard → Key health view: renders view (evidence: `src/routes/index.tsx`)
- Admin dashboard → Subtitle editor: renders view (evidence: `src/routes/index.tsx`)
- Admin dashboard → Polish visualizer: renders view (evidence: `src/routes/index.tsx`)
- TMDB explorer → Admin operations: searches and tracks (evidence: `src/components/TmdbExplorerView.tsx`)
- Subtitle editor → Admin operations: loads and saves (evidence: `src/components/SubtitleEditorView.tsx`)
- Subtitle editor → SRT utilities: parses and formats (evidence: `src/components/SubtitleEditorView.tsx`)
- Admin operations → Automation engine: authorizes and delegates (evidence: `src/lib/admin.functions.ts`)
- Key health view → Admin operations: requests key data (evidence: `src/components/KeyHealthDashboardView.tsx`)
- Key health view → Key health service: uses service (evidence: `src/components/KeyHealthDashboardView.tsx`)
- Automation engine → Gemini translation: translates cues (evidence: `src/lib/engine.server.ts`)
- Gemini translation → AI prompts: uses prompts (evidence: `src/lib/gemini-polish.server.ts`)
- External cron → Scan endpoint: triggers scan (evidence: `README.md`)
- External cron → Process endpoint: triggers processing (evidence: `README.md`)
- Scan endpoint → Automation engine: invokes scan (evidence: `src/routes/api/public/cron/scan.ts`)
- Process endpoint → Automation engine: invokes processing (evidence: `src/routes/api/public/cron/process.ts`)
- Manual progress stream → Automation engine: streams manual run (evidence: `src/routes/api/public/manual/stream.ts`)
- Automation engine → Automation queue: reads and updates jobs (evidence: `README.md`)
- Automation engine → TMDB: discovers releases (evidence: `README.md`)
- Automation engine → EmbedMaster: checks availability (evidence: `README.md`)
- Automation engine → Wyzie subtitles: fetches English SRT (evidence: `README.md`)
- Gemini translation → Gemini API: translates cues (evidence: `README.md`)
- Automation engine → Translation fallbacks: falls back per line (evidence: `README.md`)
- Automation engine → Supabase Storage: uploads Sinhala SRT (evidence: `README.md`)
- Automation engine → OnFlix catalog: updates catalog (evidence: `README.md`)
- AI Co-Pilot API → Co-Pilot prompts: builds prompt (evidence: `src/routes/api/public/copilot/chat.ts`)
- Administrator → AI Co-Pilot API: asks Co-Pilot (evidence: `README.md`)
- AI Co-Pilot API → Supabase: reads and updates data (evidence: `src/routes/api/public/copilot/chat.ts`)
- AI Co-Pilot API → Tavily search: searches web (evidence: `README.md`)
- Key health service → Gemini translation: checks translation keys (evidence: `src/lib/key-health.server.ts`)
- Key health service → Automation engine: checks engine keys (evidence: `src/lib/key-health.server.ts`)
