# Foodtruck Order

[![CI](https://github.com/adamrudolf-becube/foodtruck-order/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/adamrudolf-becube/foodtruck-order/actions/workflows/ci.yml)
[![Documentation](https://github.com/adamrudolf-becube/foodtruck-order/actions/workflows/cloudflare-pages.yml/badge.svg?branch=main)](https://github.com/adamrudolf-becube/foodtruck-order/actions/workflows/cloudflare-pages.yml)

An ordering system intended to increase throughput for solo foodtruck/kiosk operators. The current
milestone includes the protected product catalog, valid-product creation, editing, and deletion,
safe invalid-product rejection, and the authenticated tablet order-entry route with its
always-active current cart, direct/repeated product taps, total unit count, exact SEK gross total,
review correction, explicit safe abandonment, and bounded order-level operational metadata. A
provider-neutral checkout boundary with a deterministic local/test fake now exists, and explicit
non-commercial finalization atomically queues immutable product snapshots without checkout or sales.
Commercial finalization, kitchen or customer status screens, and payment/POS integration remain.

The current foundation includes a PostgreSQL-backed message plus the protected product catalog,
valid-product creation/editing/deletion, invalid-product rejection, and the order-entry route
through a layered Fastify API and React frontend. It includes automated tests, strict
quality/coverage, production builds, reproducible Docker setup, CI/artifacts, public API
documentation, and a conditional staging migration gate. Current validation and remaining work are
recorded in [docs/current-state.md](docs/current-state.md).

## Run the application

With Docker and Compose v2 installed:

```text
pnpm dev:start
# Open http://localhost:8080/
pnpm dev:stop
```

Compose initializes PostgreSQL through journaled migrations and deterministic seed data before
starting the backend, frontend, and gateway. The browser uses one origin for the page and API.
`dev:start` and `dev:stop` are the canonical local commands and both preserve the database: users,
products, and orders created through the local stack survive any number of restarts. Only
`pnpm db:reset`, whose name states the consequence, destroys that data.

## Develop and validate

Use Node 24.x and pnpm 10.34.5:

```text
pnpm install --frozen-lockfile
cp .env.example .env
pnpm quality
pnpm test
pnpm build
```

For hot reload, start standalone PostgreSQL with `docker compose up -d --wait postgres`, run
`pnpm db:migrate` and `pnpm db:seed`, then start `pnpm dev:backend` and `pnpm dev` in separate
terminals. The frontend is `http://localhost:5173` and proxies `/api` to backend port 3000.

For full Docker/browser validation:

```text
pnpm --filter @foodtruck-order/e2e exec playwright install chromium
pnpm validate:docker
```

`validate:docker` runs in its own Compose project (`foodtruck-order-validate`) on separate ports, so
it deletes only its own throwaway database and never the data created by `pnpm dev:start`.
`pnpm validate:docker:stop` removes that isolated stack afterwards. Linux hosts may need Chromium
system dependencies. `pnpm e2e:headed` is the optional visible-browser dev-mode command.

## Documentation

- [Architecture](docs/architecture.md) and [technology stack](docs/techstack.md).
- [Development setup and command catalogue](docs/development.md).
- [Testing strategy](docs/test-strategy.md).
- [CI, artifacts, and DoD enforcement mapping](docs/ci.md).
- [Docker](docs/docker.md).
- [Definition of Done](docs/definition-of-done.md).
- [Vertical Slice specification](docs/specs/001-vertical-slice/vertical-slice.md),
  [Application Zero plan](docs/specs/002-application-zero/README.md), and
  [Epic 003 Foodtruck Order MVP](docs/specs/003-mvp/README.md).
- [Current state](docs/current-state.md) and [latest AI handover](docs/ai-handover.md).
- [Documentation system and public API contracts](docs/documentation.md).

Build the static site with `pnpm docs:build`; preview with `pnpm docs:serve` at
`http://127.0.0.1:4175`. It renders Markdown, the committed OpenAPI contract in Swagger UI, and
TypeDoc's public TypeScript reference. The docs origin does not serve the backend API. The separate
publishing workflow uploads the generated site to Cloudflare Pages; no generated HTML is committed.

Markdown uses a 100-column target with automatic Prettier prose wrapping. Commands and detailed
conventions remain in the guides above, rather than this quickstart.
