# BluKavant customer workspace

A standalone TypeScript + Express reconstruction of `BluGrid_Sample.McpExamples.McpCustomerDemo`, using the real `@blukavantui/web` Grid, Drawer and Button components. It runs without OutSystems, Service Studio or either MCP server.

## Run locally

Requires Node.js 24 or newer.

```sh
npm ci
npm run build
npm start
```

Open **http://127.0.0.1:3375/** and choose **Continue as editor**. **Explore as viewer** demonstrates read-only access. The local demo uses public demonstration credentials (`editor` or `viewer`, password `local-demo`); it binds to loopback and refuses non-loopback binding with those credentials.

For development with live frontend updates and server restart:

```sh
npm run dev
```

If a preview is already running, stop it or use `PORT=3376 npm run dev`.

## What works

- 250 clearly labeled synthetic customer records in SQLite.
- BluKavant grid search, column filtering/sorting, status filter and pagination.
- Edit customer name, seats and revenue through a BluKavant drawer; cancel does not save.
- Server-side validation with the original limits: name 1–200 characters, seats 0–1,000,000 integer, revenue 0–1,000,000,000 with at most two decimals.
- Version and complete-baseline checks prevent lost updates. Conflicts preserve the draft.
- Atomic batch saves, canonical response records, audit entries, and idempotency for repeated requests.
- Editor/viewer permissions enforced on the server, session cookies, CSRF checks, and sign-out.
- Responsive layout and Light / Dark / System appearance.

The dataset is new sample data, not a copy of the live OutSystems database. The source screen edits only Name, Seats and Revenue, so Active, Joined and LastActivity are read-only here. The original shared OutSystems save action supports additional fields for other screens; that wider capability is intentionally outside this screen migration.

## Persistence and configuration

`data/customers.sqlite` is created on first startup and seeded only when empty. Browser refreshes and server restarts preserve changes. SQLite stores revenue as integer cents. Keep the database and its WAL files together when taking a live filesystem backup, or use SQLite's backup facility.

| Variable | Default | Purpose |
| --- | --- | --- |
| `PORT` | `3375` | HTTP port |
| `HOST` | `127.0.0.1` | Listening address |
| `DB_PATH` | `data/customers.sqlite` | Database file |
| `APP_PASSWORD` | unset | Password for the `editor` account; minimum 12 characters. Disables demo accounts and demo buttons. |
| `NODE_ENV` | unset | `production` requires `APP_PASSWORD` and enables Secure cookies; serve behind HTTPS. |

Production mode uses a single configured editor account. It is a small independent application, not a migration of OutSystems user identities, SSO or role assignments. Sessions are held in memory and are revoked on restart. For a shared production deployment, connect an identity provider and use an appropriate shared session store. No deployment was performed as part of this prototype.

## Project map

```text
client/        TypeScript UI, BluKavant components, responsive styles
server/        Express API, authentication, SQLite transactions
shared/        Customer and session types
tests/         API integration tests using a temporary database
vendor/        Pinned BluKavantUI 0.9.0 package, including upstream notices
```

The SDK tarball is included, so running this app does not require the BluKavant website to be online. `npm ci` needs the npm registry for Express/build dependencies. The application itself makes only same-origin `/api` requests. Theme preference may use browser storage; customer records are stored only in SQLite.

## Verification

```sh
npm run check
```

This type-checks and builds the frontend, then runs API integration tests covering authorization, CSRF/origin rejection, validation, saves, idempotency, stale-version conflicts, tampered baselines, all-or-nothing batch behavior, concurrent writes, durable database reads and logout.

The browser test changed customer 102's seats from 62 to 63, reloaded the saved value, then restored 62 through the same API. The record's version increased to 3 as expected. There are no OutSystems writes.

## Migration provenance

This example reconstructs the saved MCP model of BluGrid_Sample.McpExamples.McpCustomerDemo. Live BluKavantUI MCP contracts were used. OutSystems MCP tool discovery and module inventory succeeded; the fresh screen extraction did not complete when Service Studio became unresponsive. Parity with the latest model remains unverified.

The public download includes application source, tests and the pinned web SDK. It excludes local databases, credentials, session caches, private MCP inventories and native model exports. On first startup it creates its own 250 synthetic customers. Component license and upstream notices remain inside the SDK package.

Guide: https://blukavantui.blutekmedia.com/export-outsystems
