How the simulated risk evaluation engine computes scores.
The risk engine lives in app/risk.py. It takes a Business object and returns a score from 0–100, a risk level label, and a breakdown of every component that contributed to the final score.
The engine is deliberately simulated. It uses deterministic industry and country modifiers combined with controlled randomness (random.uniform). This makes it statistically testable — high-risk inputs reliably trend toward higher scores — while still producing varied results across multiple evaluations of the same business.
industry_modifier = 0.0industry = (business.industry or "").lower()if industry in HIGH_RISK_INDUSTRIES: industry_modifier = random.uniform(15, 30)elif industry in LOW_RISK_INDUSTRIES: industry_modifier = random.uniform(-20, -5)
The industry field is lowercased before matching. Unrecognised industries produce a modifier of 0.0.
country_modifier = 0.0country = (business.country or "").lower()if country in HIGH_RISK_COUNTRIES: country_modifier = random.uniform(15, 25)
Sanctioned or high-risk countries add between 15 and 25 points. The recognised values are: north korea, iran, syria, russia. All other countries produce a modifier of 0.0.