STYL TollVision — Architecture Overview

Smart highway-toll platform: vision ANPR → event mesh → real-time revenue + exception handling · ★ = newest (registry/match · colour + body-type on every vehicle · iPhone edge · Atlantic plane) · reused from the monorepo: Solace · Eclipse Ditto · Keycloak · §11 camera options & cost ↓

1 · System overview

A camera/clip feeds the edge-detector; everything else talks over the Solace event mesh. toll-bridge is the ONLY writer of the stores; query-api only reads + publishes; the dashboard is the single public entry point.

flowchart TB Cam([Camera / recorded clip]):::actor Op([Toll operator]):::actor subgraph EDGE["Edge — any of: laptop/Jetson · iPhone app · smart cam (§11)"] direction LR ED["edge-detector
YOLO26 + fast-alpr
+ colour · body-type
1 event / vehicle"] IOS["edge-detector-iOS
iPhone on-device
(same pipeline)"]:::opt CI["camera-ingestor
profile atlantic (optional)"]:::opt end BR{{"Solace PubSub+ — event mesh (reused)"}}:::reuse subgraph SVC["car-identify services (new)"] direction LR TB["toll-bridge
SOLE writer
dedup · bill · match"] VLM["vlm-worker
profile ai
exception enrich"] QA["query-api
read · approve · registry"] DASH["toll-dashboard
nginx: SPA + /api + /plates"] end subgraph STORE["Stores (new)"] direction LR CH[("ClickHouse
events + revenue MV")] MIN[("MinIO
plate snapshots")] end subgraph REUSE["Reused / external"] direction LR DT[("Eclipse Ditto
registry + twin")]:::reuse KC[("Keycloak")]:::reuse QVL[("Qwen3-VL
DashScope")]:::reuse end Cam --> ED Op --> DASH ED -->|"detected / exception"| BR ED -. "device plane" .-> CI IOS -. "device plane" .-> CI CI -. "republish toll" .-> BR ED -->|"snapshot"| QA BR --> TB BR -->|"exception"| VLM VLM -->|"enriched"| BR VLM -->|"read crop"| MIN VLM -->|"re-read"| QVL TB -->|"write"| CH TB -->|"write twin"| DT QA -->|"read"| CH QA -->|"snapshot"| MIN QA -->|"read registry"| DT QA -->|"approved / registry"| BR DASH -->|"/api"| QA DASH -->|"/plates"| MIN DASH -->|"OIDC"| KC QA -->|"verify JWT"| KC classDef opt stroke-dasharray:5 5,fill:#eef3f8,stroke:#90a4b8,color:#333; classDef reuse fill:#eef3f8,stroke:#7b8a9c,color:#222; classDef actor fill:#e7ecf2,stroke:#5e6b78,color:#222; style ED fill:#ffe9c7,stroke:#e0922f,color:#222 style TB fill:#ffe9c7,stroke:#e0922f,color:#222 style VLM fill:#ffe9c7,stroke:#e0922f,color:#222 style QA fill:#ffe9c7,stroke:#e0922f,color:#222 style DASH fill:#ffe9c7,stroke:#e0922f,color:#222 style CH fill:#ffe9c7,stroke:#e0922f,color:#222 style MIN fill:#ffe9c7,stroke:#e0922f,color:#222

Single-writer invariant: only toll-bridge writes ClickHouse + Ditto. vlm-worker (profile ai) handles only the exception branch; camera-ingestor (profile atlantic, dashed) is an optional pre-hop, off by default. The only direct browser→service HTTP call is dashboard→query-api (same origin via nginx).

2 · Detection → billing (happy path)

High-confidence plate (≥ 80%): detected once per vehicle, billed exactly $3, on the dashboard in under ~2s.

sequenceDiagram autonumber participant V as Vehicle participant E as edge-detector participant Q as query-api participant M as MinIO participant B as Solace broker participant T as toll-bridge participant C as ClickHouse participant D as Dashboard V->>E: enters frame E->>E: YOLO track + line-cross (1 event / vehicle) E->>E: fast-alpr OCR → plate + confidence E->>E: OpenCV color + YOLO body-type (cheap, every vehicle) E->>Q: POST /api/toll/snapshot (plate crop) Q->>M: store → image_ref E->>B: publish detected/high {plate, image_ref, color, body-type} B->>T: deliver (subscribes STYL/iot/toll subtree) T->>T: match registry · build row (fee $3, ONCE) T->>C: insert toll_events (status=billed) Note over C: revenue MV updates (constant-time SUM) D->>Q: poll /revenue /recent Q->>C: read MV + latest rows Q-->>D: revenue · vehicles · live feed

Dedup by tracking-ID + line crossing → one toll event per vehicle (no 30× over-billing). Images are referenced (image_ref), never streamed through the broker.

3 · Exception path (low-confidence → VLM → approve)

Below 80%, the plate is queued, re-read by the Qwen3-VL worker, and one-click approved by an operator. Fee is applied exactly once — at detected OR at approved, never both.

flowchart TB DET{"plate OCR
confidence"} DET -->|"≥ 80%"| HI["detected/high
status=billed · fee $3"] DET -->|"below 80%"| LO["exception/low
status=pending · fee 0"] LO --> VLM["vlm-worker
Qwen3-VL re-read
+ make/model/color"] VLM -->|"enriched"| EP["enriched_pending
fee 0"] EP --> OP([Operator reviews on dashboard]) OP -->|"approve via Keycloak"| AP["query-api publishes approved"] AP --> BILL["toll-bridge → approved
fee $3 set ONCE here"] HI --> CH[("ClickHouse")] BILL --> CH style VLM fill:#ffe9c7,stroke:#e0922f,color:#222

vlm-worker subscribes only the exception topic; it enriches + republishes enriched and never writes the stores. Operator identity comes from the validated JWT, never the request body.

4 · Vehicle registry + match ★

A registry of known vehicles (ETC / account holders, blacklist, unpaid) lives in Ditto. Every detection is matched against it — turning "count + bill" into real ANPR. Edits respect the single-writer rule: they are published, then applied by toll-bridge.

flowchart TB subgraph REG["Register / edit a vehicle (operator)"] direction LR OP([Operator]) --> DASH["Dashboard
Registered Vehicles"] DASH -->|"POST /api/toll/vehicles"| QA["query-api"] QA -->|"publish registry/upsert"| BR{{"Solace"}} BR --> TB["toll-bridge
sole Ditto writer"] TB -->|"PUT attributes.registration"| DT[("Ditto
toll:vehicle:PLATE")] end subgraph MATCH["Match on EVERY detection"] direction LR DET["detection (plate)"] --> TB2["toll-bridge"] TB2 -->|"GET registration (30s cache)"| DT DT -->|"hit / miss"| TB2 TB2 --> ROW[("ClickHouse row
registered · owner · reg_status
+ make/model/color")] end style TB fill:#ffe9c7,stroke:#e0922f,color:#222 style TB2 fill:#ffe9c7,stroke:#e0922f,color:#222 style DT fill:#ffe9c7,stroke:#e0922f,color:#222

Best-effort, fail-open: no match → row still inserted + billed as an anonymous vehicle (registered=0); a Ditto outage never blocks revenue. Blacklist / unpaid are flagged on the console.

5 · Billing state machine (fee-once invariant)

The lynchpin of both billing correctness and the constant-time revenue view: a positive fee is written exactly once per track_id.

stateDiagram-v2 [*] --> billed: detected/high ≥80% · fee $3 [*] --> pending: exception/low below 80% · fee 0 pending --> enriched_pending: vlm enriched · fee 0 enriched_pending --> approved: operator approve · fee $3 pending --> approved: manual approve · fee $3 billed --> [*] approved --> [*] note right of billed fee positive set ONCE per track_id (only at detected and approved) so the revenue MV stays correct end note

Stored in toll_events (ReplacingMergeTree by gate_id, track_id); the toll_revenue_agg materialized view answers SUM(fee) in sub-second over billions of rows.

6 · Three stores — one job each

Structured data, binary blobs and live state are different problems, so they live in different engines. The row only keeps a pointer to the image.

flowchart LR TB["toll-bridge"] --> CH[("ClickHouse
structured rows
SUM(fee) · filter · sort")] TB --> DT[("Ditto
current state
registry + twin")] QA["query-api / edge"] --> MIN[("MinIO
JPEG blobs · TTL 7d")] CH -. "image_ref → object key" .-> MIN style CH fill:#ffe9c7,stroke:#e0922f,color:#222 style MIN fill:#ffe9c7,stroke:#e0922f,color:#222 style DT fill:#ffe9c7,stroke:#e0922f,color:#222

ClickHouse = ledger (numbers to aggregate). MinIO = filing cabinet (images; the browser loads them directly via /plates). Ditto = digital twin (mutable state). Putting blobs in the DB would kill OLAP speed.

7 · Topic taxonomy (Solace)

All toll traffic lives under one domain; toll-bridge subscribes the whole subtree, each other service a narrow slice.

flowchart LR ED["edge-detector"] -->|"gate/{g}/v1/vision/detected/{track}/high"| BR{{"STYL/iot/toll subtree"}} ED -->|"gate/{g}/v1/vision/exception/{track}/low"| BR VLM["vlm-worker"] -->|"gate/{g}/v1/vision/enriched/{track}"| BR QA["query-api"] -->|"gate/{g}/v1/vision/approved/{track}"| BR QA -->|"registry/v1/{action}/{plate}"| BR BR --> TB["toll-bridge
subscribes everything"] BR -->|"exception only"| VLM style TB fill:#ffe9c7,stroke:#e0922f,color:#222

Shape: STYL/iot/{domain}/{entityType}/{entityId}/v1/{function}/{action}. Registry action = upsert | delete. Isolation from the other demos is by the toll domain + unique Solace client names.

8 · Atlantic device-plane integration ★ optional

To let Atlantic manage the camera like any sensor, the edge can publish to the tenant-less ingress plane; a camera-ingestor maps camera→demo and republishes onto the toll domain — toll-bridge is unchanged. Default stays standalone (PUBLISH_PLANE=toll).

flowchart LR ED["edge-detector
PUBLISH_PLANE=device"] -->|"STYL/iot/device/image-camera/{camId}/..."| CI["camera-ingestor
compose --profile atlantic"] MAP[("device → demo mapping
local cfg / atlantic api")] -.->|"camId → domain + gate"| CI CI -->|"STYL/iot/toll/gate/{gate}/..."| TB["toll-bridge (unchanged)"] CI -->|"unmapped"| DROP["drop + count
never guess a domain"] style CI fill:#ffe9c7,stroke:#e0922f,color:#222 style MAP fill:#ffe9c7,stroke:#e0922f,color:#222

This is the camera-ingestor anticipated by Atlantic's topic-taxonomy. Demo runs from a local mapping; "Atlantic truly owns it" additionally needs the image-camera device + mapping registered in atlantic-super-admin (future).

9 · Auth flow

Reuses the shared Keycloak realm (no custom auth). Viewing the dashboard requires login; the approve + registry-edit actions require a valid token.

sequenceDiagram autonumber participant U as Operator participant W as Dashboard SPA participant KC as Keycloak (styl-iot) participant Q as query-api U->>W: open dashboard W->>KC: OIDC PKCE (onLoad login-required) KC-->>W: access token W->>Q: reads + POST approve / vehicles (Bearer) Q->>KC: fetch JWKS cached · verify JWT Q-->>W: data (mutations 401 without a valid token) Note over Q: operator_id taken from the token, not the body

Client vehicle-identification (public PKCE). No specific role required — any signed-in user can approve/register; the action is audited with their username.

10 · Deployment (docker-compose on the VM)

Single published port (atlantic pattern): the dashboard's nginx fronts everything. toll-bridge + query-api join the monorepo's network to reach Ditto. ClickHouse data + MinIO blobs persist on named volumes across the daily restart.

flowchart TB ALB["ALB / domain :443
vehicle-identification-uat"] --> DASH["car-identify-dashboard :8095
nginx (only published port)"] DASH -->|"/api"| QA["car-identify-query-api
internal"] DASH -->|"/plates"| MIN[("car-identify-minio
internal")] QA --> CH[("car-identify-clickhouse")] TB["car-identify-toll-bridge"] --> CH QA --> MIN subgraph EXT["monorepo backend network (reused, external)"] DTN["ditto-nginx → Eclipse Ditto"] end TB -. "join network" .-> DTN QA -. "join network" .-> DTN VLM["vlm-worker · profile ai"]:::opt CI["camera-ingestor · profile atlantic"]:::opt classDef opt stroke-dasharray:5 5,fill:#eef3f8,stroke:#90a4b8,color:#333; style DASH fill:#ffe9c7,stroke:#e0922f,color:#222 style QA fill:#ffe9c7,stroke:#e0922f,color:#222 style TB fill:#ffe9c7,stroke:#e0922f,color:#222 style CH fill:#ffe9c7,stroke:#e0922f,color:#222 style MIN fill:#ffe9c7,stroke:#e0922f,color:#222

Containers are restart: unless-stopped + the Docker daemon is enabled on boot → the stack self-recovers after the daily VM stop/start. Schema migrations (e.g. registry columns) are applied once and persist in the volume.

11 · Camera & device options — Singapore cost comparison Jun 2026

The platform is camera-agnostic: it only needs one toll.frame.v1 event per vehicle on Solace. So the "camera" can be anything from a webcam you already own to a tolling-grade ANPR unit. Four routes, cheapest→richest. Plate text, colour and body-type come from our edge software (YOLO26 + fast-alpr + OpenCV) for routes A–C; make/model is added by the Qwen3-VL worker on hard cases. Smart ANPR cameras (route D) read the plate on-camera but still need our pipeline for make/model and a small camera-ingestor-style adapter to publish onto Solace.

Approach Example hardware (SG) AI runs Plate (ANPR) Colour · type · make/model Approx price (SGD, ex-GST) Fit / notes
A · Reuse cameras you already have (software only) — cheapest
Existing CCTV/IP camera via RTSP + our edge on a spare PC/laptop Any installed ONVIF/RTSP cam + reused PC Off-camera (our service) ✓ fast-alpr ✓ colour+type (edge) · make/model via VLM ~S$0* Fastest PoC on installed gear. *uses hardware you own; one PC can serve several cameras.
B · Build new — ordinary IP camera + a compute box
4MP IP bullet + reuse a PC Hikvision DS-2CD2043G2 AcuSense / Dahua equiv. Off-camera (our service) ✓ fast-alpr ✓ colour+type · make/model via VLM ~S$100–180 Camera only; long-range/IR plate optics (varifocal) ~S$200–400.
4MP IP bullet + edge AI box (no server, 24/7) IP bullet + NVIDIA Jetson Orin Nano Super 8GB On the Jetson (edge) ✓ fast-alpr ✓ colour+type · make/model via VLM ~S$500–580 Jetson dev kit ≈ S$399. Self-contained lane unit; GPU runs YOLO26 comfortably.
4MP IP bullet + low-cost edge box IP bullet + Raspberry Pi 5 8GB + AI HAT+ (Hailo) On the Pi (edge) ✓ fast-alpr ✓ colour+type · make/model via VLM ~S$350–430 Pi 5 ≈ S$120 + AI HAT+ ≈ S$130. Cheapest dedicated 24/7 edge.
C · iPhone as an all-in-one edge (our TollEdge app) ★
iPhone = camera + compute in one (on-device) Reuse any recent iPhone, or a new iPhone 16 On-device (Neural Engine) ✓ Apple Vision OCR ✓ colour+type on-device · make/model via VLM S$0 reused · S$1,299 new App is free (free Apple ID for the demo). Zero rig, "AI in your pocket". See edge-detector-ios/.
D · Smart ANPR camera — plate read on-camera
Hikvision LPR/ANPR bullet Hikvision DS-2CD7A26G0-P-IZHS8 On-camera (plate) ✓ on-camera ≥98% ~colour/type (some models) · make/model via our VLM ~S$1,288 Needs a small adapter to publish plate→Solace. Best plate capture at speed/glare/night.
Hikvision ANPR (motorised varifocal) Hikvision DS-TCG405-E (4MP LPR) On-camera (plate) ✓ on-camera ~colour/type · make/model via our VLM ~S$1,180 Same integration as above. Varifocal for flexible lane distance.
Dahua ITC ANPR Dahua ITC413 / ITC415 series On-camera (plate) ✓ on-camera 95–98% ~colour/type · make/model via our VLM ~S$1,000–1,900 (quote) Distributor-quoted in SG; multilingual plate engine.
E · Enterprise / tolling-grade ANPR (free-flow, highway speed)
Dedicated tolling ANPR per lane Survision · TagMaster · Tattile · Genetec-certified On-camera (plate, certified) ✓✓ highway-speed, free-flow varies by vendor · make/model via our VLM ~S$3,000–8,000+ /lane (POA) Production highway gantries; overkill for the demo. Quote-only.

Recommendation. Demo: route A (reuse a camera) or C (iPhone) — ~S$0. A clean self-contained lane unit: route B with a Jetson or Pi 5+AI HAT. Production highway: route E. Whatever the camera, the back end (Solace → toll-bridge → ClickHouse → dashboard) is identical.
Prices are indicative, ex-GST, as of Jun 2026 and vary by distributor/lens/license; enterprise ANPR is quote-only (POA). Sources: Hikvision LPR SGD — sgcctv.com.sg · Jetson Orin Nano Super SGD — Ban Leong / Amazon.sg (US$249 list) · iPhone 16 SGD — Apple SG · Raspberry Pi 5 / AI HAT — Cytron SG. Make/model/colour: see §2–§4 (edge colour+body-type on every vehicle; Qwen3-VL make/model on exceptions).