Set up Mangalord with a Rust/axum backend, SvelteKit frontend, Postgres, and Docker Compose deployment. Establishes the architecture and TDD patterns the project will extend: - Hexagonal-ish backend layering (domain / repo / storage / api) with a pluggable Storage trait (LocalStorage today, S3 as a future impl). - Initial migration: users, mangas, chapters, bookmarks. - Vertical slice for mangas (list, search, create, get) with #[sqlx::test] integration coverage and storage unit tests. - SvelteKit frontend using Svelte 5 runes, typed API client, Vitest unit tests and Playwright e2e with route mocking. - CLAUDE.md documenting layering, TDD/git/SemVer workflow rules, and extension points (tags, fulltext search, OCR, S3, auth). - Project-scoped .claude/settings.json with permission allowlist for the toolchain (git, cargo, npm/vite, docker, psql, gh, doc fetches). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
50 lines
1.7 KiB
SQL
50 lines
1.7 KiB
SQL
-- Initial schema for Mangalord.
|
|
-- Designed for future extensions: tags, lists, fulltext/fuzzy search,
|
|
-- OCR-derived metadata. New concepts get new tables joined here; do
|
|
-- not jam them onto existing rows.
|
|
|
|
CREATE EXTENSION IF NOT EXISTS "pgcrypto";
|
|
|
|
CREATE TABLE users (
|
|
id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
username text NOT NULL UNIQUE,
|
|
created_at timestamptz NOT NULL DEFAULT now()
|
|
);
|
|
|
|
CREATE TABLE mangas (
|
|
id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
title text NOT NULL,
|
|
author text,
|
|
description text,
|
|
cover_image_path text,
|
|
created_at timestamptz NOT NULL DEFAULT now(),
|
|
updated_at timestamptz NOT NULL DEFAULT now()
|
|
);
|
|
|
|
CREATE INDEX mangas_created_at_idx ON mangas (created_at DESC);
|
|
CREATE INDEX mangas_title_lower_idx ON mangas (lower(title));
|
|
|
|
CREATE TABLE chapters (
|
|
id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
manga_id uuid NOT NULL REFERENCES mangas(id) ON DELETE CASCADE,
|
|
number integer NOT NULL,
|
|
title text,
|
|
page_count integer NOT NULL DEFAULT 0,
|
|
created_at timestamptz NOT NULL DEFAULT now(),
|
|
UNIQUE (manga_id, number)
|
|
);
|
|
|
|
CREATE INDEX chapters_manga_idx ON chapters (manga_id, number);
|
|
|
|
CREATE TABLE bookmarks (
|
|
id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
user_id uuid NOT NULL REFERENCES users(id) ON DELETE CASCADE,
|
|
manga_id uuid NOT NULL REFERENCES mangas(id) ON DELETE CASCADE,
|
|
chapter_id uuid REFERENCES chapters(id) ON DELETE SET NULL,
|
|
page integer,
|
|
created_at timestamptz NOT NULL DEFAULT now(),
|
|
UNIQUE (user_id, manga_id, chapter_id)
|
|
);
|
|
|
|
CREATE INDEX bookmarks_user_idx ON bookmarks (user_id, created_at DESC);
|