# Restaurant ERP

Local-First / LAN-Only restaurant operations system: one Go server (REST API + SSE realtime +
embedded web frontend) with local PostgreSQL as the single source of truth. No cloud database,
no internet required for daily operations, single tenant (Acme Restaurant Co. / Main Branch).

## Stack

- **Backend:** Go 1.25 (chi router, pgx), embedded migrations, structured logging.
- **Frontend:** React 19 + TypeScript + Vite + Tailwind 3 + TanStack Query + zustand + recharts (embedded in the binary).
- **Database:** PostgreSQL 16 (local). Money: NUMERIC(19,4) + shopspring/decimal. No float money.

## Quick start (development)

Prerequisites: Go 1.25, Node 24, pnpm 11, local PostgreSQL with `erp` user and
`restaurant_erp` database (see .env.example for the dev connection string).

```bash
./scripts/dev.sh      # Go server :8080 (auto-migrates) + Vite :5173 with proxy
./scripts/seed.sh     # seed demo data (idempotent; run after the server created the schema)
```

Open http://localhost:5173 (dev) or http://localhost:8080 (embedded production build).
Demo accounts (dev only): `admin`, `manager`, `cashier`, `waiter`, `kitchen`,
`host`, `driver`, `storekeeper`, `accountant` — password `demo1234`.

## Production build

```bash
./scripts/build.sh    # pnpm build → embed → go build -o bin/restaurant-erp
```

The binary serves the UI from :8080 on the LAN (http://restaurant.local or http://<ip>:8080).
Windows service registration lives in `installer/windows/`.

## Tests

```bash
./scripts/test.sh     # go test ./... + web lint/typecheck/build
```

API-level E2E suites live in `tests/e2e/` and run against a live server:

```bash
ERP_BASE=http://127.0.0.1:8080 bash tests/e2e/run-all.sh   # 6 suites, ~10 min
```

Suites: waiter journey, takeaway, purchasing (PO → partial receive → invoice →
three-way match → supplier payment), reservations/seating (incl. double-booking
guards), concurrency (parallel fire/payment/reservation), and the offline
acceptance test (T53) that restarts the server and verifies data integrity.

## Architecture

See `docs/architecture/adr/` for decisions (Local-First, Go Core, PostgreSQL SoT, Embedded React,
LAN access, no public inbound, signed updates, license grace, backup/restore, AI adapter,
internal-only delivery, deferred external integrations). Execution state: `plan.md`,
detailed task plan: `EXECUTION_PLAN.md`.
