Files
mangabaka-seeder/docs/ARCHITECTURE.md
T
Lucas WintherandClaude Opus 5.5 219a05c039 chore: bootstrap agent-ready docs and rules; revise design for web page + userscript
Revise the covers spec: both links given directly, static page served by a
Cloudflare Worker plus a userscript on one pure core, Bun instead of Node,
and R2 rehosting with a 30-day expiry. Move the spec to docs/specs/, merge
HANDOVER.md into docs/DECISIONS.md, the spec and docs/TODO.md, and add
AGENTS.md, pointer files, PERMISSIONS.md and agent permission configs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-14 22:02:39 +02:00

41 lines
2.1 KiB
Markdown

# Architecture
How `mangabaka-seeder` is built today. Update in the same commit as any structural change.
## Overview
No code exists yet. The design is in [`specs/001-webtoons-covers.md`](specs/001-webtoons-covers.md):
one pure TypeScript core (`src/core/`) that turns a MangaBaka series link and a Webtoons series
link into a cover submission, used by three front ends — a static page served by a Cloudflare
Worker (primary), a userscript, and later a Bun CLI. Replace this section with reality as modules land.
## Map (planned — spec §4)
| Path | Responsibility |
|---|---|
| `src/core/` | Pure pipeline: sources, Wayback history, image inspection, dedupe, seed, MangaBaka client. No DOM, Bun, Node or `GM_*` APIs. |
| `src/web/` | Static page UI. |
| `src/worker/` | Cloudflare Worker: static assets, `/api/fetch` allowlisted proxy, `/api/upload` → R2. |
| `src/userscript/` | Userscript on mangabaka.org; network via `GM_xmlhttpRequest`. |
| `src/cli/` | Later: Bun CLI. |
| `test/fixtures/` | Saved real responses; tests never hit the network. |
## Data flow
Links → series id + `source.resolve` → current + Wayback candidates → inspect (bytes, size,
sha256) → dedupe against MangaBaka → seed → user reviews → rehost (explicit) → submit or manual entry.
## External dependencies
| Service | Reached via | If unavailable |
|---|---|---|
| `api.mangabaka.org` | direct (CORS open) | Nothing works. |
| Webtoons HTML / `swebtoon-phinf.pstatic.net` | Worker proxy or `GM_xmlhttpRequest` | Nothing works. |
| Wayback (`web.archive.org`) | same | Warning; current covers only. |
| Cloudflare R2 | Worker binding | Rehost fails; `direct` host still possible. |
## Invariants
- `src/core/` never imports from `web/`, `worker/`, `userscript/` or `cli/`.
- The MangaBaka token is only ever sent to `api.mangabaka.org`, never through the Worker.
- Nothing is uploaded or submitted without an explicit user action; saves use `save_mode: "review"`.
- `/api/fetch` only fetches allowlisted hosts; `/api/upload` only takes a source URL, never bytes.
## Known rough edges
See the open questions in spec §7 and [`TODO.md`](TODO.md).