A zero-cost, high-performance Trust Engine that identifies complex fraud archetypes across 1M+ synthetic banking transactions with sub-second inference speed.
The executive dashboard provides real-time KPI tracking, fraud archetype distributions, and spatial-temporal risk metrics across all processed transactions.
Detailed spatial analysis mapping impossible travel hotspots, alongside velocity spike and behavioral drift detection metrics to identify compromised accounts.
An interactive alert management system allowing fraud analysts to filter by risk tier, review evidence (e.g., ground speed, Z-scores), and disposition cases in real-time.
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β GitHub Actions CI/CD β
ββββββββββββ¬βββββββββββββββββββ¬ββββββββββββββββ¬ββββββββββββββββ€
β BRONZE β SILVER β GOLD β INTERFACE β
β β β β β
β generatorβ Impossible Travelβ Risk Scores β Streamlit β
β .py β (Haversine/GPS) β (Composite) β Dashboard β
β β β β β
β 1M+ raw β Velocity Spikes β User Risk β Real-time β
β records β (60s windows) β Profiles β Watchdog β
β β β β β
β Parquet β Behavioral Drift β Fraud β SQL Explorer β
β β (Z-Score/30d MA) β Attribution β β
ββββββββββββΌβββββββββββββββββββΌββββββββββββββββΌββββββββββββββββ€
β Faker β DuckDB β dbt-core β Plotly β
β PyArrow β + dbt macros β + dbt tests β + Geo Maps β
ββββββββββββ΄βββββββββββββββββββ΄ββββββββββββββββ΄ββββββββββββββββ
| Archetype | Method | Threshold |
|---|---|---|
| Impossible Travel | Haversine distance + ground speed between consecutive transactions | > 500 mph |
| Velocity Spikes | 60-second sliding window transaction count | β₯ 10 txns / 60s |
| Behavioral Drift | Z-Score against 30-day rolling average | |Z| > 3Ο |
- Engine: DuckDB β vectorized, in-process OLAP
- Storage: Apache Parquet β columnar, compressed
- Pipeline: dbt-core β modular, tested, version-controlled SQL
- Orchestration: GitHub Actions β CI/CD on every push
- Interface: Streamlit + Plotly β executive-level dashboard
pip install -r requirements.txtpython run_pipeline.pyThis will:
- Generate 1M+ synthetic transactions with injected fraud
- Run all dbt models (Silver enrichment + Gold aggregation)
- Run dbt data integrity tests
- Export Gold tables to Parquet
- Generate dbt documentation and data lineage graph
- Print a summary report with model evaluation metrics
streamlit run dashboard/app.pydbt docs serve --profiles-dir riskmetric --project-dir riskmetric# Generate data only
python generator.py
# Run dbt models only (with full refresh for incremental models)
cd riskmetric
dbt run --profiles-dir . --project-dir . --full-refresh
dbt test --profiles-dir . --project-dir .
dbt docs generate --profiles-dir . --project-dir .Banking Sentinel/
βββ generator.py # Bronze: 1M+ synthetic transaction generator
βββ run_pipeline.py # Full pipeline orchestrator
βββ config.yml # Centralized thresholds & calibration config
βββ requirements.txt # Python dependencies
βββ data/ # Generated data (gitignored)
β βββ raw_transactions.parquet # Bronze layer
β βββ user_profiles.parquet # Bronze layer
β βββ riskmetric.duckdb # DuckDB warehouse
βββ riskmetric/ # dbt project
β βββ dbt_project.yml # dbt config + vars for threshold calibration
β βββ profiles.yml
β βββ macros/
β β βββ haversine.sql # Haversine distance macro
β βββ models/
β βββ staging/ # Raw β Staged
β β βββ stg_transactions.sql
β β βββ stg_user_profiles.sql
β βββ silver/ # Fraud detection (incremental)
β β βββ silver_impossible_travel.sql
β β βββ silver_velocity_spikes.sql
β β βββ silver_behavioral_drift.sql
β βββ gold/ # Curated risk models
β βββ gold_risk_scores.sql
β βββ gold_user_risk_profiles.sql
β βββ gold_fraud_attribution.sql
β βββ gold_model_evaluation.sql # Precision/Recall/F1
β βββ gold_threshold_calibration.sql # Threshold sensitivity
βββ dashboard/
β βββ app.py # Streamlit dashboard (8 pages)
βββ .github/workflows/
βββ pipeline.yml # CI/CD automation
The composite risk score (0β100) is a weighted sum of detected fraud signals:
| Signal | Weight | Rationale |
|---|---|---|
| Impossible Travel | 40 pts | Strongest signal β rarely a false positive at >500 mph |
| Velocity Spike | 35 pts | Card testing precursor β high urgency for blocking |
| Behavioral Drift | 25 pts | Spending anomalies β higher FP rate, requires human review |
Risk Tiers: CRITICAL (β₯60) Β· HIGH (β₯35) Β· MEDIUM (β₯25) Β· LOW (<25)
All weights and tier cutoffs are externalized as dbt variables in dbt_project.yml and documented in config.yml, enabling data-driven recalibration without code changes.
The pipeline computes full classification metrics against ground-truth labels:
| Metric | Description |
|---|---|
| Precision | TP / (TP + FP) β how many flags are real fraud |
| Recall | TP / (TP + FN) β how much fraud is caught |
| F1-Score | Harmonic mean of Precision and Recall |
| False Positive Rate | FP / (FP + TN) β operational noise level |
| Confusion Matrix | Full TP/FP/FN/TN breakdown per archetype |
The gold_threshold_calibration model evaluates detection performance across a range of thresholds per archetype, producing precision-recall tradeoff curves for optimal operating point selection.
- Initial weights set by domain expertise (fraud analyst heuristics)
- Threshold sensitivity analysis via
gold_threshold_calibrationβ tests speed thresholds (200β800 mph), velocity counts (3β20 txns), and Z-Score bounds (1.5β5.0Ο) - Validation against labeled ground truth using
gold_model_evaluationβ reports precision, recall, and F1 per archetype - Production path: weights would be tuned via logistic regression coefficients or gradient-boosted model feature importances; periodic recalibration (quarterly) as fraud patterns evolve
Silver-layer models use dbt's incremental materialization strategy:
- On first run: full table build
- On subsequent runs: only processes transactions newer than
MAX(transaction_timestamp)in the existing table - Use
--full-refreshflag to force a complete rebuild
This mirrors production patterns where millions of daily transactions are processed incrementally rather than rebuilt from scratch.
| Page | Purpose |
|---|---|
| Overview | Executive KPIs, fraud by archetype, timeline, accuracy |
| Impossible Travel | Speed distribution, geo map, flagged transactions |
| Velocity Spikes | Burst analysis, amount patterns |
| Behavioral Drift | Z-Score distribution, amount vs rolling average |
| User Profiles | Per-user risk aggregation, tier filtering |
| Model Evaluation | Precision/Recall/F1, confusion matrix, calibration curves |
| Triage Queue | Alert case management with disposition workflow |
| Raw Explorer | Ad-hoc SQL queries against DuckDB warehouse |
- Self-labeled data: Fraud is injected by the same system that detects it, creating circular validation. A production system would use externally labeled data or blind holdout sets.
- No temporal train/test split: All evaluation is in-sample. Production deployment would require forward-looking validation on unseen future data.
- Static thresholds: Current thresholds are fixed. A production system would use adaptive thresholds that adjust to evolving fraud patterns (concept drift).
- Scale ceiling: DuckDB handles 1M+ records locally with ease. At 1B+ records, consider partitioned Parquet, incremental dbt models with date-based partitioning, and migration to cloud OLAP (Snowflake/BigQuery).
- No real-time stream: Current architecture is batch-oriented. Real-time fraud detection would require a streaming layer (Kafka + Flink) feeding into the same model logic.