Přeskočit obsah

🔄 AML WORKFLOW - JAK TO FUNGUJE

Popis všech resilience patterns a flow diagramů.

📋 ZÁKLADNÍ FLOW

Request → 18 Parallel Modules → Aggregate Results → Risk Scoring → Response
           ↓
      (retry, circuit breaker, fallback)

🔁 RETRY MECHANISMUS

3 pokusy s exponential backoff:

Attempt 1: wait 0s  → try PRIMARY
Attempt 2: wait 1s  → try PRIMARY
Attempt 3: wait 2s  → try PRIMARY
Failed 3×: wait 4s  → try FALLBACK

⚡ CIRCUIT BREAKER

Ochrana proti opakovaným selháním:

if consecutive_failures >= threshold:
    state = OPEN
    skip_primary_api()
    use_fallback_immediately()

after cooldown_period:
    state = HALF_OPEN
    try_primary_again()

Prahy: - Sanctions: 5 failures → 10 min cooldown - Executions: 3 failures → 30 min cooldown - LEI/EUID: 3 failures → 10 min cooldown

🔗 FALLBACK CHAIN

Pro moduly s fallback:

PRIMARY API ❌
    ↓
FALLBACK Scraper (Playwright) ✅
    ↓
Result returned

Fallback scrapery: 1. Executions → exekuce.justice.cz 2. Justice → or.justice.cz/ias/ui/rejstrik 3. Court Decisions → nsoud.cz

📊 WEIGHTED RISK SCORING

weighted_score = raw_score × weight

# Příklad:
sanctions_score = 20 × 1.5 = 30.0
pep_score = 15 × 1.3 = 19.5
vat_score = 5 × 1.0 = 5.0

total = (30.0 + 19.5 + 5.0) / 100 = 54.5
level = HIGH (>50)

⏱️ PARALLEL EXECUTION

Všech 18 modulů běží současně:

results = await asyncio.gather(
    sanctions_check(),
    insolvency_check(),
    executions_check(),
    # ... všech 18 modulů
)

total_time = max(module_times)  # ne sum!

Typicky: 15-20 sekund (nejpomalejší modul)


Výsledek: Resilientní, rychlý, 100% completeness