Architecture — C4 Diagrams
← BillingOne Overview | Event Flow →
L1 — System Context
Where does PolicyOne sit in the platform, and how does it relate to BillingOne?
Rendering diagram…
L2 — Container View
Which containers inside PolicyOne participate in the BillingOne integration?
Rendering diagram…
L3 — Component View (PolicyOne Bind Pipeline)
How do the internal components of the PolicyOne App interact when an agent binds a quote?
Rendering diagram…
Database Tables Involved
policy.event_outbox
Written atomically at bind. Drained by OutboxPublisher.
-- Relevant columns
CREATE TABLE policy.event_outbox (
id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
policy_id uuid NOT NULL REFERENCES policy.policies(id),
tenant_id uuid NOT NULL,
event_type text NOT NULL, -- 'policy.bound'
payload jsonb NOT NULL, -- PolicyEvent<PolicyBoundPayload>
sequence_num bigint NOT NULL, -- from policy.policy_sequence
status text NOT NULL DEFAULT 'pending', -- pending | processing | published | failed
published_at timestamptz,
failed_at timestamptz,
failure_reason text,
created_at timestamptz DEFAULT now()
);
policy.quote_billing
Holds the agent's billing election. Read by bindQuoteToPolicy() and included in the policy.bound payload.
CREATE TABLE policy.quote_billing (
id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
quote_id uuid NOT NULL UNIQUE REFERENCES policy.quotes(id) ON DELETE CASCADE,
payment_plan_code varchar(30) NOT NULL, -- 'pif' | 'quarterly' | 'monthly-12'
billing_method varchar(20) NOT NULL, -- 'direct_bill' | 'agency_bill' | 'mortgage_bill'
discount_codes jsonb NOT NULL DEFAULT '[]', -- [{code, pct, amount, reason}]
created_at timestamptz DEFAULT now(),
updated_at timestamptz DEFAULT now()
);
Redis Stream Layout
Stream: events:policy
Consumer groups:
billing-center ← BillingOne's PolicyEventsConsumer
claims-center ← ClaimsOne's PolicyEventsConsumer (coverage activation)
Message format (XADD):
Key: events:policy
ID: * (auto-generated by Redis)
Field: data
Value: JSON-serialised PolicyEvent<PolicyBoundPayload>
Each message is a single data field containing the full PolicyEvent<T> envelope — see the Payload Reference for the exact shape.