CI passing on Python 3.12 / 3.13 · 20/20 tests green · MIT
SupplyChain-Risk-Engine ingests supplier CSVs, computes a weighted geo/delay/financial risk score per supplier, simulates disruption scenarios, and exports executive PDF reports. The compute layer is Polars and DuckDB; the interface is Streamlit. The application runs with no authentication and no required API keys.
Supply_Chain_Risk_Engine.mp4
Live instance: supplychain-risk-engine-r8djbttt6eah48khhsfcze.streamlit.app
| Layer | Technology | Why |
|---|---|---|
| Data processing | Polars | Primary dataframe engine for CSV ingestion and transforms |
| Analytics | DuckDB | In-process SQL for dashboard and Top-10 supplier queries |
| UI | Streamlit | Single-file app framework, deployable to Streamlit Community Cloud |
| Visualization | Plotly | Scatter-geo heatmap and scenario/weather charts |
| Reporting | FPDF2 + Pillow | Executive PDF generation (Pillow is FPDF2's rendering backend) |
| HTTP | Requests | RSS feed retrieval and Open-Meteo API calls |
| Numerics | NumPy | Z-score anomaly detection and risk math |
KPIs, a risk histogram, Z-score anomaly detection, and a Top-10 riskiest suppliers view backed by live DuckDB SQL.
Plotly scatter-geo map; marker size and color scale with supplier risk score.
Aggregates 8 RSS sources — Supply Chain Dive, Logistics Management, FreightWaves, DC Velocity, JOC, Hellenic Shipping News, Reuters Trade, Bloomberg Supply Chain. Keyword search and source filters. No API keys.
Region disruption multiplier (1–5x) with a baseline-vs-simulated chart. Computes inventory days-of-cover, shortfall probability, and lead-time projection from a port congestion index and labor strike input.
Open-Meteo integration (free, no key). Current conditions, LOW→SEVERE shipping risk classification, 24-hour wind and precipitation charts.
One-click FPDF2 executive report with flexible column auto-detection across CSV schema variants.
Zero-auth public demo. Neon terminal theme. Graceful module fallbacks on cold start.
| Component | Methodology | Weight |
|---|---|---|
| Geo Risk | Geographic exposure score | 40% |
| Delay Risk | Delivery/lead-time risk score | 30% |
| Financial Risk | Financial stability score | 30% |
Total Risk = (Geo × 0.40) + (Delay × 0.30) + (Financial × 0.30)
| Tier | Score Range |
|---|---|
| LOW | 0–25 |
| MEDIUM | 26–50 |
| HIGH | 51–75 |
| CRITICAL | 76–100 |
SupplyChain-Risk-Engine/
├── app.py
├── theme.py
├── pyproject.toml
├── requirements.txt
├── requirements-dev.txt
├── tests/
├── engine/
│ ├── ingest.py
│ ├── news_stream.py
│ ├── risk_model.py
│ └── scenario_sim.py
├── database/
│ └── risk_queries.py
├── components/
│ ├── alerts.py
│ ├── map_viz.py
│ └── views.py
├── utils/
│ └── pdf_gen.py
└── data/
Clone the repository:
git clone https://github.com/Ali-datasmith/SupplyChain-Risk-Engine.git
cd SupplyChain-Risk-EngineInstall dependencies and run the app:
pip install -r requirements.txt
streamlit run app.py| Field | Requirement | Accepted aliases |
|---|---|---|
supplier |
Required | supplier_name, vendor, name |
risk_score |
Required | risk, score, rating |
region |
Recommended | country, area, zone |
lat |
Required for map pages | latitude, y |
lon |
Required for map pages | longitude, lng, x |
pip install -r requirements-dev.txt
pytestRun a single test file:
pytest tests/test_risk_model.py -vThe suite contains 20 unit tests across 5 modules: risk_model, scenario_sim, alerts, risk_queries, pdf_gen. The Streamlit runtime is mocked in tests/conftest.py using pytest-mock and pyarrow, installed via requirements-dev.txt with Python-version markers.
CI is defined in .github/workflows/ci.yml and runs on a 3.12 / 3.13 matrix on every push and pull request.
Runs on Streamlit Community Cloud's free tier: in-memory only, no API keys, under 1 GB RAM at 100k rows.
- Pydantic input validation
- Pandera data quality gates
- Loguru structured logging
- GenAI-generated headline summaries for the Intelligence Feed
MIT
Ali-datasmith Email: rjptmhmmd@gmail.com