Architecture Project Briefs

4-project ecosystem: A (this site) → B (Rating Engine) → C (Broker Portal) → D (White-label)

Flow:A (GMG Site)→B (Rating API)←C (Broker Portal)&D (White-label)

Project B: Rating Engine & Policy Administration API

Overview

Headless backend API — single source of truth for insurance product rating, quote generation, policy administration, and document generation. Consumed by Projects A, C, and D.

Key Features

  • •Product registry with cover levels (bronze/silver/gold)
  • •Rating factor engine (multipliers, flat loadings, discounts)
  • •Quote generation with IPT calculation
  • •Quote-to-policy binding with document generation
  • •Broker API key authentication
  • •Billing entries for broker account-based billing
  • •Document templates (IPID, policy wording, schedule, TOBA)
  • •Internal admin dashboard for managing products, rates, and viewing quotes/policies

Database Tables

  • •products — slug, name, category, ipt_rate, is_active
  • •cover_levels — product_id, slug, base_premium, features (jsonb)
  • •rating_factors — product_id, factor_name, factor_type, conditions (jsonb), value, priority
  • •brokers — name, slug, api_key, commission_rate, is_whitelabel, branding (jsonb)
  • •quotes — quote_reference, broker_id, product_id, risk_data, premiums, status
  • •policies — policy_number, quote_id, policyholder, cover dates, documents
  • •billing_entries — broker_id, policy_id, entry_type, amount, billing_month
  • •document_templates — product_id, doc_type, template_content, version

API Endpoints (Edge Functions)

  • •POST /api/quote — calculate premium from risk data
  • •POST /api/bind — convert quote to policy, generate docs
  • •GET /api/products — list active products and cover levels
  • •GET /api/policy/:id/documents — download policy documents
  • •GET /api/broker/billing?month=YYYY-MM — broker billing summary
  • •POST /api/broker/validate — validate broker API key

Rating Logic

1) Look up base premium from cover_levels → 2) Retrieve rating_factors for product → 3) Apply factors in priority order → 4) net_premium = base × multipliers + loadings - discounts → 5) ipt = net × ipt_rate → 6) gross = net + ipt → 7) If broker: commission = net × commission_rate

Project C: GMG Broker Management Portal

Overview

GMG-branded broker portal where insurance brokers log in, submit applications on behalf of clients, download policy documents, and view monthly billing statements. Account-based billing settled via BACS.

Key Features

  • •Broker email/password authentication (no self-registration)
  • •Dashboard with quick stats (policies, balance, pending quotes)
  • •Step-by-step application wizard (product → risk → policyholder → quote → bind)
  • •Searchable quotes & policies table with document downloads
  • •Monthly billing statements with PDF download
  • •API integration guide page (broker's API key + code examples)
  • •GMG Admin section: create brokers, manage commissions, view all billing, reports

Application Wizard Steps

  • •Step 1: Product Selection — choose product and cover level
  • •Step 2: Risk Details — dynamic form based on product type
  • •Step 3: Policyholder Details — name, address, email, phone, DOB
  • •Step 4: Quote Review — premium breakdown from Project B API
  • •Step 5: Confirmation & Bind — policy created, documents available

Database Tables (Local)

  • •broker_profiles — user_id, broker_name, company, api_key_ref, commission_rate
  • •application_drafts — broker_user_id, product_slug, form_data, step
  • •cached_policies — policy_number, product_name, premium, status, documents
  • •billing_statements — billing_month, total_premium, commission, net_due, is_paid

Integration

All API calls to Project B routed through edge functions (keeps API keys server-side). Edge functions act as proxy: frontend request → Project B API → response back to frontend.

Project D: White-Label Broker Storefronts

Overview

Generic-branded, multi-tenant insurance storefront. Each broker gets their own sub-path (e.g., insurance-platform.co.uk/brokera) with custom logo, colors, and product selection. ZERO GMG branding.

Key Features

  • •Multi-tenant routing: /:broker-slug for each broker's storefront
  • •Dynamic theming from broker config (logo, colors, company name)
  • •Product listing filtered to broker's enabled products
  • •Quote journey with dynamic forms per product type
  • •Premium breakdown display with cover level comparison
  • •Policy binding with document generation and download
  • •Basic analytics tracking per broker (page views, quotes, purchases)
  • •SEO-friendly with dynamic meta tags per broker

Route Structure

  • •/ — Generic landing page
  • •/:broker-slug — Broker's branded homepage
  • •/:broker-slug/products — Product listing
  • •/:broker-slug/:product — Product detail & quote journey
  • •/:broker-slug/quote — Quote results
  • •/:broker-slug/checkout — Bind/purchase flow
  • •/:broker-slug/confirmation — Policy confirmation & downloads

Dynamic Theming

On route mount, fetch broker config from Project B. Apply CSS custom properties dynamically (primary_color, secondary_color, accent_color). Swap logo, company name, contact details. Cache in localStorage.

Database Tables (Local)

  • •tenant_cache — broker_slug, config (jsonb), last_fetched, is_active
  • •quote_sessions — broker_slug, session_id, product_slug, form_data, status
  • •page_analytics — broker_slug, page_path, event_type, metadata

Important

No consumer authentication needed. Broker is the buyer for billing purposes. All rating logic from Project B. Consumers see only their broker's brand, never GMG or the platform brand.

📄 Full briefs saved at:

  • docs/PROJECT_B_BRIEF.md — Copy as first prompt for new Lovable project
  • docs/PROJECT_C_BRIEF.md — Copy as first prompt for new Lovable project
  • docs/PROJECT_D_BRIEF.md — Copy as first prompt for new Lovable project