SIMS Onboarding

Pedro & Vusal, joining cold while Joaquim is out (~2 weeks from Jun 2). Mission: get productive fast and land the client demo Jun 22-23. Gabriel is the other active SIMS dev.

The demo is the rollout gate. One machine (KM 850 II), one Plastaze VM, ~15-min scripted live demo to Simoldes execs. If it lands, the 8-factory R1-R8 rollout (Jul-Dec) unlocks.

Hard calendar spine

DateGate
Jun 12Cloudflare Tunnel + Pages live (DEV2-603). E2E suite (DEV2-631). HARD GATE
Jun 15All D2/D3/D4 merged + deployed to Plastaze VM. Feature freeze.
Jun 18Internal full-script dry-run (DEV2-606). Bug list + go/no-go.
Jun 19R1 Phase-2 deploy to Plastaze (DEV2-650).
Jun 21Paulo rehearsal — he plays the client. Final go/no-go.
Jun 22-23Demo.
Demo is NOT blocked by Xpert ERP (proGrow fallback is fine), multi-tenant DB, backups, or monitoring — those are rollout prereqs, not demo prereqs. Don't let rollout hardening eat demo time.

1 · What SIMS is

SIMS (Simoldes Industrial Monitoring System) is an MES for injection-molding factories. It replaces Simoldes' legacy proGrow platform with real-time OEE/KPI calculation straight from EWON IoT devices, plus a tablet-first manual-input layer for what machines can't self-report.

Two data sources, one KPI engine

Manual SIMS entries are canonical; proGrow is fallback/validation only and is being removed at D4.

2 · Monorepo + run it

Root: sims-project. Three independent git repos (each own .git).

RepoStackEntryPort
sims-backendPython 3.11+, FastAPI, SQLAlchemy async + asyncpg, Postgres 15, Alembic, Redis, JWTapp/main.py8000
sims-frontendReact 19, Vite 7, TS, TanStack Query, React Router 7, shadcn/Radix, Tailwind 4, i18next, idb, vite-plugin-pwasrc/App.tsx5173
sims-ingestionPython 3.11+, asyncua (OPC-UA), APScheduler, SQLite buffersrc/main.py
Doc-vs-code drift: older READMEs describe an MQTT pipeline. The live ingestion is OPC-UA polling (src/opcua_client.py, no mqtt_client.py). MQTT survives only as a local simulator path. Trust the code.

Run locally (Mac, Apple Silicon)

cd sims-backend && docker compose up -d   # whole stack
# services: redis db api ewon-sim ingestion mqtt-broker simulator frontend
# frontend :5173 · DB role sims_user / db sims_db

# api 500s on missing columns? local migration drift:
docker exec sims-api alembic upgrade head   # then restart api

# psql:
docker exec sims-db psql -U sims_user -d sims_db -c "SELECT ..."   # NOT -U postgres

# frontend stale ("Network Error" while logged in):
cd sims-backend && docker compose restart frontend

G1 gates — run before every PR

RepoGates
backendmake lint · mypy app/ --strict · make test (cov 80% / 100% KPI). Full CI: make test-ci
frontendnpm run lint · npx tsc --noEmit · npm run test · npm run build
ingestionruff check src/ tests/ · black src/ tests/ · pytest

Frontend gotchas (day one)

