SYSTEM DEEP-DIVE
Area 3: Automated Billing
The event compression pipeline — 196 Stripe event types compress through a single surface before fanning out to 5 subsystems and ~50 downstream services.
Recompute engine evaluates all 5 stores, determines correct dunning state, applies minimal diff. The critical path — failure here leaves accounts in undefined state.
Grants and revokes feature access based on subscription state changes. ~50 product services read entitlements at runtime.
Manages payment mandates — the authorization agreements between customers and payment providers for recurring charges.
Invoice finalization and charge attempts. Processes invoice.paid, invoice.payment_failed, and related Stripe events.
Downstream distribution. Every processed event publishes to PGQ, which bridges to Kafka for the ~50 consuming services.
| Table | Owner | What It Stores | Access Pattern |
|---|---|---|---|
| subs_dunning | Area 3 | Dunning state per account — retry count, escalation level | A3 recompute reads + writes |
| subs_account | Shared | Account flags, billing profile, bad_debt status | A1 writes profiles, A3 writes bad_debt |
| subs_customer | Shared | Stripe ↔ CF customer mapping | A1 setup, A2 checkout |
| subs_mandate | Area 3 | Payment mandates — authorization agreements | A3 reads + writes |
| subs_stuck_events | Area 3 | Unprocessed webhook events — the orphan store | A3 writes, ops reads |
| Stripe | External | Payment status, mandates, invoice state | webhooks → all areas |
Area 3 is the event compression pipeline — 196 Stripe event types narrow to actionable state changes across five subsystems. The recompute engine is the critical path: it reads all stores and computes correct state in a single pass.