flowchart LR
%% =========================================================
%% MOBILE EDGE
%% =========================================================
subgraph EDGE["Mobile Edge"]
USER["Consumer Mobile App"]
VENDOR["Vendor Mobile App"]
QUEUE["Encrypted Local Event Queue<br/>event_id • sequence • offline retry"]
REDUCE["On-Device Reduction<br/>sensor windows • movement summaries<br/>compressed raw chunks"]
USER --> QUEUE
VENDOR --> QUEUE
USER --> REDUCE
REDUCE --> QUEUE
end
%% =========================================================
%% API LANES
%% =========================================================
subgraph API["Regional API Layer"]
INGEST["Stateless Telemetry Gateway<br/>authenticate • validate • consent check<br/>rate limit • acknowledge batch"]
TXAPI["Transactional API<br/>tokens • purchases • redemptions<br/>profiles • campaigns • catalog"]
end
QUEUE -->|"Compressed event batches"| INGEST
USER -->|"Authoritative transactions"| TXAPI
VENDOR -->|"Authoritative transactions"| TXAPI
%% =========================================================
%% OPERATIONAL STATE
%% =========================================================
subgraph OPS["Operational Systems"]
OPDB[("Operational PostgreSQL<br/>authoritative application state")]
OUTBOX["Transactional Outbox"]
end
TXAPI --> OPDB
OPDB --> OUTBOX
%% =========================================================
%% DURABLE STREAM
%% =========================================================
subgraph STREAM["Durable Event Stream — Kafka / Redpanda"]
BEHAVIOR["mobile.behavior"]
GAMEPLAY["mobile.gameplay"]
LOCATION["mobile.location"]
SOCIAL["mobile.social"]
VENDOREVENTS["mobile.vendor"]
TRANSACTIONS["transactional.outbox"]
SENSOR["sensor.manifest"]
DLQ["rejected / dead-letter"]
end
INGEST -->|"Durable publish"| BEHAVIOR
INGEST --> GAMEPLAY
INGEST --> LOCATION
INGEST --> SOCIAL
INGEST --> VENDOREVENTS
INGEST --> SENSOR
INGEST -.->|"Invalid or prohibited"| DLQ
OUTBOX --> TRANSACTIONS
%% =========================================================
%% RAW ARCHIVE
%% =========================================================
subgraph BRONZE["Bronze Layer — Immutable Archive"]
OBJECT[("S3-Compatible Object Storage<br/>Parquet / Protobuf + Zstd<br/>replayable raw history")]
RAWCHUNKS[("Raw Sensor Chunks<br/>uploaded only when required")]
end
BEHAVIOR --> ARCHIVE["Archive Writer"]
GAMEPLAY --> ARCHIVE
LOCATION --> ARCHIVE
SOCIAL --> ARCHIVE
VENDOREVENTS --> ARCHIVE
TRANSACTIONS --> ARCHIVE
SENSOR --> ARCHIVE
ARCHIVE --> OBJECT
REDUCE -.->|"Deferred bulk upload"| RAWCHUNKS
SENSOR -.->|"Manifest references chunk"| RAWCHUNKS
%% =========================================================
%% STREAM PROCESSING
%% =========================================================
subgraph PROCESS["Stream Processing and Derivation"]
CANON["Canonicalizer<br/>deduplicate • normalize IDs<br/>correct timestamps • classify privacy"]
SESSION["Sessionizer<br/>game and group sessions"]
ZONEPART["Zone Partial Aggregator<br/>zone + time bucket + salt"]
ZONEREDUCE["Zone Final Reducer<br/>minute • hour • day windows"]
ATTR["Attribution Processor<br/>exposure → visit → redemption"]
USERFEATURE["User Feature Builder<br/>preferences • behavior • affinity"]
VENDORFEATURE["Vendor Feature Builder<br/>audience response • game preference"]
RECON["Transaction Reconciler<br/>tokens • purchases • rewards"]
SINK["Idempotent Warehouse Sink<br/>deterministic keys • upserts"]
end
BEHAVIOR --> CANON
GAMEPLAY --> CANON
LOCATION --> CANON
SOCIAL --> CANON
VENDOREVENTS --> CANON
TRANSACTIONS --> CANON
CANON --> SESSION
CANON --> ZONEPART
CANON --> ATTR
CANON --> USERFEATURE
CANON --> VENDORFEATURE
CANON --> RECON
ZONEPART -->|"Parallel salted windows"| ZONEREDUCE
SESSION --> SINK
ZONEREDUCE --> SINK
ATTR --> SINK
USERFEATURE --> SINK
VENDORFEATURE --> SINK
RECON --> SINK
%% =========================================================
%% ANALYTICAL STORAGE
%% =========================================================
subgraph WAREHOUSE["Silver and Gold Analytical Storage"]
CITUS[("PostgreSQL / Citus")]
USERGROUP["User Co-location Group<br/>distributed by user_id"]
VENDORGROUP["Vendor Co-location Group<br/>distributed by vendor_id"]
ZONEGROUP["Zone Co-location Group<br/>distributed by zone_id"]
REFERENCE["Reference Tables<br/>games • places • demographic bands<br/>model definitions"]
CLICKHOUSE[("Optional ClickHouse<br/>hot raw-event exploration<br/>real-time drill-down")]
end
SINK --> CITUS
CITUS --> USERGROUP
CITUS --> VENDORGROUP
CITUS --> ZONEGROUP
CITUS --> REFERENCE
CANON -.->|"Optional hot-event feed"| CLICKHOUSE
%% =========================================================
%% PUBLIC DATA AND MODEL INPUTS
%% =========================================================
subgraph EXTERNAL["Existing Analytical Inputs"]
PUBLICDATA[("Normalized Census / BLS<br/>PostgreSQL Warehouse")]
MODELREG["Model and Feature Registry<br/>definitions • versions • confidence rules"]
end
PUBLICDATA -->|"Geographic and demographic enrichment"| CITUS
MODELREG --> USERFEATURE
MODELREG --> VENDORFEATURE
MODELREG --> ATTR
%% =========================================================
%% SERVING LAYER
%% =========================================================
subgraph SERVING["Serving and Decision Layer"]
ANALYTICS["MT Analytics Engine"]
FEATUREAPI["Feature and Segment API"]
DASHBOARD["Vendor and Internal Dashboards"]
RECOMMEND["Game, Venue, Product<br/>and Campaign Recommendations"]
LIVE["Live Zone Activity"]
RESEARCH["Research and Historical Analysis"]
end
USERGROUP --> FEATUREAPI
VENDORGROUP --> FEATUREAPI
ZONEGROUP --> LIVE
REFERENCE --> ANALYTICS
CITUS --> ANALYTICS
CLICKHOUSE -.-> DASHBOARD
OBJECT -.->|"Replay / batch analysis"| RESEARCH
ANALYTICS --> DASHBOARD
ANALYTICS --> RECOMMEND
FEATUREAPI --> RECOMMEND
LIVE --> DASHBOARD
%% =========================================================
%% REPLAY PATH
%% =========================================================
OBJECT -.->|"Replay after model, schema,<br/>or processor changes"| CANON
%% =========================================================
%% STYLING
%% =========================================================
classDef mobile fill:#e8f1ff,stroke:#315b8a,stroke-width:1px;
classDef gateway fill:#eef8ee,stroke:#38703d,stroke-width:1px;
classDef stream fill:#fff5db,stroke:#8a681f,stroke-width:1px;
classDef processor fill:#f5edff,stroke:#68428a,stroke-width:1px;
classDef storage fill:#f3f3f3,stroke:#555,stroke-width:1px;
classDef serving fill:#e8f8f7,stroke:#28706b,stroke-width:1px;
classDef optional stroke-dasharray: 5 5;
class USER,VENDOR,QUEUE,REDUCE mobile;
class INGEST,TXAPI gateway;
class BEHAVIOR,GAMEPLAY,LOCATION,SOCIAL,VENDOREVENTS,TRANSACTIONS,SENSOR,DLQ stream;
class CANON,SESSION,ZONEPART,ZONEREDUCE,ATTR,USERFEATURE,VENDORFEATURE,RECON,SINK processor;
class OPDB,OUTBOX,OBJECT,RAWCHUNKS,CITUS,USERGROUP,VENDORGROUP,ZONEGROUP,REFERENCE,PUBLICDATA,MODELREG storage;
class ANALYTICS,FEATUREAPI,DASHBOARD,RECOMMEND,LIVE,RESEARCH serving;
class CLICKHOUSE optional;