# MRP QR Code System A single-container, self-hosted Manufacturing Resource Planning (MRP) app built around printable QR-coded traveler cards. Designed for small fabrication shops running on an Unraid server with phone-based operators. ## Status **Step 1 of the build plan** is in this commit: repo scaffold, Prisma schema, Docker build, and authentication (admin email + password; operator name + 4-digit PIN with 12h device session). Everything downstream — project / assembly / part CRUD, QR generation, operator scan flow, PDF travelers, fasteners & POs, dashboards, STEP viewer, QC — is planned but not yet implemented. See [`docs/BUILD-PLAN.md`](docs/BUILD-PLAN.md) for the sequenced roadmap. ## Core concepts - **Project → Assembly → Part → Operation.** Each operation is one shop-floor step (cut, bend, rivet, weld, …) and gets its own printable QR card. - **Single claim.** Only one operator can hold an operation at a time; other scans show it as in-progress. - **Two roles.** Admins (email + password) plan the work. Operators (PIN) execute it from their phones. - **Files.** STEP / PDF / DXF / SVG upload per part; STEP viewer will render in-browser so phones don't need a CAD app. - **Purchasing.** Fasteners roll up across a project into PO drafts. - **Online only.** The server lives in the shop; no offline/PWA queueing. ## Stack - Next.js 15 (App Router) + React 19 + TypeScript - Prisma + SQLite (file-backed, on a single `/data` volume) - Tailwind CSS 4 - bcryptjs for password / PIN hashing - Zod for input validation and environment parsing ## Local development Prerequisites: Node 20+, npm. ```bash cp .env.example .env # edit .env and set APP_SECRET to at least 32 random chars npm install npx prisma migrate dev --name init npm run db:seed # creates the bootstrap admin from .env npm run dev ``` Visit http://localhost:3000 and sign in as the bootstrap admin. ## Docker / Unraid deployment See [`docs/DEPLOY.md`](docs/DEPLOY.md). In short: ```bash docker compose up -d --build ``` The container runs `prisma migrate deploy` on every start and creates a bootstrap admin on first boot if none exists. All persistent state lives in the `/data` volume (`app.db` + `uploads/` + `backups/`). ## Environment All env vars are documented in [`.env.example`](.env.example). `APP_SECRET` must be set and at least 32 characters in production. ## Project layout ``` app/ Next.js routes (UI + /api/*) components/ Shared React components lib/ env, prisma, auth, session, password, audit, request helpers prisma/ schema.prisma + migrations/ scripts/ seed.ts and future ops scripts docker/ entrypoint.sh docs/ Project docs (DEPLOY, BUILD-PLAN, ARCHITECTURE) ``` ## Not in this repo The top-level `AGENTS.md`, `SKILLS.md`, `hubs/`, and `skills/` directories are the coding-agent instruction suite this project was started from. They are reference material for AI assistants and are not shipped in the Docker image (they are listed in `.dockerignore`).