# khangitvns12/crawler architecture

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

- Interactive diagram: https://gitdiagram.com/khangitvns12/crawler
- Repository: https://github.com/khangitvns12/crawler

## Overview

NovelFlow is a web novel crawler, translator, library, and reader. Users crawl a source novel, optionally translate its chapters, save it to the library, then read or export it; background crawling supports longer jobs. The graph also includes documented API/OPDS access and Supabase synchronization. Relationships are limited to calls or references shown in the supplied excerpts and SOURCE INDEX; some route implementations and export details were not sampled.

Main entry points: [`app/page.tsx`](https://github.com/khangitvns12/crawler/blob/main/app/page.tsx) (Workspace), [`lib/server-storage.ts`](https://github.com/khangitvns12/crawler/blob/main/lib/server-storage.ts) (Storage facade), [`lib/crawler-engine.ts`](https://github.com/khangitvns12/crawler/blob/main/lib/crawler-engine.ts) (Crawler engine), [`components/NovelDetailModal.tsx`](https://github.com/khangitvns12/crawler/blob/main/components/NovelDetailModal.tsx) (Novel details)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_product_ui["Library experience"]
  node_web_app["Workspace<br/>[page.tsx]"]
  node_library["Novel library<br/>[LibraryView.tsx]"]
  node_novel_detail["Novel details"]
  node_reader["Chapter reader<br/>[ReaderModal.tsx]"]
  node_epub["EPUB export"]
end

subgraph group_crawl["Crawling"]
  node_crawler_ui["Crawler controls<br/>[CrawlerView.tsx]"]
  node_background_ui["Background jobs"]
  node_crawl_api["Crawler endpoints<br/>[route.ts]"]
  node_crawler_engine["Crawler engine<br/>[crawler-engine.ts]"]
  node_site_presets["Site presets"]
  node_background_jobs["Job runner"]
end

subgraph group_translation["Translation"]
  node_translation_ui["Translation workspace"]
  node_translate_api["Translation endpoint<br/>[route.ts]"]
  node_gemini["Gemini translation<br/>[gemini.ts]"]
end

subgraph group_platform["Storage and access"]
  node_domain_types["Novel and chapter model<br/>[novel.ts]"]
  node_storage_api["Novel endpoints<br/>[route.ts]"]
  node_server_storage["Storage facade<br/>[server-storage.ts]"]
  node_local_store[("Local state<br/>[server-storage.ts]")]
  node_supabase[("Supabase store<br/>[supabase.ts]")]
  node_v1_api["Public API and OPDS<br/>[route.ts]"]
  node_opds_generator["OPDS feed generator<br/>[opds-generator.ts]"]
end

node_user(("Reader"))
node_external_gemini{{"Google Gemini"}}
node_external_supabase[("Supabase service")]
node_novel_site{{"Novel websites"}}

node_user -->|"uses"| node_web_app
node_web_app -->|"shows"| node_library
node_web_app -->|"shows"| node_crawler_ui
node_web_app -->|"shows"| node_background_ui
node_web_app -->|"shows"| node_translation_ui
node_library -->|"opens"| node_novel_detail
node_novel_detail -->|"opens"| node_reader
node_novel_detail -.->|"exports"| node_epub
node_crawler_ui -->|"requests crawl"| node_crawl_api
node_crawl_api -->|"calls"| node_crawler_engine
node_crawler_engine -->|"selects preset"| node_site_presets
node_crawler_engine -.->|"fetches pages"| node_novel_site
node_background_ui -.->|"manages jobs"| node_background_jobs
node_background_jobs -->|"crawls chapters"| node_crawler_engine
node_crawler_ui -->|"saves chapters"| node_storage_api
node_translation_ui -.->|"requests translation"| node_translate_api
node_translate_api -->|"calls"| node_gemini
node_gemini -.->|"translates with"| node_external_gemini
node_translate_api -->|"updates novel"| node_server_storage
node_storage_api -->|"reads and writes"| node_server_storage
node_server_storage -->|"persists locally"| node_local_store
node_server_storage -->|"syncs when configured"| node_supabase
node_supabase -.->|"queries"| node_external_supabase
node_storage_api -->|"uses model"| node_domain_types
node_v1_api -->|"reads novels"| node_server_storage
node_v1_api -->|"generates feed"| node_opds_generator
node_user -.->|"accesses API"| node_v1_api

click node_web_app "https://github.com/khangitvns12/crawler/blob/main/app/page.tsx"
click node_library "https://github.com/khangitvns12/crawler/blob/main/components/LibraryView.tsx"
click node_novel_detail "https://github.com/khangitvns12/crawler/blob/main/components/NovelDetailModal.tsx"
click node_reader "https://github.com/khangitvns12/crawler/blob/main/components/ReaderModal.tsx"
click node_epub "https://github.com/khangitvns12/crawler/blob/main/components/EpubExportModal.tsx"
click node_crawler_ui "https://github.com/khangitvns12/crawler/blob/main/components/CrawlerView.tsx"
click node_background_ui "https://github.com/khangitvns12/crawler/blob/main/components/BackgroundCrawlerView.tsx"
click node_crawl_api "https://github.com/khangitvns12/crawler/blob/main/app/api/crawler/chapter/route.ts"
click node_crawler_engine "https://github.com/khangitvns12/crawler/blob/main/lib/crawler-engine.ts"
click node_site_presets "https://github.com/khangitvns12/crawler/blob/main/lib/preset-extractors.ts"
click node_background_jobs "https://github.com/khangitvns12/crawler/blob/main/lib/background-crawler.ts"
click node_translation_ui "https://github.com/khangitvns12/crawler/blob/main/components/TranslationView.tsx"
click node_translate_api "https://github.com/khangitvns12/crawler/blob/main/app/api/translate/route.ts"
click node_gemini "https://github.com/khangitvns12/crawler/blob/main/lib/gemini.ts"
click node_domain_types "https://github.com/khangitvns12/crawler/blob/main/types/novel.ts"
click node_storage_api "https://github.com/khangitvns12/crawler/blob/main/app/api/novels/route.ts"
click node_server_storage "https://github.com/khangitvns12/crawler/blob/main/lib/server-storage.ts"
click node_local_store "https://github.com/khangitvns12/crawler/blob/main/lib/server-storage.ts"
click node_supabase "https://github.com/khangitvns12/crawler/blob/main/lib/supabase.ts"
click node_v1_api "https://github.com/khangitvns12/crawler/blob/main/app/api/v1/opds/route.ts"
click node_opds_generator "https://github.com/khangitvns12/crawler/blob/main/lib/opds-generator.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_web_app,node_library,node_novel_detail,node_reader,node_epub toneBlue
class node_crawler_ui,node_background_ui,node_crawl_api,node_crawler_engine,node_site_presets,node_background_jobs,node_external_supabase toneAmber
class node_translation_ui,node_translate_api,node_gemini toneMint
class node_domain_types,node_storage_api,node_server_storage,node_local_store,node_supabase,node_v1_api,node_opds_generator toneRose
class node_user,node_external_gemini,node_novel_site toneIndigo
```

## Components

### Library experience

- [Workspace](https://github.com/khangitvns12/crawler/blob/main/app/page.tsx): `app/page.tsx`
- [Novel library](https://github.com/khangitvns12/crawler/blob/main/components/LibraryView.tsx): `components/LibraryView.tsx`
- [Novel details](https://github.com/khangitvns12/crawler/blob/main/components/NovelDetailModal.tsx): `components/NovelDetailModal.tsx`
- [Chapter reader](https://github.com/khangitvns12/crawler/blob/main/components/ReaderModal.tsx): `components/ReaderModal.tsx`
- [EPUB export](https://github.com/khangitvns12/crawler/blob/main/components/EpubExportModal.tsx): `components/EpubExportModal.tsx`

### Crawling

- [Crawler controls](https://github.com/khangitvns12/crawler/blob/main/components/CrawlerView.tsx): `components/CrawlerView.tsx`
- [Background jobs](https://github.com/khangitvns12/crawler/blob/main/components/BackgroundCrawlerView.tsx): `components/BackgroundCrawlerView.tsx`
- [Crawler endpoints](https://github.com/khangitvns12/crawler/blob/main/app/api/crawler/chapter/route.ts): `app/api/crawler/chapter/route.ts`
- [Crawler engine](https://github.com/khangitvns12/crawler/blob/main/lib/crawler-engine.ts): `lib/crawler-engine.ts`
- [Site presets](https://github.com/khangitvns12/crawler/blob/main/lib/preset-extractors.ts): `lib/preset-extractors.ts`
- [Job runner](https://github.com/khangitvns12/crawler/blob/main/lib/background-crawler.ts): `lib/background-crawler.ts`

### Translation

- [Translation workspace](https://github.com/khangitvns12/crawler/blob/main/components/TranslationView.tsx): `components/TranslationView.tsx`
- [Translation endpoint](https://github.com/khangitvns12/crawler/blob/main/app/api/translate/route.ts): `app/api/translate/route.ts`
- [Gemini translation](https://github.com/khangitvns12/crawler/blob/main/lib/gemini.ts): `lib/gemini.ts`

### Storage and access

- [Novel and chapter model](https://github.com/khangitvns12/crawler/blob/main/types/novel.ts): `types/novel.ts`
- [Novel endpoints](https://github.com/khangitvns12/crawler/blob/main/app/api/novels/route.ts): `app/api/novels/route.ts`
- [Storage facade](https://github.com/khangitvns12/crawler/blob/main/lib/server-storage.ts): `lib/server-storage.ts`
- [Local state](https://github.com/khangitvns12/crawler/blob/main/lib/server-storage.ts): `lib/server-storage.ts`
- [Supabase store](https://github.com/khangitvns12/crawler/blob/main/lib/supabase.ts): `lib/supabase.ts`
- [Public API and OPDS](https://github.com/khangitvns12/crawler/blob/main/app/api/v1/opds/route.ts): `app/api/v1/opds/route.ts`
- [OPDS feed generator](https://github.com/khangitvns12/crawler/blob/main/lib/opds-generator.ts): `lib/opds-generator.ts`

### Other components

- **Reader**
- **Google Gemini**
- **Supabase service**
- **Novel websites**

## Connections

- Reader → Workspace: uses (evidence: `app/page.tsx`)
- Workspace → Novel library: shows (evidence: `app/page.tsx`)
- Workspace → Crawler controls: shows (evidence: `app/page.tsx`)
- Workspace → Background jobs: shows (evidence: `app/page.tsx`)
- Workspace → Translation workspace: shows (evidence: `app/page.tsx`)
- Novel library → Novel details: opens (evidence: `components/LibraryView.tsx`)
- Novel details → Chapter reader: opens (evidence: `components/NovelDetailModal.tsx`)
- Novel details → EPUB export: exports
- Crawler controls → Crawler endpoints: requests crawl (evidence: `components/CrawlerView.tsx`)
- Crawler endpoints → Crawler engine: calls (evidence: `app/api/crawler/chapter/route.ts`)
- Crawler engine → Site presets: selects preset (evidence: `lib/crawler-engine.ts`)
- Crawler engine → Novel websites: fetches pages
- Background jobs → Job runner: manages jobs
- Job runner → Crawler engine: crawls chapters (evidence: `lib/background-crawler.ts`)
- Crawler controls → Novel endpoints: saves chapters (evidence: `components/CrawlerView.tsx`)
- Translation workspace → Translation endpoint: requests translation
- Translation endpoint → Gemini translation: calls (evidence: `app/api/translate/route.ts`)
- Gemini translation → Google Gemini: translates with
- Translation endpoint → Storage facade: updates novel (evidence: `app/api/translate/route.ts`)
- Novel endpoints → Storage facade: reads and writes (evidence: `app/api/novels/route.ts`)
- Storage facade → Local state: persists locally (evidence: `lib/server-storage.ts`)
- Storage facade → Supabase store: syncs when configured (evidence: `lib/server-storage.ts`)
- Supabase store → Supabase service: queries
- Novel endpoints → Novel and chapter model: uses model (evidence: `app/api/novels/route.ts`)
- Public API and OPDS → Storage facade: reads novels (evidence: `app/api/v1/opds/route.ts`)
- Public API and OPDS → OPDS feed generator: generates feed (evidence: `app/api/v1/opds/route.ts`)
- Reader → Public API and OPDS: accesses API
