9af070608ba8242ae429b8c7d231218f42051326
Backend:
- Migration 0003_pages.sql adds a `pages` table (id, chapter_id,
page_number, storage_key, content_type) with a unique (chapter_id,
page_number). New table because chapter pages can have different MIME
types per page; reconstructing keys from a single template would
break the moment a chapter mixes png and jpg pages.
- `domain::Page` + `repo::page` (create + list_for_chapter).
- The chapter upload handler now inserts one page row per part as it
writes the bytes to storage.
- GET /api/v1/mangas/{id}/chapters/{n}/pages returns `{pages: [...]}`
with the storage_key clients need to construct image URLs. 404 if
the manga or chapter doesn't exist; reads are public.
Storage trait grows `get_stream(&str) -> StreamingFile` returning a
`Pin<Box<dyn Stream<Item = io::Result<Bytes>> + Send>>` + size. The
local backend implements via `tokio::fs::File` + `tokio_util::io::
ReaderStream` with a 64 KiB chunk size. GET /api/v1/files/*key now
streams via `axum::body::Body::from_stream` instead of buffering — the
test asserts a 200 KiB file emits >1 frame end-to-end through the
router.
Frontend:
- lib/api/client.ts gains `fileUrl(key)` so components don't
reconstruct the `/api/v1/files/...` path manually.
- lib/api/chapters.ts gains `ChapterPage` type + `getChapterPages` (the
type is named ChapterPage to avoid colliding with `Page` from
client.ts, which is the pagination envelope).
- /manga/[id]/+page.svelte: overview with cover, title, author,
description, chapter list, and a disabled bookmark control (real
bookmarking lands in feat/bookmarks). Responsive at 640 px.
- /manga/[id]/chapter/[n]/+page.svelte: paginated reader. Current page
loads eagerly; next page is preloaded in a hidden img so navigation
feels instant. Keyboard handler maps ArrowRight/j/Space → next,
ArrowLeft/k → prev, Home/End → first/last; skips when the user is
typing in an input. Focus ring on the prev/next buttons.
- SSR is disabled on both routes via `export const ssr = false` so the
client-only fetch flow doesn't need to be replicated server-side; the
routes are interactive features, not SEO surfaces.
- E2E (e2e/reader.spec.ts): overview shows the title/cover/chapter
list; reader pages through three pages via ArrowRight, j, k, and
ArrowLeft, and the preload img holds the page-2 src on initial load.
Lockstep version bump to 0.6.0.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Mangalord
A self-hosted manga and comics reader. Browse, search, read, bookmark, and upload manga and chapters. The HTTP API is consumed by both the SvelteKit web UI and external bots/scripts that perform the same actions programmatically.
Stack
- Backend: Rust, axum, sqlx
- Database: Postgres 16
- Frontend: SvelteKit 2 (Svelte 5 runes), TypeScript, Vite
- File storage: pluggable
Storagetrait — local FS today, S3 (and friends) as future impls - Deploy: Docker Compose on a single server
Quick start
cp .env.example .env
docker compose up --build
- Frontend: http://localhost:3000
- API: http://localhost:8080/api
- API health: http://localhost:8080/api/health
Local development
Run only Postgres in Docker; run backend and frontend natively for fast iteration:
docker compose -f docker-compose.dev.yml up -d
# backend
cd backend
export DATABASE_URL=postgres://mangalord:mangalord@localhost:5432/mangalord
cargo run
# frontend (separate shell)
cd frontend
npm install
npm run dev
The Vite dev server proxies /api to http://localhost:8080.
Tests
This project is developed test-first. Tests live at three levels:
# Backend: unit (in-module) + integration (tests/, per-test DB via #[sqlx::test])
cd backend && cargo test
# Frontend: unit / module tests (Vitest)
cd frontend && npm test
# Frontend: end-to-end (Playwright; spins up dev server, mocks API by default)
cd frontend && npm run test:e2e
API surface
| Method | Path | Purpose |
|---|---|---|
| GET | /api/health |
Liveness |
| GET | /api/mangas |
List / search mangas |
| POST | /api/mangas |
Create a manga |
| GET | /api/mangas/{id} |
Get a manga |
| GET | /api/files/{key} |
Stream a blob (cover, chapter page) |
Chapters, uploads, and bookmarks are next — the patterns to extend are documented in CLAUDE.md.
Description
Languages
Rust
59.1%
Svelte
21.9%
TypeScript
18.1%
CSS
0.6%
Dockerfile
0.2%
Other
0.1%