CLIENT RISK
Intelligence · AI
The pipeline

How Client Risk Intelligence works

A transparent, end-to-end look at every step — from raw public data to the risk and opportunity scores you see on the dashboard.

Step 1
Ingest — free public data, no API keys

Whenever you click Refresh (per-company or globally), the backend pulls fresh data from four free public sources:

  • Yahoo Finance (unofficial JSON) — company profile, latest quote, price history for the chart.
  • Google News RSS — up to 20 latest news items per company, keyed on a fingerprint so we never store duplicates.
  • SEC EDGAR (data.sec.gov) — recent filings (8-K, 10-Q, 10-K, etc.) for US-listed companies.
  • World Bank — macro indicators used for country context.

Every fetch is written to ingestion_logs so you can audit success/failure per source.

Step 2
Normalize into events

Each interesting item becomes a row in the events table with a stable (company, source, source_ref_id) key. Types include:

news
filing_8-K
filing_10-Q
filing_10-K
stock_drop
stock_surge

A stock move automatically becomes an event when the daily change exceeds ±5%.

Step 3
Analyze with AI — grounded on the event

For every new event the platform calls the Lovable AI Gateway (default: Gemini) with a structured prompt that returns strict JSON. There are no free-text hallucinations: the output schema forces the model to fill each field.

{ executive_summary, // 1-2 sentences business_impact, // effect on your engagement risk_level, // low | medium | high | critical probability, // 0..1 confidence, // 0..1 priority, // P1 | P2 | P3 | P4 opportunity, // boolean recommended_actions[], // 2-4 bullets suggested_followup // concrete next step }

You can switch the model at any time on the Settings page.

Step 4
Score — a transparent 0-100 formula

After each refresh we recompute three scores per company using the last 30 days of analyses + stock quotes:

weight = { low:5, medium:15, high:30, critical:50 } risk_score = Σ (weight × probability) for risk events // capped 0-100 opportunity_score = Σ (weight × probability) for opportunity events // capped 0-100 stock_health = 50 + (avg_daily_%_move × 5) // clipped 0-100 health_score = stock_health − risk_score/2 + opportunity_score/4 // clipped 0-100

The full breakdown (counts + avg move) is stored on every risk_scores row for audit.

Step 5
Alert — only what matters

An alert is automatically created when an analysis returns:

  • risk_level = high or critical, or priority = P1 → severity high/critical alert
  • opportunity = true → an info-level opportunity alert

Everything below that stays in the timeline but doesn't page you.

Step 6
Ask the AI Analyst

On any company page you can chat with an analyst that only sees that company's ingested events, scores and profile. It won't invent numbers — if data is missing it will tell you what to ingest.

Honest limits. This is an open MVP with no login. Free data sources rate-limit, news is polling not push, and coverage of SEC filings is US-only. Everything is fetched on demand — no historical backfill beyond what the sources return.