LoreDuel is a Next.js App Router game prototype: a solo 3-battle campaign with optional wallet-backed live adjudication on GenLayer.
Project status: MVP complete (playable vertical slice), not full production.
- 3-battle campaign flow (tutorial -> midgame -> boss)
- Stance/status combat model with turn memory and chronicle log
- Demo mode (no wallet required)
- Optional wallet mode for live verdict relay
- Automatic fallback to local verdict logic if chain/RPC fails
- Local persistence (run/profile/settings)
- Minimal backend APIs for profile/runs/events/health/metrics
- E2E + unit/integration test coverage
- Next.js 16 (App Router)
- React 19 + TypeScript
- Framer Motion
- Playwright + Vitest
- Optional Postgres (
pg) for server persistence
npm install
npm run devOpen: http://localhost:3000
npm run dev- start development servernpm run build- production buildnpm run start- run built appnpm run lint- eslintnpm run test- unit/integration tests (vitest)npm run test:e2e- Playwright end-to-end testsnpm run db:migrate- apply Postgres schema migrationsnpm run smoke:read- read smoke test for GenLayer contractnpm run smoke:write- write smoke test for GenLayer contract
Create .env.local (optional for MVP demo, required for live mode/hardening):
# Live GenLayer (optional)
NEXT_PUBLIC_GENLAYER_RPC_URL=https://studio.genlayer.com/api
NEXT_PUBLIC_GENLAYER_CONTRACT_ADDRESS=0x...
NEXT_PUBLIC_GENLAYER_NETWORK=studionet
# API protection (recommended outside local dev)
API_WRITE_TOKEN=replace-with-strong-token
ANALYTICS_INGEST_TOKEN=replace-with-strong-token
# Postgres mode (optional)
ENABLE_POSTGRES=true
DATABASE_URL=postgres://...- Default: file store at
.data/server-store.json - Optional: Postgres when
ENABLE_POSTGRES=trueandDATABASE_URLis set
GET/PUT /api/profile/:walletGET/POST /api/runsGET/POST /api/eventsGET /api/healthGET /api/metrics(Prometheus format)
app/
api/ # route handlers
layout.tsx
page.tsx
src/
components/
LoreDuelApp.tsx # compatibility export
loreduel/
LoreDuelApp.tsx # main UI container
constants.ts # UI constants/types
lib/
game.ts # core game loop/state
genlayer.ts # chain adapter + fallback
storage.ts # client persistence
analytics.ts
tx-history.ts
server/
repository.ts # file/pg repository layer
store.ts
rate-limit.ts
validation.ts
styles/
loreduel.css
npm run lint
npx tsc --noEmit
npm run test
npm run test:e2e- mandatory managed Postgres + backup/restore drills
- alerting/SLO/on-call/runbooks
- security hardening (threat model, contract audit, abuse controls)
- deeper content pipeline + localization
Details: see PRODUCTION_READINESS.md.