Enterprise-Grade Supply Chain Risk Engine & Real-Time Intelligence Command Center
SupplyChain-Risk-Engine-V2.mp4
Why this section exists: Provides immediate technical credibility and automated proof of build health, test coverage, and strict type safety for senior data system architects and recruiters.
- Python 3.12 / 3.13: Built for modern Python runtimes.
- CI Matrix: Multi-version test verification via GitHub Actions.
- CodeQL SAST: Automated static analysis security scanning.
- Zero-Error Ruff & Mypy: Strict linting and typing compliance.
Why this section exists: Highlights performance paradigms and structural enhancements delivered in the V2 engine upgrade.
The Supply Chain Risk Engine V2 is a high-throughput, B2B SaaS-grade command center engineered to ingest, validate, score, and visualize large-scale multi-tier supply chain data in real time.
- Zero-Copy Data Pipelines (Polars & DuckDB): High-speed vectorized lazy evaluations and zero-overhead out-of-core SQL cross-table joins.
- Strict Pandera Data Quality Gate: Complete schema boundary protection preventing unvalidated or malformed supplier CSVs from reaching engine core.
- Resilient HTTP & GenAI Layer: Integrated
httpx.Clienttimeouts andtenacityexponential backoff retries mapped to taxonomy categories (CAT_QUOTA,CAT_TIMEOUT,CAT_AUTH,CAT_SCHEMA,CAT_FALLBACK). - Argon2id Auth Gate & 1-Click Sandbox: Enterprise password security combined with instant read-only recruiter demo access.
- Glassmorphic Obsidian Command Center UI: Custom dark theme with neon cyan/indigo accents and non-laggy CSS backdrop blurs.
Why this section exists: Visualizes the raw data flow from multi-tier supplier CSV ingestion to executive C-suite briefings.
βββββββββββββββββββββββββββββ
β Multi-Tier Supplier CSVs β
βββββββββββββββ¬ββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββ βββββββββββββββββββββββββββββ
β Pandera Ingestion Gate β βββΆ β Out-of-Core DuckDB Joins β
βββββββββββββββ¬ββββββββββββββ βββββββββββββββ¬ββββββββββββββ
β β
βΌ βΌ
βββββββββββββββββββββββββββββ βββββββββββββββββββββββββββββ
β Polars Vectorized Risk β βββΆ β Live Threat Intel (RSS) β
β Scoring Engine β β & Open-Meteo Weather API β
βββββββββββββββ¬ββββββββββββββ βββββββββββββββ¬ββββββββββββββ
β β
βΌ βΌ
βββββββββββββββββββββββββββββ βββββββββββββββββββββββββββββ
β Structured GenAI Briefingsβ βββΆ β Board PDF & HTML Reports β
β (Google GenAI Pydantic) β β & Interactive PyDeck Maps β
βββββββββββββββββββββββββββββ βββββββββββββββββββββββββββββ
Why this section exists: Explains the deterministic algorithmic foundation behind composite supplier threat calculations.
The engine computes a composite supplier risk index
Where:
-
Base Risk (
$S_b$ ): Standard normalized baseline risk score. -
Financial Risk (
$S_f$ ): Logarithmic scale of annual spend:$\frac{\ln(1 + \text{spend})}{\max(\ln(1 + \text{spend}))}$ . -
Operational Risk (
$S_o$ ): Tier floor calculation:$1.0 - \frac{\text{tier} - 1}{3}$ . -
Geopolitical Exposure (
$S_g$ ): Regional vulnerability coefficient (EMEA: 0.8, APAC: 0.7, LATAM: 0.6, NA: 0.3). -
Audit Staleness (
$S_a$ ): Half-life degradation ratio:$\min\left(1.0, \frac{\text{days since last audit}}{730}\right)$ .
Why this section exists: Provides repository scannability and highlights clean enterprise module separation.
SupplyChain-Risk-Engine-V2/
βββ .github/
β βββ workflows/
β βββ ci.yml # GitHub Actions CI matrix test runner
β βββ codeql-analysis.yml # SAST security analysis workflow
βββ ai/
β βββ genai_client.py # Google GenAI client factory
β βββ narrative_generator.py # Token-batched AI risk briefing generator
β βββ news_digest.py # Typed news synthesis generator
βββ engine/
β βββ duckdb_joins.py # Zero-copy DuckDB SQL queries
β βββ risk_scoring.py # Vectorized Polars scoring algorithms
βββ feeds/
β βββ rss_client.py # Non-blocking RSS news feed ingestion
β βββ weather_client.py # Open-Meteo climate disruption client
βββ geo/
β βββ map_builder.py # GPU-accelerated PyDeck geospatial rendering
βββ ingestion/
β βββ csv_loader.py # Optimized Polars CSV loader
β βββ validation_gate.py # Pandera schema enforcement gate
βββ reporting/
β βββ html_report.py # Jinja2 + Plotly interactive report builder
β βββ pdf_report.py # Board-grade executive PDF engine
βββ resilience/
β βββ http_client.py # HTTPX client + Tenacity retry taxonomy
βββ schemas/ # Pydantic v2 & Pandera domain models
βββ src/
β βββ auth/ # Argon2id security & session access gate
β βββ ui/ # Glassmorphism dark styles & CSS injection
βββ state/ # Streamlit session state contract
βββ telemetry/ # Loguru structured logging handlers
βββ tests/ # Comprehensive pytest suite
βββ app.py # Main Streamlit command center entrypoint
βββ requirements.txt # Production dependencies
βββ README.md # System documentation
Why this section exists: Delivers bulletproof, step-by-step instructions for developers onboarding onto the repository.
# 1. Clone the repository
git clone https://github.com/Ali-datasmith/SupplyChain-Risk-Engine-V2.git
cd SupplyChain-Risk-Engine-V2
# 2. Create and activate virtual environment
python3.12 -m venv venv
source venv/bin/activate
# 3. Install production dependencies
pip install -r requirements.txt
# 4. Launch Streamlit Command Center
streamlit run app.pyWhy this section exists: Demonstrates cloud readiness and zero-configuration Streamlit Community Cloud deployment.
- Fork or push repository to GitHub.
- Log in to Streamlit Community Cloud.
- Click New app, select your repository, branch (
main), and main file path (app.py). - (Optional) In Advanced Settings, add secrets for
GEMINI_API_KEYorGEMINI_MODEL. - Deploy! Dynamic
sys.pathresolution inapp.pyensures seamless startup.
Why this section exists: Proves software reliability through strict test execution and static analysis tooling.
# Run complete test suite (79+ unit & integration tests)
python -m pytest -v
# Run linting with auto-fixing
ruff check . --fix
# Run strict static type checking
python -m mypy --explicit-package-bases app.py theme.py engine/ ingestion/ feeds/ geo/ reporting/ resilience/ schemas/ state/ telemetry/ ai/ src/Why this section exists: Demonstrates real-world architectural maturity and awareness of operational boundaries.
- Current Limitations: RSS feed availability relies on external provider endpoints; Gemini GenAI quota depends on API tier limits.
- Production Roadmap:
- Integration with SAP/Oracle ERP webhooks.
- Multi-tenant Role-Based Access Control (RBAC).
- Streaming Kafka event pipeline ingestion.
Why this section exists: Guarantees legal compliance for open-source enterprise usage.
Distributed under the MIT License. See LICENSE for details.
