# Dashboard Local Development

Phase 4C Dashboard is mock-only, read-only and iPad-first. The UI loads through the Pinia Store and API Client from the mock-only Gateway. Fixtures remain only for unit tests and controlled demo fallback. Local E2E smoke tests validate the real mock Gateway -> Dashboard flow without real domain data.

## Voraussetzungen

- Node.js >= 20
- npm
- Python Gateway dependencies from `apps/api-gateway`

## Install

```bash
cd apps/dashboard
npm install
```

`node_modules/` and `dist/` are ignored and must not be committed.

## Gateway starten

```bash
make gateway-dev
```

Gateway URL:

- `http://127.0.0.1:8080/api/healthz`

## Dashboard starten

For an operator-testable full local stack, use:

```bash
make demo
# open the printed Frontend URL
make demo-stop
```

For frontend-only development:

```bash
make dashboard-dev
```

Dashboard URL:

- `http://127.0.0.1:5174`

## Environment

`apps/dashboard/.env.example`:

```env
VITE_API_BASE_URL=http://127.0.0.1:8080
VITE_JARVIS_DEMO_MODE=1
```

Rules:

- no secrets in `VITE_*`
- no Tailscale IPs
- no private hostnames
- no runtime paths
- AutoShorts page may show only safe status KPIs from the Gateway: pending review count, ready preview count, last pipeline status, and source health. No media previews, scripts, prompts, captions, render buttons, upload buttons, or publish buttons. The live read-only source is documented in `docs/integrations/autoshorts-live-contract-review.md`.

## Tests

```bash
make dashboard-test
make dashboard-build
make verify
make smoke-local
make smoke-operator-demo
make e2e-local
make visual-checklist
```

## API-only Smoke

```bash
bash scripts/smoke-local-dashboard.sh --skip-dashboard
```

## Full local E2E Smoke

```bash
make e2e-local
```

The harness starts:

- mock Gateway with `JARVIS_DEMO_MODE=1` and `JARVIS_ENV=development`
- Dashboard with `VITE_API_BASE_URL=http://127.0.0.1:<gateway_port>` and `VITE_JARVIS_DEMO_MODE=1`

Default ports remain:

- Gateway: `8080`
- Dashboard: `5174`

If a default port is occupied, the harness prints a warning and selects a free alternative port. It never kills foreign processes.

Optional explicit ports:

```bash
JARVIS_E2E_GATEWAY_PORT=18080 JARVIS_E2E_DASHBOARD_PORT=15174 make e2e-local
```

## Playwright browser setup

If Playwright reports that Chromium is missing:

```bash
cd apps/dashboard
npx playwright install --with-deps chromium
```

## Artefacts

Do not commit local QA artefacts. These paths are ignored:

- `.tmp/e2e/`
- `tmp/e2e/`
- `apps/dashboard/test-results/`
- `apps/dashboard/playwright-report/`

## Sicherheitsregeln

- Store/API Client is the central frontend data source.
- Fixtures are only unit-test/demo fallback data.
- Production mode has no silent fixture fallback.
- GET-only API client.
- No real FinanceManager endpoints.
- No Health DB.
- No Runtime paths.
- No POST/mutation flows.
- No iframes.
- No exact Finance values.
- No Health raw data.
- No screenshots/videos committed.

## Troubleshooting

If `make dashboard-test` reports missing dependencies, run `cd apps/dashboard && npm install` and retry.


## Phase 4D UX Acceptance

The mock-only Dashboard now includes a read-only module detail layout for Finance, Health, AutoShorts and System. `/autoshorts` is available as a safe mock detail route because AutoShorts is a first-class module card. Detail pages share ModuleDetailShell components, show max 3 safe KPIs, source health metadata, blocked actions and safe links only.

Local commands:

```bash
make dashboard-test
make dashboard-build
make e2e-local
make ux-acceptance
```

Still deliberately absent: real adapters, Health DB, Finance runtime, POST/mutation flows, uploads, report generation, iframes, charts, exact finance values and Health raw data.


## FinanceManager Read-only Adapter

Phase 5A adds an optional FinanceManager read-only adapter behind `FINANCE_ADAPTER_MODE`. Default is `mock`. `live_readonly` requires `FINANCE_API_BASE_URL` and calls only the approved GET endpoints documented in `docs/integrations/finance-readonly-adapter.md`. `disabled` returns a safe degraded Finance snapshot. Exact Finance values remain blocked; `ALLOW_EXACT_FINANCE_VALUES=1` is rejected.

Smoke, only with local FinanceManager running:

```bash
export FINANCE_API_BASE_URL=http://127.0.0.1:<finance-port>
make smoke-finance-live-readonly
```

Rollback:

```bash
FINANCE_ADAPTER_MODE=mock
```


## Phase 5B Finance Live Smoke

FinanceManager was validated locally in read-only mode against `http://127.0.0.1:8001`. The local start shape was `python -m uvicorn jarvis_finance.api.main:app --host 127.0.0.1 --port 8001` from the FinanceManager source repository using the existing local venv.

Validation command:

```bash
FINANCE_API_BASE_URL=http://127.0.0.1:8001 \
FINANCE_ADAPTER_MODE=live_readonly \
ALLOW_EXACT_FINANCE_VALUES=0 \
make smoke-finance-live-readonly
```

The smoke checks allowed GET endpoints, `/api/modules`, `/api/overview`, `source_type=http_api`, safe Finance `ModuleSnapshot` shape, and forbidden string absence. Raw Finance responses are not committed; see `docs/integrations/finance-live-contract-review.md` and `docs/integrations/finance-sanitizer-mapping.md` for redacted structural mapping. Rollback remains `FINANCE_ADAPTER_MODE=mock`.

## Health card with local probe

The dashboard continues to consume the same gateway contract. No Health detail UI, raw tables, medical values, files, PDFs, or Drive links are added by `local_probe`. The Health card/page may only display safe metadata categories such as pipeline status, freshness category, and open review count.
