Status: Early-stage development. The project is functional in parts, but not yet a complete playable experience.
Live deployment: z-venture.vercel.app
Z Venture is a browser-first RPG prototype built with Next.js App Router, Prisma, and PostgreSQL. It includes account creation/sign-in, game creation/continuation, map-based location movement, and save snapshots.
- Account flow: sign up, sign in, logout, cookie-based sessions
- Per-user game profiles: create new game, continue last game
- Save model: auto-saves on location changes + manual/quick save endpoint
- Game pages: main status, inventory, map, game settings placeholder
- Home pages: about, settings placeholder, route-level auth redirects
- Reliability/security primitives: retry wrapper for DB calls, request rate limiting, security headers
- Framework: Next.js 16 (App Router)
- Language: TypeScript (strict mode)
- UI: React 19 + Tailwind CSS v4
- Database: PostgreSQL
- ORM: Prisma 7 + Neon adapter (
@prisma/adapter-neon) - Tests: Jest + Testing Library (jsdom)
- Package manager: pnpm
app/— routes, layouts, server actions, API routes, UI componentsutils/— game data, DB helpers, retry/validation/rate-limit logic, shared typesprisma/— Prisma schema/config and generated client outputlib/— Prisma client setup and client-only local save helper__tests__/— unit/component tests for UI and utility behaviorelectron/— lightweight Electron wrapper that loads deployed web app
/— home/signin— sign-in form/signup— sign-up form/login— redirects to/signin(308)/new— create a new game/continue— continue a saved game/about— project about page/settings— home settings placeholder
/game— current game dashboard (stats, inventory summary, saves, current location)/game/inventory— inventory details/game/map— location map + movement actions/game/settings— game settings placeholder
GET /game/api/health— simple health check payloadPOST /game/api/save— creates a manual save from current game state
- Session token is stored in an HTTP-only cookie named
session - Session records are persisted in the
Sessiontable with expiry - Session lookup resolves current user by token
- Game routes block unauthorized users via
unauthorized() - Sign-in and sign-up actions are rate-limited
Core entities in prisma/schema.prisma:
User(credentials, timestamps, last game pointer)Session(token-based auth sessions)Game(owned by user)Save(snapshot history for a game)GameState(state payload linked to one save)
Key relationship notes:
- One
User→ manyGame - One
Game→ manySave - One
Save→ oneGameState - Game names are unique per user (
@@unique([username, name]))
Create a .env file in the project root.
Required:
DATABASE_URL="postgresql://USER:PASSWORD@HOST:PORT/DBNAME"Optional:
NEXT_PUBLIC_BASE_URL="http://localhost:3000"NEXT_PUBLIC_BASE_URL is used by /login redirect; when missing, it falls back to http://localhost:3000.
pnpm installpnpm db:push
pnpm db:genpnpm devApp default URL: http://localhost:3000
pnpm dev # next dev
pnpm build # next build
pnpm start # next start
pnpm lint # eslint
pnpm test # jest
pnpm test:watch # jest --watch
pnpm db:push # prisma db push (with npx fallback)
pnpm db:gen # prisma generate (with npx fallback)Current test coverage focuses on navigation and utility behavior:
__tests__/homeButtons.test.tsx__tests__/navBar.test.tsx__tests__/sideNav.test.tsx__tests__/urls.test.ts__tests__/strFmtCheck.test.ts- additional component tests in
__tests__/
Run tests:
pnpm test- DB operations are wrapped with exponential-backoff retry helper (
withRetry) - In-memory request rate limiting is applied to:
- sign-in attempts
- sign-up attempts
- save endpoint requests
- Global security headers configured in
next.config.tsinclude:X-Frame-OptionsX-Content-Type-OptionsReferrer-PolicyPermissions-PolicyContent-Security-Policy
electron/index.js opens the hosted app URL in an Electron shell. This is separate from the Next.js local dev workflow.
DATABASE_URL environment variable is not set- Add
DATABASE_URLto.envand restart the process.
- Add
- Prisma client issues after schema change
- Re-run
pnpm db:pushthenpnpm db:gen.
- Re-run
- Unauthorized page while accessing
/game- Sign in first; ensure session cookie exists and has not expired.
- Rate-limit errors during auth/save tests
- Wait for the configured window to reset and retry.
This repository is licensed under CC BY-NC-ND 4.0.
In plain terms, this code is shared for viewing/reference under the license terms; do not use it commercially or create derivative works outside what the license permits.