Production System Blueprint
A production healthcare equity platform that rewards verified health behavior with deterministic, geographically weighted incentives — recorded in an auditable, append-only ledger.
The architectural invariant that governs every other decision: the PostgreSQL reward ledger running on Hetzner is the single system of record for every action verified, every point credited, every pool allocation, and every Participation Impact Score assignment.
Snowflake is a downstream analytics mirror and never holds authoritative balance state. No component outside PostgreSQL can originate reward state, and no component inside PostgreSQL depends on an external system being available to remain consistent.
The system is organized as a modular monolith during MVP with defined extraction points for later distribution.
Native iOS in Swift/SwiftUI as the primary surface, Android in Kotlin with Jetpack Compose, and a Next-generation web companion for account management, redemption flows, and the internal admin console.
Caddy reverse proxy handles TLS 1.3 termination, HSTS enforcement, and request routing. Cloudflare sits in front at scale for DDoS protection and geographic distribution.
A thin HTTP boundary that delegates immediately to the domain service layer — UserService, VerificationService, RewardEngineService, RewardLedgerService, and PoolAllocationService.
PostgreSQL 16 as the single system of record, Redis 7 for sessions, rate limiters, and BullMQ queues, and S3-compatible object storage for binary artifacts and archived audit logs.
Snowflake with dedicated virtual warehouses for ETL ingestion, BI querying, and ML workloads — supporting equity modeling and cohort research without touching the operational hot path.
Hash-chained audit logs and append-only ledger tables protect every recorded event, with outbound-only integrations isolated from inbound traffic.
The Signature Innovation
The HCV engine computes a deterministic reward multiplier from regional population density, healthcare access, and outcome scarcity — amplifying rewards for users whose participation produces greater marginal public health impact.
Persons per square kilometer at the Census tract level, sourced from the U.S. Census Bureau American Community Survey. Normalized inversely with logarithmic compression.
A composite of primary-care providers per 10k residents, mean distance to qualified facilities, and preventive-care availability — sourced from HRSA AHRF and CMS provider enrollment data.
A composite reflecting how far regional baseline outcomes fall below benchmarks — premature mortality, preventable hospitalizations, and chronic disease prevalence per County Health Rankings.
Each input is normalized to the unit interval, then combined through a weighted linear combination:
Default weights are wPD=0.3, wHAI=0.4, wOSF=0.3, prioritizing healthcare access as the most direct indicator of systemic underservice. The multiplier is bounded between RMmin=1.0 (no user is ever penalized relative to the base schedule) and RMmax=2.5 (preserving economic sustainability).
Every point movement is recorded as a paired debit and credit with database-enforced invariants. Every transaction sums to zero. No entry is ever updated or deleted — corrections are implemented as compensating transactions, preserving complete history.
Application database users hold insert-only privileges on ledger tables. Update and delete privileges exist only for break-glass administrative accounts whose use generates audit alerts. Balances are never stored as mutable state — they are computed by aggregation.
Submissions pass syntactic, semantic, and evidentiary validation. Self-attested actions carry lower base rewards than externally verified actions — creating a steep gradient toward HealthKit, Health Connect, pharmacy claims, and provider feeds.
Reward pools define a scope predicate, a funded amount, an allocation algorithm, and a time window. Funding sources include platform reserves, institutional grants, public-health partnerships, and content-neutral sponsor contributions.
Each completion writes the action row, paired ledger entries, streak updates, milestone awards, and a domain event in a single PostgreSQL transaction. Any failure rolls back the entire change — no partial state ever escapes.
The transactional outbox pattern guarantees every state change emits a durable event atomically — no event can ever be lost to a downstream failure.
Every service method that produces a state change inserts a row into domain_events within the same transaction. The log is partitioned by month, online for ninety days, archived indefinitely to object storage.
Workers consume events with SELECT FOR UPDATE SKIP LOCKED for concurrent safety. Notifications, streaks, milestones, and Snowflake replication all run as independent worker pools.
Any derived system — a Snowflake table or a notification history — can be rebuilt by iterating the event log with fresh consumer logic. No primary database restore required.
Saint Daniels operates at the intersection of healthcare privacy law, financial regulation, and state insurance law — and the security posture integrates all three regimes simultaneously.
LUKS at rest, pgcrypto column-level encryption for PHI with keys held in a separate key management service, TLS 1.3 in transit, mutual TLS within the server boundary, and immutable cryptographically chained audit logs replicated nightly to object storage with seven-year retention.
Every infrastructure transition is justified by a specific measured condition. No transition is performed speculatively.
A single Hetzner AX52 running the full Docker Compose stack. Closed beta over six months, with Snowflake feeding initial dashboards.
PostgreSQL extracts to a dedicated AX102 host with a read replica. The first institutional sponsored pools go live. Annual fairness audit published.
Load-balanced application hosts, dedicated Redis and worker hosts, RewardLedgerService and PoolAllocationService extracted to independent services. Multi-state expansion begins.
Core ledger services extracted, GPU host introduced for ML verification, multi-region PostgreSQL with logical replication.
Fairness is computed, not marketed. Integrity is auditable, not asserted. Scale is earned, not anticipated.
Every reward traces to a specific verified behavior, weighted by a specific published fairness formula. Every ledger entry is recorded in an append-only audit trail. Every infrastructure decision is governed by measured demand. The platform that results is one in which users in underserved and low-density regions receive amplified reward weighting — because their participation produces amplified public health value.