No description
  • JavaScript 83.6%
  • CSS 16.4%
Find a file
amayakase 47c1c08647
All checks were successful
Validate waifudb / Frontend Build & Lint (push) Successful in 27s
Validate waifudb / Backend Dependencies (push) Successful in 5s
Validate waifudb / Frontend fixture browser smoke (push) Successful in 56s
Add Relationships 2.0 design docs
This adds the Relationships 2.0 specification, architecture diagrams, test matrix, and phased implementation roadmap for the canonical universe explorer. It defines the source-of-truth model for pair relationships, parentage, species, houses/organizations, romance situations, and release validation while preserving admin/account safety requirements.
2026-10-12 00:02:30 +02:00
.forgejo/workflows Add Playwright smoke tests and CI job 2026-10-11 23:03:48 +02:00
.github/instructions Add AGENTS guide and DB workflow instructions 2026-04-25 19:00:53 +02:00
backend Add startup schema manager for MariaDB 2026-10-11 23:34:03 +02:00
docs Add Relationships 2.0 design docs 2026-10-12 00:02:30 +02:00
frontend Refine tag and relationship page UX 2026-10-11 23:13:52 +02:00
.gitignore Add Playwright smoke tests and CI job 2026-10-11 23:03:48 +02:00
AGENTS.md Add AGENTS guide and DB workflow instructions 2026-04-25 19:00:53 +02:00
package-lock.json Add boilerplate: Express backend & Vite frontend 2026-04-25 13:43:01 +02:00
package.json Add Playwright smoke tests and CI job 2026-10-11 23:03:48 +02:00
README.md Add startup schema manager for MariaDB 2026-10-11 23:34:03 +02:00
UNIVERSE_NAVIGATION_VERIFICATION.md Add universe section nav and Forgejo validation 2026-10-11 21:06:37 +02:00

waifudb boilerplate

Express backend + React (Vite) frontend with Material UI.

Project structure

  • backend - Express API
  • frontend - React + MUI app
  • package.json - root scripts to run both apps

Configuration

Backend example config: backend/.env.example

  • PORT - backend port (default 4000)
  • SITE_NAME - site/app name
  • FRONTEND_ORIGIN - CORS origin for frontend
  • DB_HOST - MariaDB host
  • DB_PORT - MariaDB port (default 3306)
  • DB_NAME - MariaDB database name
  • DB_USER - MariaDB username
  • DB_PASSWORD - MariaDB password
  • DB_LOG_SQL - set to true to log Sequelize SQL
  • DB_SCHEMA_MODE - update (default) or validate
  • AUTH_BCRYPT_ROUNDS - bcrypt work factor for stored passwords

Frontend example config: frontend/.env.example

  • FRONTEND_PORT - Vite dev server port (default 5173)
  • VITE_FRONTEND_PORT - frontend port shown in the UI
  • VITE_SITE_NAME - site name fallback for frontend runtime config
  • VITE_API_BASE_URL - backend API base URL
  • VITE_CONFIG_TIMEOUT_MS - request timeout for runtime config API (default 2500)

Copy these to .env files if you want to override defaults.

Scripts

From the repository root:

  • npm run dev - run backend + frontend together
  • npm run dev:backend - run only backend
  • npm run dev:frontend - run only frontend
  • npm run build - build frontend

Authentication

The backend uses Sequelize with the MariaDB dialect for account storage and persistent login sessions.

  • POST /api/auth/register - create an account with username and password
  • POST /api/auth/login - log in with username and password
  • GET /api/auth/me - return the current user for a bearer token
  • POST /api/auth/logout - invalidate the current bearer token

Frontend auth stores the bearer token in localStorage, and the backend persists the session record in MariaDB so login survives server restarts until logout.

Start MariaDB, configure the backend connection, then run npm run dev (or npm run dev:backend). Before accepting requests, the backend creates the configured database if missing and prepares its tables from backend/sql/schema.sql. The MariaDB account needs CREATE privileges for a missing database, and CREATE/ALTER/INDEX privileges for schema updates. Existing databases can use an account limited to that database.

Startup adds missing tables, columns, indexes, foreign keys, and check constraints. It also reconciles defaults and automatic timestamp updates when the column type, nullability, and auto-increment setting already match, preserving stored values. Existing rows and extra tables/columns are retained. Required columns without defaults on populated tables, incompatible column definitions, conflicting indexes/foreign keys, or incompatible table storage/collation stop startup for manual review. Column errors include suggested SQL and actual metadata; review/backfill your data before applying it. Renames and data transformations require deliberate manual SQL. DDL commits independently: a failed adjustment may leave earlier additions applied, and restarting resumes from that state. Back up populated databases before schema upgrades.

DB_SCHEMA_MODE=validate checks an existing database without applying schema changes and fails startup when adjustments are needed. Validation checks column types, nullability, defaults, auto-increment and timestamp updates, indexes, foreign-key targets/actions, and the presence of named CHECK constraints. It does not compare existing CHECK expressions, triggers, or extra objects. Startup uses a database advisory lock to serialize schema management across backend instances.

The agent does not execute SQL or start a database-connected backend during verification; runtime schema updates happen when you start the application.

Schema setup SQL:

  • backend/sql/schema.sql

Manual verification (use a disposable database):

  1. Configure a new DB_NAME, start the backend, and confirm the database/tables are created before /api/health succeeds.
  2. Register, log in, fetch /api/auth/me, restart and confirm the session persists, then log out.
  3. Restart again and confirm the schema log reports zero adjustments and records remain intact.
  4. Manually remove a nullable column or nonunique index; restart to confirm it is restored. Repeat in validate mode and confirm startup fails without restoring it.
  5. Change a column type or omit a required column on a populated table; confirm startup fails with review instructions and preserves records.
  6. Test insufficient database privileges and invalid connection settings; confirm the API never begins listening. Verify frontend config fallback while the API is unavailable.

API starter routes

  • GET /api/health - basic health check
  • GET /api/config - returns public runtime config used by the frontend
  • POST /api/auth/register - create account
  • POST /api/auth/login - log in
  • GET /api/auth/me - resolve active session
  • POST /api/auth/logout - log out
  • GET /api/sources - list sources (supports search and type query params)
  • GET /api/sources/:id - source details with relations and linked character IDs
  • POST /api/sources - create source (mod/admin)
  • PATCH /api/sources/:id - update source (mod/admin)
  • POST /api/sources/:id/cover - upload source cover image (mod/admin)

Shared runtime config flow

Frontend runtime config resolves in this order:

  1. GET /api/config (live API values)
  2. Last good config cached in localStorage
  3. Frontend .env defaults

This keeps the app usable when the backend config API is temporarily unavailable.