pawankapkoti/manufacturing-compliance
<div align="center">
Manufacturing Compliance Dashboard
BRC/HACCP food safety compliance — replaces your Excel spreadsheets
Supports BRC compliance for fish production including RSPCA/GG grading, waterfall yield tracking, and batch traceability from catch area to packed product.
 ![Python]() 
</div>
Links
- GitHub
- Live Dashboard
- Hugging Face Space
- Profile
- Contributing: `CONTRIBUTING.md` · `GOVERNANCE.md` · `CODE_OF_CONDUCT.md` · `SECURITY.md` · `NOTICE` · `CHANGELOG.md`
If this dashboard is useful to you, a GitHub star helps discoverability for other food-safety teams with the same BRCGS audit problem.
Integration tests (ScanAPI)
The FastAPI layer has two layers of test coverage:
- Unit / in-process —
tests/test_api.pyuses FastAPI'sTestClientfor fast in-process tests (no network, runs in the main test job). - Integration / real HTTP —
scanapi/scanapi.yamldrives every endpoint over HTTP via ScanAPI (by Camila Maia and the ScanAPI org, MIT). Catches middleware / CORS / serialisation bugs TestClient skips. Runs locally viamake scanapiand on CI via theScanAPI integration testsworkflow.
Report lands in scanapi-report/ (gitignored). Point at a staging deploy by overriding the base URL: make scanapi BASE_URL=https://staging.example.com.
Companion tools
This dashboard is part of a small set of on-prem tools for regulated manufacturing data. The three work cleanly on their own but compose into a platform:
- [OpsMind](https://github.com/Pawansingh3889/OpsMind) — On-prem AI assistant for natural-language queries against the same manufacturing data this dashboard visualises. Operators ask questions in English, OpsMind generates SQL, the dashboard shows the audit-trail surface. See OpsMind's multi-plant deployment guide for the AKT 6 scope.
- [sql-sop](https://github.com/Pawansingh3889/sql-guard) — Static SQL safety layer (PyPI, ~1k monthly downloads). Validates SQL against 44 rules before execution. Same defence-in-depth philosophy this dashboard's read-only model uses.
What Problem Does This Solve?
Compliance officers in food manufacturing spend hours in Excel tracking batch traceability, temperature logs, allergen records, and weight variance. Auditors need instant answers. This dashboard replaces those spreadsheets with a live, searchable system that traces any product from catch area to packed product in seconds.
Key Features
- Full batch traceability — trace any product from ocean catch to packed shelf in 2 seconds
- Real-time temperature monitoring — automatic alerts when cold room readings breach limits
- Allergen matrix — covers all 14 EU allergens with changeover sequence tracking
- Weight variance analysis — z-score anomaly detection flags suspicious batches
- One-click audit reports — give auditors what they need without opening Excel
- RSPCA/GG golden rule enforcement — automated compliance checks against grading standards
- Natural language queries — auditors ask questions in plain English, get structured results
- MCP server — expose compliance data as tools for LLM agents (5 tools via FastMCP)
- Declarative validation — temperature, batch, and allergen data validated before import
- SLO monitoring — temperature compliance (95%), traceability completeness (90%)
- Centralized chart themes — consistent light/dark palette across dashboard and PDF reports
Auditor asks for Batch 4821's traceability chain. Someone spends 20 minutes in Excel. This dashboard does it in 2 seconds.
[Try the live dashboard →](https://manufacturing-compliance-dashboard-mjappkncanejzlfr5ngghik.streamlit.app) · [Hugging Face](https://huggingface.co/spaces/pawankapkoti/manufacturing-compliance)
See it run
<div align="center">
</div>
$ make setup && make run
┌─────────────────────────────────────────────────────────────┐
│ Manufacturing Compliance Dashboard │
│ │
│ ┌──────────────────────────────────────────────────────┐ │
│ │ COMPLIANCE SCORE │ │
│ │ Temperature Control: 99.1% ██████████████████████░ │ │
│ │ Traceability: 97.2% █████████████████████░░ │ │
│ │ Overall: 98.1% ██████████████████████░ │ │
│ │ Status: ✅ PASS │ │
│ └──────────────────────────────────────────────────────┘ │
│ │
│ Batches tracked: 674 │
│ Temperature readings: 8,640 │
│ Orders monitored: 271 │
│ Products in matrix: 16 │
└─────────────────────────────────────────────────────────────┘What it does — all 4 tabs
┌─────────────────────────────────────────────────────────────┐
│ TAB 1: BATCH TRACEABILITY │
│ │
│ Search: Batch COD-2024-0847 │
│ │
│ Raw Material Intake │
│ Supplier: FreshCatch Ltd │ Batch: RM-4821 │
│ Date: 2024-03-15 06:12 │ Temp: 1.8°C ✓ │
│ │
│ Production │
│ Line: 2 │ Shift: Morning │ Operator: J. Smith │
│ Input: 120kg │ Output: 114kg │ Waste: 6kg │
│ Yield: 95.0% │
│ │
│ Despatch │
│ Customer: Tesco DC North │ Order: ORD-9182 │
│ Temp at load: 2.1°C ✓ │ FEFO: ✓ │
│ │
│ Chain complete: Raw material → Production → Despatch ✓ │
│ Traceability score: 100% │
├─────────────────────────────────────────────────────────────┤
│ TAB 2: TEMPERATURE MONITORING │
│ │
│ ┌─ Cold Room 1 ──────────────────────────────────────┐ │
│ │ Current: 2.3°C │ Min: -2.0°C │ Max: 5.0°C │ │
│ │ Status: ✅ IN RANGE │ │
│ │ ──────────────────────────────────────── │ │
│ │ 3.1 2.8 2.3 2.5 2.1 2.4 2.3 (30-day trend) │ │
│ └────────────────────────────────────────────────────┘ │
│ │
│ ┌─ Zone D ────────────────────────────────────────┐ │
│ │ Current: -19.4°C │ Min: -25.0°C │ Max: -15.0°C │ │
│ │ Status: ✅ IN RANGE │ │
│ └────────────────────────────────────────────────────┘ │
│ │
│ Anomaly Detection (z-score): │
│ ⚠ Cold Room 2: 5.3°C at 14:22 — exceeds 5.0°C threshold │
│ ⚠ Duration: 47 minutes │ Trend: rising since 13:00 │
│ │
├─────────────────────────────────────────────────────────────┤
│ TAB 3: ALLERGEN MATRIX │
│ │
│ Product │ Fish │ Milk │ Egg │ Soy │ Gluten │ Nuts │
│ ───────────────┼──────┼──────┼─────┼─────┼────────┼──────│
│ Cod Fillets │ ● │ │ │ │ │ │
│ Fish Cakes │ ● │ ● │ ● │ │ ● │ │
│ Prawn Cocktail │ ● │ │ │ ● │ │ │
│ Fish Fingers │ ● │ │ ● │ │ ● │ │
│ │
│ BRC Section 5 compliant │ Export to CSV │ │
│ │
├─────────────────────────────────────────────────────────────┤
│ TAB 4: AUDIT REPORT │
│ │
│ [Generate Report] │
│ → Compliance score: 98.1% PASS │
│ → Temperature excursions: 3 (all <60 min) │
│ → Traceability gaps: 2 batches (97.2% coverage) │
│ → Allergen matrix: 16 products × 6 allergens │
│ → Shelf life concessions: 1 │
│ → Export: [PDF] [JSON] │
└─────────────────────────────────────────────────────────────┘Fish Production Compliance Features
Temperature Monitoring & Shelf Life
Temperature monitoring with breach detection linked to shelf life extensions (+2/+3 superchill). Excursions are flagged in real time with duration tracking, and breaches automatically trigger shelf life concession reviews.
Allergen Matrix
Allergen matrix supporting fish production allergens: fish, crustaceans, molluscs, wheat, egg, milk, and mustard. BRC Section 5 compliant with full cross-contact risk assessment and CSV export.
Batch Traceability
Batch traceability supporting OCM scan-back lineage with parent-child batch mapping. Every batch is traceable from catch area through processing to packed product, with full chain scoring.
Weight Variance Reconciliation
Weight variance reconciliation for BRC compliance across customer product lines. Input/output yields are tracked per batch with waterfall reporting to identify loss points.
Golden Rule Enforcement
The dashboard enforces the golden rule: RSPCA material can cascade down to GG products, but GG material can never be upgraded to RSPCA. Tail pieces are never packed into RSPCA products.
Architecture
ERP / PostgreSQL
|
v
[SQLAlchemy] --- database connection with retry
|
+---> [Batch Traceability] --- catch area to packed product
|
+---> [Temperature Monitor] --- z-score anomaly detection
|
+---> [Allergen Matrix] --- 7 allergen types
|
+---> [Weight Variance] --- BRC compliance
|
v
[Streamlit Dashboard] --- live at streamlit.app
|
v
[Sentry] --- error monitoring (opt-in)Build it
# Step 1: Clone and install
git clone https://github.com/Pawansingh3889/manufacturing-compliance-dashboard.git
cd manufacturing-compliance-dashboard
pip install -r requirements.txt
# Step 2: Seed 60 days of demo data
python data/seed_demo.py
# → Products: 10 | Production: ~500 | Orders: ~270
# → Temperature logs: ~19,000 (5 locations, 8 readings/day)
# → Raw materials: ~200 supplier deliveries
# Step 3: Run
streamlit run app.py
# → Dashboard at http://localhost:8501Or one-liner: make setup && make run
Configure for your factory
# config.yaml — edit thresholds per location
temperature:
locations:
Cold Room 1:
min: -2.0
max: 5.0
Cold Room 2:
min: -2.0
max: 5.0
Zone D:
min: -25.0
max: -15.0
Chiller (Dispatch):
min: 0.0
max: 5.0
Ambient Store:
min: 10.0
max: 25.0
allergens:
- Fish
- Crustaceans
- Molluscs
- Wheat
- Egg
- Milk
- MustardUpload your own data via the Excel/CSV upload tab — columns are validated automatically.
Stack
Scope and limitations
Pattern borrowed from Frank Rust and Thomas Prexl's "It Works on My Machine" talk (PyCon DE 2026): tell users upfront what the app can't do so they don't form ChatGPT-style expectations. A dashboard that answers some questions perfectly and silently fails on others erodes trust faster than one that refuses out-of-scope questions cleanly.
What this dashboard does
- Traces any batch code from catch area to packed shelf using the six ERP tables listed in Stack
- Flags temperature excursions, allergen-changeover gaps, weight-variance outliers, and shelf-life risk based on pre-loaded rules
- Exposes the same data over a FastAPI REST layer (
api.py) and an MCP server (mcp_server.py) for LLM agents - Answers a fixed set of natural-language questions via
modules/nl_query.py(regex-based, offline — no LLM call) - Reports Four Golden Signals on
GET /metricsso operators can see when the API itself is struggling
What it does NOT do
- No free-form SQL. The NL query module only understands the patterns coded into it; questions outside that set return "not supported" rather than guessing.
- No writes to the ERP. Every connection is read-only; the dashboard surfaces data, it does not correct it.
- No live ERP integration in the public demo. The hosted Streamlit / Hugging Face versions run on anonymised synthetic data. Production deployments point at a read-only user on the real ERP.
- No multi-tenant auth. Password via Streamlit secrets, single-tenant. If you need RBAC, put the app behind an identity-aware proxy.
- No PII. The anonymised seed intentionally contains no real employee names, customer identifiers, batch codes, or vessel registration numbers. Production deployments must keep that rule — the app is designed for factory-floor use, not as a customer-data store.
- No unbounded history. Queries that would return more than a few thousand rows are paginated or capped. Bulk export lives on the production-analytics-pipeline side, not here.
Error Monitoring
Optional error monitoring via Sentry. Set the SENTRY_DSN environment variable to enable. If not set, monitoring is completely disabled (no-op).
export SENTRY_DSN="https://examplePublicKey@o0.ingest.sentry.io/0"
export ENVIRONMENT="production" # optional, defaults to "development"Built by someone who works on the factory floor. 674 batches tracked, 8,640 temperature readings monitored, one-click audit reports.
[Live Dashboard](https://manufacturing-compliance-dashboard-mjappkncanejzlfr5ngghik.streamlit.app) · [Report Bug](https://github.com/Pawansingh3889/manufacturing-compliance-dashboard/issues)
