Technology-Agnostic Blueprint for Engineering Teams
Complete fraud state for 7 million active users
| Field | Type / Size | Purpose | Implementation Notes |
|---|---|---|---|
| fs | uint16 (0-1000) | Current fraud score | Single monotonic scale simplifies alert routing |
| fc | uint8 (0-100) | Confidence in fs | Simple % value; API maps to LOW/MED/HIGH |
| f | uint8 bitmap | 8 instantaneous risk flags | Fits in one byte; bitmap ops are O(1) in Redis |
| lh3 | uint32 | Last H3 index (β 20m @ res 10) | 4 bytes store the "where" |
| lt | uint32 | Unix-seconds of lh3 | 2Γ uint32 keeps epoch math trivial |
| ls | uint8 enum | Location source (GPS/WiFi/IP/Peer/Sensor) | Avoids string parsing on hot path |
| ph | uint8 (0-100) | Rolling peer-trust score | Used for quick gating of peer reports |
| lut | uint32 | Last time Tier 2 refreshed fs | Separates data seen vs analysis done |
| lvt | uint32 | Last time any event seen | For inactivity expiry / cold-start heuristics |
| hb_h3 | uint32 (optional) | Stable "home-base" cell | Only written when Tier 3 has high certainty |
1 hash Γ 14 bytes raw β 20 bytes after Redis zip-list overhead
7 million active users = 140MB total memory footprint
Each flag uses a single bit, allowing for efficient bitwise operations and minimal memory usage. All 8 flags fit in a single uint8, enabling O(1) flag checks and updates.
| Step | Logic | State |
|---|---|---|
| Fetch hot state | Pull usr:{id} hash (lh3, lt, f) | READ |
| Velocity check | v = haversine(lh3,newH3)/(t-lt); if v>Vmax set f.bit0 | WRITE f |
| GPS Γ IMU sanity | Compare Ξv from GPS to IMU vector; flag f.bit1 on mismatch | WRITE f |
| IP/VPN lookup | Test client IP against vpn_ips_bloom; if hit set f.bit2 | READ bloom |
| Update location | lh3=newH3, lt=t, ls=source, lvt=t | WRITE |
| Emit trigger | Publish (user-id, changedBits, lh3) β tier1_processed | β |
Pure stream processing: All math is stateless except 1-hop look-back, enabling horizontal scaling of Tier 1 micro-services.
| Sub-task | Cadence | Algorithm |
|---|---|---|
| Spatial baseline mining | 6-hour window | DBSCAN on 30-day history β home/work H3 clusters |
| Travel-corridor profiling | nightly | Frequent-itemset of (origin-dest) H3 pairs |
| Peer trust graph update | hourly | TrustGNN/PageRank on 7-day peer-edges |
| Bloom & map refresh | as feeds arrive | Re-build vpn_ips_bloom, bssid_loc_h3, sensor_loc_h3 |
Compressed location data β Kafka topics
Stateless checks, Redis update β€ 5ms
Single Redis hash read < 10ms P99
30s context analysis, score update
Baseline refresh, model training
/location-score-assessment
< 10ms
| Risk Tier | Tier 2 Frequency | Data Horizon | Extra Actions |
|---|---|---|---|
| HIGH (fs<300) | every event | 5 min | Push blocking webhook |
| MED (300-700) | 30s default | 30 min | Normal pipeline |
| LOW (>700) | 2 min | 2 hours | Opportunistic caching |
For every Redis write:
API can return last N reason codes alongside score. Flags map 1-to-1 to human-readable codes.
Trust score update (Tier 2):