# alan-uai/tradumanga architecture

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

- Interactive diagram: https://gitdiagram.com/alan-uai/tradumanga
- Repository: https://github.com/alan-uai/tradumanga

## Overview

Tradumanga is a web app for importing manga/manhwa chapters, translating pages contextually into Brazilian Portuguese, and reading the rendered results. The main flow starts with a URL import or chapter upload, enters a durable Inngest workflow, ingests pages, analyzes and translates them with Gemini, renders and QA-checks artifacts, stores them in Supabase, and exposes them in the reader. The graph also includes account/anonymous-session handling and reading progress. Pipeline stages and some service links follow the README; unsampled routes and implementations are not inferred beyond documented behavior.

Main entry points: [`lib/pipeline/inngest-runtime.ts`](https://github.com/alan-uai/tradumanga/blob/main/lib/pipeline/inngest-runtime.ts) (Page pipeline runtime), [`lib/supabase/admin.ts`](https://github.com/alan-uai/tradumanga/blob/main/lib/supabase/admin.ts) (Supabase admin access), [`lib/anonymous/access.ts`](https://github.com/alan-uai/tradumanga/blob/main/lib/anonymous/access.ts) (Actor and access checks), [`app/api/import/url/route.ts`](https://github.com/alan-uai/tradumanga/blob/main/app/api/import/url/route.ts) (URL import API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["Reader experience"]
  node_library["Library and dashboard<br/>[page.tsx]"]
  node_new_import["New import<br/>[page.tsx]"]
  node_processing_view["Processing view"]
  node_reader["Reader<br/>[page.tsx]"]
  node_reading_progress["Reading progress"]
end

subgraph group_access["Identity and access"]
  node_session_bootstrap["Session bootstrap"]
  node_anonymous_state[("Anonymous local state<br/>[localState.ts]")]
  node_anonymous_session["Anonymous sessions<br/>[session.ts]"]
  node_access_control["Actor and access checks<br/>[access.ts]"]
  node_account_migration["Account migration<br/>[route.ts]"]
end

subgraph group_ingestion["Import and ingestion"]
  node_import_api["URL import API<br/>[route.ts]"]
  node_chapter_api["Chapter creation API<br/>[route.ts]"]
  node_url_ingest["URL source handling<br/>[url.ts]"]
  node_mangadex_ingest["MangaDex source<br/>[mangadex.ts]"]
  node_mangadex_reader["MangaDex reader proxy<br/>[route.ts]"]
end

subgraph group_pipeline["Translation pipeline"]
  node_inngest_endpoint["Inngest endpoint<br/>[route.ts]"]
  node_workflow_functions["Workflow functions<br/>[functions.ts]"]
  node_pipeline_runtime["Page pipeline runtime<br/>[inngest-runtime.ts]"]
  node_gemini["Gemini analysis and translation<br/>[gemini.ts]"]
  node_page_layers["Page composition and QA<br/>[page-layers.ts]"]
  node_image_provider["Image processing provider"]
  node_translated_pages["Translated page artifacts<br/>[inngest-runtime.ts]"]
end

subgraph group_platform["Persistence and orchestration"]
  node_inngest_client["Inngest client<br/>[client.ts]"]
  node_supabase_admin["Supabase admin access<br/>[admin.ts]"]
  node_supabase_server["Supabase server auth<br/>[server.ts]"]
  node_supabase_browser["Supabase browser client<br/>[client.ts]"]
  node_supabase_storage[("Supabase database and storage<br/>[admin.ts]")]
end

node_visitor(("Visitor"))
node_external_inngest{{"Inngest Cloud"}}
node_external_gemini{{"Gemini"}}
node_external_supabase[("Supabase")]

node_visitor -->|"opens"| node_library
node_visitor -->|"starts import"| node_new_import
node_new_import -->|"submits URL"| node_import_api
node_import_api -->|"canonicalizes URL"| node_url_ingest
node_import_api -->|"detects source"| node_mangadex_ingest
node_import_api -->|"sends event"| node_inngest_client
node_inngest_endpoint -->|"serves functions"| node_inngest_client
node_inngest_endpoint -->|"registers"| node_workflow_functions
node_inngest_client -.->|"dispatches workflow"| node_external_inngest
node_workflow_functions -->|"runs stages"| node_pipeline_runtime
node_pipeline_runtime -->|"ingests sources"| node_url_ingest
node_pipeline_runtime -->|"analyzes and translates"| node_gemini
node_pipeline_runtime -->|"composes pages"| node_page_layers
node_gemini -->|"requests analysis"| node_external_gemini
node_page_layers -->|"renders and QA-checks"| node_translated_pages
node_pipeline_runtime -->|"records pipeline state"| node_supabase_admin
node_pipeline_runtime -.->|"stores artifacts"| node_translated_pages
node_supabase_admin -.->|"accesses data"| node_external_supabase
node_chapter_api -->|"checks access"| node_access_control
node_chapter_api -->|"validates source"| node_url_ingest
node_mangadex_reader -->|"uses source helper"| node_mangadex_ingest
node_processing_view -->|"redirects when ready"| node_reader
node_processing_view -.->|"polls status API"| node_external_supabase
node_reader -->|"renders tracker"| node_reading_progress
node_reading_progress -->|"saves local progress"| node_anonymous_state
node_session_bootstrap -->|"loads local manifest"| node_anonymous_state
node_session_bootstrap -->|"uses browser client"| node_supabase_browser
node_anonymous_session -->|"stores session records"| node_supabase_admin
node_access_control -->|"resolves session"| node_anonymous_session
node_access_control -->|"checks signed-in user"| node_supabase_server
node_access_control -->|"checks ownership"| node_supabase_admin
node_account_migration -->|"gets session ID"| node_anonymous_session
node_account_migration -->|"authenticates user"| node_supabase_server
node_account_migration -->|"migrates records"| node_supabase_admin
node_supabase_admin -.->|"accesses store"| node_supabase_storage
node_supabase_server -.->|"authenticates"| node_external_supabase
node_supabase_browser -.->|"connects client"| node_external_supabase
node_pipeline_runtime -.->|"optional image processing"| node_image_provider

click node_library "https://github.com/alan-uai/tradumanga/blob/main/app/page.tsx"
click node_new_import "https://github.com/alan-uai/tradumanga/blob/main/app/new/page.tsx"
click node_processing_view "https://github.com/alan-uai/tradumanga/blob/main/components/processing-client.tsx"
click node_reader "https://github.com/alan-uai/tradumanga/blob/main/app/reader/%5Bid%5D/page.tsx"
click node_reading_progress "https://github.com/alan-uai/tradumanga/blob/main/components/reader-progress-tracker.tsx"
click node_session_bootstrap "https://github.com/alan-uai/tradumanga/blob/main/components/anonymous-session-bootstrap.tsx"
click node_anonymous_state "https://github.com/alan-uai/tradumanga/blob/main/lib/anonymous/localState.ts"
click node_anonymous_session "https://github.com/alan-uai/tradumanga/blob/main/lib/anonymous/session.ts"
click node_access_control "https://github.com/alan-uai/tradumanga/blob/main/lib/anonymous/access.ts"
click node_account_migration "https://github.com/alan-uai/tradumanga/blob/main/app/api/migrate-anonymous/route.ts"
click node_import_api "https://github.com/alan-uai/tradumanga/blob/main/app/api/import/url/route.ts"
click node_chapter_api "https://github.com/alan-uai/tradumanga/blob/main/app/api/chapters/route.ts"
click node_url_ingest "https://github.com/alan-uai/tradumanga/blob/main/lib/ingest/url.ts"
click node_mangadex_ingest "https://github.com/alan-uai/tradumanga/blob/main/lib/ingest/mangadex.ts"
click node_mangadex_reader "https://github.com/alan-uai/tradumanga/blob/main/app/api/mangadex/reader/route.ts"
click node_inngest_endpoint "https://github.com/alan-uai/tradumanga/blob/main/app/api/inngest/route.ts"
click node_workflow_functions "https://github.com/alan-uai/tradumanga/blob/main/lib/inngest/functions.ts"
click node_pipeline_runtime "https://github.com/alan-uai/tradumanga/blob/main/lib/pipeline/inngest-runtime.ts"
click node_gemini "https://github.com/alan-uai/tradumanga/blob/main/lib/pipeline/gemini.ts"
click node_page_layers "https://github.com/alan-uai/tradumanga/blob/main/lib/pipeline/page-layers.ts"
click node_image_provider "https://github.com/alan-uai/tradumanga/blob/main/lib/pipeline/openrouter-image.ts"
click node_inngest_client "https://github.com/alan-uai/tradumanga/blob/main/lib/inngest/client.ts"
click node_supabase_admin "https://github.com/alan-uai/tradumanga/blob/main/lib/supabase/admin.ts"
click node_supabase_server "https://github.com/alan-uai/tradumanga/blob/main/lib/supabase/server.ts"
click node_supabase_browser "https://github.com/alan-uai/tradumanga/blob/main/lib/supabase/client.ts"
click node_supabase_storage "https://github.com/alan-uai/tradumanga/blob/main/lib/supabase/admin.ts"
click node_translated_pages "https://github.com/alan-uai/tradumanga/blob/main/lib/pipeline/inngest-runtime.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_library,node_new_import,node_processing_view,node_reader,node_reading_progress toneBlue
class node_session_bootstrap,node_anonymous_state,node_anonymous_session,node_access_control,node_account_migration,node_external_supabase toneAmber
class node_import_api,node_chapter_api,node_url_ingest,node_mangadex_ingest,node_mangadex_reader toneMint
class node_inngest_endpoint,node_workflow_functions,node_pipeline_runtime,node_gemini,node_page_layers,node_image_provider,node_translated_pages toneRose
class node_inngest_client,node_supabase_admin,node_supabase_server,node_supabase_browser,node_supabase_storage,node_visitor,node_external_inngest,node_external_gemini toneIndigo
```

## Components

### Reader experience

- [Library and dashboard](https://github.com/alan-uai/tradumanga/blob/main/app/page.tsx): `app/page.tsx`
- [New import](https://github.com/alan-uai/tradumanga/blob/main/app/new/page.tsx): `app/new/page.tsx`
- [Processing view](https://github.com/alan-uai/tradumanga/blob/main/components/processing-client.tsx): `components/processing-client.tsx`
- [Reader](https://github.com/alan-uai/tradumanga/blob/main/app/reader/%5Bid%5D/page.tsx): `app/reader/[id]/page.tsx`
- [Reading progress](https://github.com/alan-uai/tradumanga/blob/main/components/reader-progress-tracker.tsx): `components/reader-progress-tracker.tsx`

### Identity and access

- [Session bootstrap](https://github.com/alan-uai/tradumanga/blob/main/components/anonymous-session-bootstrap.tsx): `components/anonymous-session-bootstrap.tsx`
- [Anonymous local state](https://github.com/alan-uai/tradumanga/blob/main/lib/anonymous/localState.ts): `lib/anonymous/localState.ts`
- [Anonymous sessions](https://github.com/alan-uai/tradumanga/blob/main/lib/anonymous/session.ts): `lib/anonymous/session.ts`
- [Actor and access checks](https://github.com/alan-uai/tradumanga/blob/main/lib/anonymous/access.ts): `lib/anonymous/access.ts`
- [Account migration](https://github.com/alan-uai/tradumanga/blob/main/app/api/migrate-anonymous/route.ts): `app/api/migrate-anonymous/route.ts`

### Import and ingestion

- [URL import API](https://github.com/alan-uai/tradumanga/blob/main/app/api/import/url/route.ts): `app/api/import/url/route.ts`
- [Chapter creation API](https://github.com/alan-uai/tradumanga/blob/main/app/api/chapters/route.ts): `app/api/chapters/route.ts`
- [URL source handling](https://github.com/alan-uai/tradumanga/blob/main/lib/ingest/url.ts): `lib/ingest/url.ts`
- [MangaDex source](https://github.com/alan-uai/tradumanga/blob/main/lib/ingest/mangadex.ts): `lib/ingest/mangadex.ts`
- [MangaDex reader proxy](https://github.com/alan-uai/tradumanga/blob/main/app/api/mangadex/reader/route.ts): `app/api/mangadex/reader/route.ts`

### Translation pipeline

- [Inngest endpoint](https://github.com/alan-uai/tradumanga/blob/main/app/api/inngest/route.ts): `app/api/inngest/route.ts`
- [Workflow functions](https://github.com/alan-uai/tradumanga/blob/main/lib/inngest/functions.ts): `lib/inngest/functions.ts`
- [Page pipeline runtime](https://github.com/alan-uai/tradumanga/blob/main/lib/pipeline/inngest-runtime.ts): `lib/pipeline/inngest-runtime.ts`
- [Gemini analysis and translation](https://github.com/alan-uai/tradumanga/blob/main/lib/pipeline/gemini.ts): `lib/pipeline/gemini.ts`
- [Page composition and QA](https://github.com/alan-uai/tradumanga/blob/main/lib/pipeline/page-layers.ts): `lib/pipeline/page-layers.ts`
- [Image processing provider](https://github.com/alan-uai/tradumanga/blob/main/lib/pipeline/openrouter-image.ts): `lib/pipeline/openrouter-image.ts`
- [Translated page artifacts](https://github.com/alan-uai/tradumanga/blob/main/lib/pipeline/inngest-runtime.ts): `lib/pipeline/inngest-runtime.ts`

### Persistence and orchestration

- [Inngest client](https://github.com/alan-uai/tradumanga/blob/main/lib/inngest/client.ts): `lib/inngest/client.ts`
- [Supabase admin access](https://github.com/alan-uai/tradumanga/blob/main/lib/supabase/admin.ts): `lib/supabase/admin.ts`
- [Supabase server auth](https://github.com/alan-uai/tradumanga/blob/main/lib/supabase/server.ts): `lib/supabase/server.ts`
- [Supabase browser client](https://github.com/alan-uai/tradumanga/blob/main/lib/supabase/client.ts): `lib/supabase/client.ts`
- [Supabase database and storage](https://github.com/alan-uai/tradumanga/blob/main/lib/supabase/admin.ts): `lib/supabase/admin.ts`

### Other components

- **Visitor**
- **Inngest Cloud**
- **Gemini**
- **Supabase**

## Connections

- Visitor → Library and dashboard: opens
- Visitor → New import: starts import
- New import → URL import API: submits URL (evidence: `app/api/import/url/route.ts`)
- URL import API → URL source handling: canonicalizes URL (evidence: `app/api/import/url/route.ts`)
- URL import API → MangaDex source: detects source (evidence: `app/api/import/url/route.ts`)
- URL import API → Inngest client: sends event (evidence: `app/api/import/url/route.ts`)
- Inngest endpoint → Inngest client: serves functions (evidence: `app/api/inngest/route.ts`)
- Inngest endpoint → Workflow functions: registers (evidence: `app/api/inngest/route.ts`)
- Inngest client → Inngest Cloud: dispatches workflow (evidence: `README.md`)
- Workflow functions → Page pipeline runtime: runs stages (evidence: `lib/inngest/functions.ts`)
- Page pipeline runtime → URL source handling: ingests sources (evidence: `lib/pipeline/inngest-runtime.ts`)
- Page pipeline runtime → Gemini analysis and translation: analyzes and translates (evidence: `lib/inngest/functions.ts`)
- Page pipeline runtime → Page composition and QA: composes pages (evidence: `lib/pipeline/inngest-runtime.ts`)
- Gemini analysis and translation → Gemini: requests analysis (evidence: `README.md`)
- Page composition and QA → Translated page artifacts: renders and QA-checks (evidence: `README.md`)
- Page pipeline runtime → Supabase admin access: records pipeline state (evidence: `lib/pipeline/inngest-runtime.ts`)
- Page pipeline runtime → Translated page artifacts: stores artifacts (evidence: `README.md`)
- Supabase admin access → Supabase: accesses data (evidence: `README.md`)
- Chapter creation API → Actor and access checks: checks access (evidence: `app/api/chapters/route.ts`)
- Chapter creation API → URL source handling: validates source (evidence: `app/api/chapters/route.ts`)
- MangaDex reader proxy → MangaDex source: uses source helper (evidence: `app/api/mangadex/reader/route.ts`)
- Processing view → Reader: redirects when ready (evidence: `components/processing-client.tsx`)
- Processing view → Supabase: polls status API
- Reader → Reading progress: renders tracker (evidence: `app/reader/[id]/page.tsx`)
- Reading progress → Anonymous local state: saves local progress (evidence: `components/reader-progress-tracker.tsx`)
- Session bootstrap → Anonymous local state: loads local manifest (evidence: `components/anonymous-session-bootstrap.tsx`)
- Session bootstrap → Supabase browser client: uses browser client (evidence: `components/anonymous-session-bootstrap.tsx`)
- Anonymous sessions → Supabase admin access: stores session records (evidence: `lib/anonymous/session.ts`)
- Actor and access checks → Anonymous sessions: resolves session (evidence: `lib/anonymous/access.ts`)
- Actor and access checks → Supabase server auth: checks signed-in user (evidence: `lib/anonymous/access.ts`)
- Actor and access checks → Supabase admin access: checks ownership (evidence: `lib/anonymous/access.ts`)
- Account migration → Anonymous sessions: gets session ID (evidence: `app/api/migrate-anonymous/route.ts`)
- Account migration → Supabase server auth: authenticates user (evidence: `app/api/migrate-anonymous/route.ts`)
- Account migration → Supabase admin access: migrates records (evidence: `app/api/migrate-anonymous/route.ts`)
- Supabase admin access → Supabase database and storage: accesses store (evidence: `lib/supabase/admin.ts`)
- Supabase server auth → Supabase: authenticates (evidence: `README.md`)
- Supabase browser client → Supabase: connects client
- Page pipeline runtime → Image processing provider: optional image processing
