Pre-sale / Underwriting — standalone architecture
Build just this flow: a quote arrives, a scorecard fans out to automated risk assessors (parallel scoring modules — wildfire, flood, prior loss…), and an underwriter decides accept/refer/decline. Advance the maturity stage to add the scorecard, then the event-sourced audit + AI, then scale.
Stage 1 · MVP. A Cloud Run Underwriting API + a Cloud SQL policy-configuration table with the accept/refer/decline state machine. A human can work a queue and decide.
Stage 2 · Scorecard. Consume QuoteRequested + product versions + cat-scores; fan the scorecard out to assessors via Pub/Sub; emit DecisionMade.
Stage 3 · Trust & AI. Make the policy-config event-sourced with a hash-chained (each entry fingerprints the previous one, so tampering is detectable) audit log (regulators need it), and add the propose-only RAG agent — its knowledge base is a governed (access-controlled, redacted) copy of that same event log.
Stage 4 · Scale. Add read replicas for queue/review reads, split the assessor fan-out across partitions, and run in multiple regions. The event-sourced core makes replay/audit at scale straightforward.
📖 Flow story — what really happens
Every cross-flow arrow is the same async handoff — no flow calls another directly. 1. The sending flow commits its data row plus an outbox row in one transaction. 2. A relay publishes the event to the event bus (Pub/Sub on GCP · EventBridge→SQS on AWS). 3. The bus's push-subscription POSTs it to the receiving flow's Cloud Run API, which processes it idempotently (duplicates ignored, deduped on event_id). Synchronous reads (e.g. getProductVersion) are plain request/response.
- The Underwriting API's push-subscription receives
QuoteRequestedfrom the bus (deduped onevent_id) and writes asubmissionrow to its own Cloud SQL. - It runs the scorecard, fanning out to risk assessors — cat-model peril scores, property characteristics, and the product's risk rules each add a weighted signal; the result is saved as a
scorecard_resultrow. - The score routes the case: clean → auto-accept; appetite flag (outside the risk profile this insurer chooses to accept) → refer to a human; hard rule breach (a disqualifying condition no human may override) → decline.
- The underwriter (or the AI agent within guardrails) decides; the decision is appended to the
uw_decisionlog on WORM storage (tamper-evident), stamped with the model + rule +product_versionso it's reconstructable for regulators. - The same transaction writes an
outboxrow; the relay publishesDecisionMade(accept|refer|decline)to the bus. - On
accept, Pricing's subscription picks it up next. The decision + eventual outcome (access-controlled, personal data removed) is also written to thedecision_log/rag_documentstore and embedded intopgvector, so the agent learns from real decisions.
Interfaces (black-box contract)
| Direction | Contract | Who |
|---|---|---|
| Consumes | QuoteRequested, ProductVersionPublished, peril scores | Customer, Product, Cat-model |
| Emits | DecisionMade {accept/refer/decline, actor} | Pricing, Case, RAG |