# skywin88/ahahah architecture

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

- Interactive diagram: https://gitdiagram.com/skywin88/ahahah
- Repository: https://github.com/skywin88/ahahah

## Overview

MeoPhim is a movie discovery and streaming product with user accounts, community features, advertising, and an administrative suite. Its principal user journey is browsing the catalog, opening a movie, and watching an episode; the repository also contains substantial catalog synchronization and hero-media processing workflows. The tree and source index establish these product areas, but many page-to-API and URL-to-view connections were not shown, so those relationships are omitted or marked unverified.

Main entry points: [`client/utils/api.ts`](https://github.com/skywin88/ahahah/blob/main/client/utils/api.ts) (API utilities), [`server/core/models`](https://github.com/skywin88/ahahah/tree/main/server/core/models) (Domain records), [`server/core/services/hero_video_pipeline.py`](https://github.com/skywin88/ahahah/blob/main/server/core/services/hero_video_pipeline.py) (Hero video pipeline), [`server/core/services/kkphim_sync_service.py`](https://github.com/skywin88/ahahah/blob/main/server/core/services/kkphim_sync_service.py) (Catalog synchronization)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_browse["Discovery and viewing"]
  node_home["Home discovery<br/>[index.tsx]"]
  node_movie_page["Movie detail"]
  node_player["Cinema player"]
  node_search["Search interface<br/>[Search.tsx]"]
end

subgraph group_community["Accounts and community"]
  node_accounts["Account pages"]
  node_chat["Chat experience<br/>[ChatWidget.tsx]"]
end

subgraph group_admin["Administration"]
  node_admin_ui["Admin suite"]
  node_ad_manager["Ad management"]
  node_ad_preview["Ad preview<br/>[AdLivePreview.tsx]"]
  node_admin_api["Admin operations API"]
  node_hero_admin["Hero banner API"]
end

subgraph group_catalog["Catalog operations"]
  node_catalog_sync["Catalog synchronization"]
  node_crawler["Crawler service<br/>[crawler_service.py]"]
  node_providers["Catalog providers"]
  node_background_tasks["Background tasks<br/>[tasks.py]"]
end

subgraph group_platform["Media and platform"]
  node_api_client["API utilities<br/>[api.ts]"]
  node_domain_data[("Domain records")]
  node_hero_pipeline["Hero video pipeline"]
  node_video_trimmer["Video trimming<br/>[ffmpeg_trimmer.py]"]
  node_storage["Media storage<br/>[storage_service.py]"]
  node_security["Stream security<br/>[security.py]"]
  node_cache["Cache invalidation<br/>[cache_keys.py]"]
  node_cdn["Client CDN routing<br/>[cdn.ts]"]
  node_edge_worker["R2 CDN worker<br/>[r2-cdn-worker.js]"]
end

node_viewer(("Viewer"))

node_viewer -.->|"opens"| node_home
node_viewer -.->|"searches"| node_search
node_viewer -.->|"opens title"| node_movie_page
node_movie_page -.->|"uses player"| node_player
node_home -.->|"requests data"| node_api_client
node_movie_page -.->|"requests data"| node_api_client
node_search -.->|"requests data"| node_api_client
node_accounts -.->|"requests data"| node_api_client
node_admin_ui -.->|"administers"| node_admin_api
node_ad_manager -->|"uses draft"| node_ad_preview
node_admin_api -.->|"manages records"| node_domain_data
node_hero_admin -->|"reads and writes"| node_domain_data
node_hero_admin -->|"queues work"| node_background_tasks
node_background_tasks -->|"runs sync"| node_catalog_sync
node_background_tasks -->|"runs crawl"| node_crawler
node_catalog_sync -->|"fetches catalog"| node_providers
node_catalog_sync -->|"uses crawler"| node_crawler
node_catalog_sync -->|"updates records"| node_domain_data
node_background_tasks -->|"updates records"| node_domain_data
node_hero_pipeline -->|"uploads media"| node_storage
node_hero_pipeline -->|"uses records"| node_domain_data
node_hero_pipeline -->|"validates media"| node_security
node_hero_pipeline -->|"uses cache keys"| node_cache
node_hero_admin -->|"trims previews"| node_video_trimmer
node_video_trimmer -->|"stores output"| node_storage
node_api_client -->|"rewrites media"| node_cdn

click node_home "https://github.com/skywin88/ahahah/blob/main/client/pages/index.tsx"
click node_movie_page "https://github.com/skywin88/ahahah/tree/main/client/pages/movie"
click node_player "https://github.com/skywin88/ahahah/blob/main/client/hooks/useCinemaPlayerEngine.ts"
click node_search "https://github.com/skywin88/ahahah/blob/main/client/components/core/Search.tsx"
click node_api_client "https://github.com/skywin88/ahahah/blob/main/client/utils/api.ts"
click node_accounts "https://github.com/skywin88/ahahah/tree/main/client/pages"
click node_chat "https://github.com/skywin88/ahahah/blob/main/client/components/core/ChatWidget.tsx"
click node_admin_ui "https://github.com/skywin88/ahahah/tree/main/client/components/admin"
click node_ad_manager "https://github.com/skywin88/ahahah/blob/main/client/components/admin/AdsManagerModule.tsx"
click node_ad_preview "https://github.com/skywin88/ahahah/blob/main/client/components/admin/AdLivePreview.tsx"
click node_admin_api "https://github.com/skywin88/ahahah/blob/main/server/core/views/admin_suite_views.py"
click node_hero_admin "https://github.com/skywin88/ahahah/blob/main/server/core/views/hero_banner_views.py"
click node_catalog_sync "https://github.com/skywin88/ahahah/blob/main/server/core/services/kkphim_sync_service.py"
click node_crawler "https://github.com/skywin88/ahahah/blob/main/server/core/services/crawler_service.py"
click node_providers "https://github.com/skywin88/ahahah/tree/main/server/core/providers"
click node_background_tasks "https://github.com/skywin88/ahahah/blob/main/server/core/tasks.py"
click node_domain_data "https://github.com/skywin88/ahahah/tree/main/server/core/models"
click node_hero_pipeline "https://github.com/skywin88/ahahah/blob/main/server/core/services/hero_video_pipeline.py"
click node_video_trimmer "https://github.com/skywin88/ahahah/blob/main/server/core/services/ffmpeg_trimmer.py"
click node_storage "https://github.com/skywin88/ahahah/blob/main/server/core/services/storage_service.py"
click node_security "https://github.com/skywin88/ahahah/blob/main/server/core/services/security.py"
click node_cache "https://github.com/skywin88/ahahah/blob/main/server/core/cache_keys.py"
click node_cdn "https://github.com/skywin88/ahahah/blob/main/client/lib/cdn.ts"
click node_edge_worker "https://github.com/skywin88/ahahah/blob/main/cloudflare/r2-cdn-worker.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_home,node_movie_page,node_player,node_search,node_viewer toneBlue
class node_accounts,node_chat toneAmber
class node_admin_ui,node_ad_manager,node_ad_preview,node_admin_api,node_hero_admin toneMint
class node_catalog_sync,node_crawler,node_providers,node_background_tasks toneRose
class node_api_client,node_domain_data,node_hero_pipeline,node_video_trimmer,node_storage,node_security,node_cache,node_cdn,node_edge_worker toneIndigo
```

## Components

### Discovery and viewing

- [Home discovery](https://github.com/skywin88/ahahah/blob/main/client/pages/index.tsx): `client/pages/index.tsx`
- [Movie detail](https://github.com/skywin88/ahahah/tree/main/client/pages/movie): `client/pages/movie`
- [Cinema player](https://github.com/skywin88/ahahah/blob/main/client/hooks/useCinemaPlayerEngine.ts): `client/hooks/useCinemaPlayerEngine.ts`
- [Search interface](https://github.com/skywin88/ahahah/blob/main/client/components/core/Search.tsx): `client/components/core/Search.tsx`

### Accounts and community

- [Account pages](https://github.com/skywin88/ahahah/tree/main/client/pages): `client/pages`
- [Chat experience](https://github.com/skywin88/ahahah/blob/main/client/components/core/ChatWidget.tsx): `client/components/core/ChatWidget.tsx`

### Administration

- [Admin suite](https://github.com/skywin88/ahahah/tree/main/client/components/admin): `client/components/admin`
- [Ad management](https://github.com/skywin88/ahahah/blob/main/client/components/admin/AdsManagerModule.tsx): `client/components/admin/AdsManagerModule.tsx`
- [Ad preview](https://github.com/skywin88/ahahah/blob/main/client/components/admin/AdLivePreview.tsx): `client/components/admin/AdLivePreview.tsx`
- [Admin operations API](https://github.com/skywin88/ahahah/blob/main/server/core/views/admin_suite_views.py): `server/core/views/admin_suite_views.py`
- [Hero banner API](https://github.com/skywin88/ahahah/blob/main/server/core/views/hero_banner_views.py): `server/core/views/hero_banner_views.py`

### Catalog operations

- [Catalog synchronization](https://github.com/skywin88/ahahah/blob/main/server/core/services/kkphim_sync_service.py): `server/core/services/kkphim_sync_service.py`
- [Crawler service](https://github.com/skywin88/ahahah/blob/main/server/core/services/crawler_service.py): `server/core/services/crawler_service.py`
- [Catalog providers](https://github.com/skywin88/ahahah/tree/main/server/core/providers): `server/core/providers`
- [Background tasks](https://github.com/skywin88/ahahah/blob/main/server/core/tasks.py): `server/core/tasks.py`

### Media and platform

- [API utilities](https://github.com/skywin88/ahahah/blob/main/client/utils/api.ts): `client/utils/api.ts`
- [Domain records](https://github.com/skywin88/ahahah/tree/main/server/core/models): `server/core/models`
- [Hero video pipeline](https://github.com/skywin88/ahahah/blob/main/server/core/services/hero_video_pipeline.py): `server/core/services/hero_video_pipeline.py`
- [Video trimming](https://github.com/skywin88/ahahah/blob/main/server/core/services/ffmpeg_trimmer.py): `server/core/services/ffmpeg_trimmer.py`
- [Media storage](https://github.com/skywin88/ahahah/blob/main/server/core/services/storage_service.py): `server/core/services/storage_service.py`
- [Stream security](https://github.com/skywin88/ahahah/blob/main/server/core/services/security.py): `server/core/services/security.py`
- [Cache invalidation](https://github.com/skywin88/ahahah/blob/main/server/core/cache_keys.py): `server/core/cache_keys.py`
- [Client CDN routing](https://github.com/skywin88/ahahah/blob/main/client/lib/cdn.ts): `client/lib/cdn.ts`
- [R2 CDN worker](https://github.com/skywin88/ahahah/blob/main/cloudflare/r2-cdn-worker.js): `cloudflare/r2-cdn-worker.js`

### Other components

- **Viewer**

## Connections

- Viewer → Home discovery: opens
- Viewer → Search interface: searches
- Viewer → Movie detail: opens title
- Movie detail → Cinema player: uses player
- Home discovery → API utilities: requests data
- Movie detail → API utilities: requests data
- Search interface → API utilities: requests data
- Account pages → API utilities: requests data
- Admin suite → Admin operations API: administers
- Ad management → Ad preview: uses draft (evidence: `client/components/admin/AdsManagerModule.tsx`)
- Admin operations API → Domain records: manages records
- Hero banner API → Domain records: reads and writes (evidence: `server/core/views/hero_banner_views.py`)
- Hero banner API → Background tasks: queues work (evidence: `server/core/views/hero_banner_views.py`)
- Background tasks → Catalog synchronization: runs sync (evidence: `server/core/tasks.py`)
- Background tasks → Crawler service: runs crawl (evidence: `server/core/tasks.py`)
- Catalog synchronization → Catalog providers: fetches catalog (evidence: `server/core/services/kkphim_sync_service.py`)
- Catalog synchronization → Crawler service: uses crawler (evidence: `server/core/services/kkphim_sync_service.py`)
- Catalog synchronization → Domain records: updates records (evidence: `server/core/services/kkphim_sync_service.py`)
- Background tasks → Domain records: updates records (evidence: `server/core/tasks.py`)
- Hero video pipeline → Media storage: uploads media (evidence: `server/core/services/hero_video_pipeline.py`)
- Hero video pipeline → Domain records: uses records (evidence: `server/core/services/hero_video_pipeline.py`)
- Hero video pipeline → Stream security: validates media (evidence: `server/core/services/hero_video_pipeline.py`)
- Hero video pipeline → Cache invalidation: uses cache keys (evidence: `server/core/services/hero_video_pipeline.py`)
- Hero banner API → Video trimming: trims previews (evidence: `server/core/views/hero_banner_views.py`)
- Video trimming → Media storage: stores output (evidence: `server/core/services/ffmpeg_trimmer.py`)
- API utilities → Client CDN routing: rewrites media