Auth model: JWT middleware enforces auth only on /api/v1/*. /machine-data is exempt (X-API-Key server-to-server). Ingestion sends BACKEND_API_KEY; backend checks INGESTION_API_KEYthese must match or 401.

3 · Data pipeline end-to-end

EWON Flexy OPC-UA (opc.tcp://10.2.61.2:4840, ns=4, 24 tags of 651)
  → opcua_client.py polls every 5s, buffers a snapshot only when
    N_Ciclo (new cycle) or TS_Estado_RT (state change) flips → SQLite (30-day)
  → APScheduler every 60s POSTs ≤100 unsynced rows + heartbeat
  → api_client.py POST {BACKEND_API_URL}/machine-data   header X-API-Key
       machine_code via DEVICE_MAPPING {"KM850II":"KM 850 II"}
  → backend POST /api/v1/machine-data: X-API-Key → lookup Machine (404 if not seeded!)
       → classify event (ewon_parser) → SHA256 dedup → JSONB in production_events
  → frontend TanStack Query polls /machines/:code/status + /kpis/... every 10s
Machine seeding: the machines table is manually seeded, no auto-seed. /machine-data returns 404 if a code isn't there. Mapping gotcha: OPC topic KM850II (no spaces) ↔ DB/frontend KM 850 II (spaces) — DEVICE_MAPPING must be in the .env compose reads.

4 · Backend domain + KPIs

Models in app/models/: machines, production_events (raw JSONB), stoppages/stoppage_codes, rejections/rejection_codes, work_orders (OFs) + moulds + machine_mould_runs, operators/sessions/tablets, kpi_snapshots, proGrow sync tables. ~30 routers in app/api/v1/.

KPI engine — app/services/kpi_calculator.py (~2200 lines)

proGrow: PROGROW_USE_MOCK gates the sync loop. Slated for removal from calculate_oee/teep/ppm at D4 (DEV2-602). Setting USE_PROGROW_FALLBACK=False does NOT make it standalone — it only governs the /stoppages read path.

5 · Current state

MilestoneTargetState
D1 FoundationMay 4Done nav, tablet auth, PWA, manual-input scaffolding
D2 Core Manual InputsJun 1~99% — all 4 named demo-blockers closed
D3 Dashboards & IntegrationJun 221.5% demo runs against these · unassigned
D4 proGrow EliminationJun 300% · holds Epic 16 (demo coordination)
D5 Multi-Tenant DBJul 22rollout prereq, not demo
R1 Plastaze → R8Jul-Dec8 factories, proGrow off by year-end
In-flight code: branch DEV2-tablet-device-pairing, 31 commits ahead of main, open PRs #94 (backend) + #104 (frontend) since May 27. Bundles per-machine PIN login + moulds/cavities schema (5 migrations) + OF-start mould-run lifecycle. Shipped with no Linear ticket / AC — now governance-ticketed (DEV2-705/706/707/708).

Deploy topology — don't confuse the three

6 · Client commitments (verbatim)

Paulo Brás (Simoldes Operations), 2026-05-27 — closing EWON/Xpert questions:

The "ask" of Simoldes IT: only outbound HTTPS (443) from the VM to Cloudflare + Firebase/GCS, and validate a public domain. NO inbound ports / VPN / fixed IP. The IT-security review of this architecture is the rollout gatekeeper — confirm it was sent/approved.
Paulo's tolerance bar: "nem 1 peça nem 1 minuto" lost before any proGrow termination; Procimo's internal bar is <1%. Unresolved conflict — DEV2-545.

7 · Demo script (Jun 22-23)

Canonical: docs/sims-demo-script.md (~15 min, 12 sections, European Portuguese):

  1. Supervisor login (/login)
  2. Machines overview (KM 850 II + KM1300 live)
  3. Machine detail (Produção/Timeline/Validação/Diagnóstico)
  4. +5. Tablet provisioning + activation
  5. Machine identify + handover
  6. Operator clock-in (keypad) + manual input
  7. Rejection registration
  8. Stoppage justification (1ª Peça OK = honest "Em breve" placeholder)
  9. A Minha Sessão (audit trail)
  10. Relatório Tempo de Trabalho (central D2 deliverable, CSV in proGrow schema)
  11. Admin
Script-vs-code drift: the script narrates device-code tablet provisioning; the shipped flow is per-machine PIN. Reconcile narration with the live PIN flow before rehearsing.

8 · Risk register

IDRiskSev
STOP-1"N por justificar" badge recomputes from raw events and never decrements as operators justify — wrong on screen.crit
CLOCK-01Clock-in on a new machine doesn't close the prior open session → inflated Tempo de Trabalho + double-counted parts.crit
PGW-*Overview/Timeline still render proGrow numbers next to canonical SIMS KPIs, no staleness badge — can visibly disagree.high
Mould 404Unknown mould 404s as "Máquina não encontrada" (should be "Molde"). Re-verify fix held.high
DEV2-535Bulk-justify lacks shift-boundary check. Paulo demanded shift-scoped edits. (Carries DEV2-599's requirement.)high
Stoppage↔WOFrontend StoppageResponse TS type missing work_order_id (backend sends it). Low-effort fix.low
The one test everyone defers: 768px tablet Docker smoke with real KM 850 II data (offline cache + queue). No agent can do it — by hand, before sign-off.

9 · Demo-readiness checklist

Run the actual docs/sims-demo-script.md flow on the demo VM and confirm each.

Functional path

Data integrity + infra

10 · Ownership split

Nothing in D3/D4 had an owner. Suggested split (your tickets carry the detail):

DevLaneTickets
Pedro
DEV2-703
Work Order Management (recommended D3 starter, no external blocker) + "próxima OF" tile (Paulo-demanded)DEV2-346 · 359 · 360 · 536
Vusal
DEV2-704
proGrow Comparison + cut (the demo's credibility story) + evidence packageDEV2-347 · 361 · 362 · 602 · 604
Shared w/ GabrielCloudflare (Jun 12 gate), runbook, dry-runs, demo-visible data bugsDEV2-603 · 605 · 606 · STOP-1 · CLOCK-01 · PGW-*
Blocked (escalate via Paulo)Xpert ERP — needs Simoldes IT DB2/MS-SQL creds + FIRM_CODE. Soft for demo.DEV2-345 · 354 (owner TBD)

Governance tickets filed 2026-06-01

You can and should create tickets as you find gaps — team Dev Team - Joaquim, milestone D3/D4, link the onboarding doc.

11 · Who to ask

12 · First-day runbook

  1. Clone all three repos; cd sims-backend && docker compose up -d; alembic upgrade head if api 500s.
  2. Open :5173, log in as supervisor, click through /machines → machine detail → admin.
  3. Read docs/sims-demo-script.md and run the flow locally (operator + supervisor paths).
  4. Read your Linear ticket — DEV2-703 (Pedro) / DEV2-704 (Vusal). It's your queue.
  5. Run the G1 gates on a no-op change to confirm your toolchain.
  6. Pull the open tablet-PIN branch (DEV2-tablet-device-pairing); PRs #94/#104.
  7. Post in #ops-weekly-updates that you're onboarded; sync with Gabriel on the split.

Compiled 2026-06-01 from codebase, Linear (D2/D3/D4 + cycle 8), Gmail (Paulo EWON/Xpert + rollout plan), Slack #ops-weekly-updates, Granola notes, and the docs/ audit set. Dated decisions override older ones. · Source: docs/ONBOARDING-pedro-vusal-2026-06.md