Skip to content

Pawansingh3889/manufacturing-compliance-dashboard

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

86 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
title Manufacturing Compliance Dashboard
emoji 🏭
colorFrom green
colorTo yellow
sdk streamlit
sdk_version 1.45.1
app_file app.py
pinned false
license mit
short_description BRC/HACCP food safety compliance dashboard

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.

Live Dashboard Python License

Links

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.py uses FastAPI's TestClient for fast in-process tests (no network, runs in the main test job).
  • Integration / real HTTP β€” scanapi/scanapi.yaml drives every endpoint over HTTP via ScanAPI (by Camila Maia and the ScanAPI org, MIT). Catches middleware / CORS / serialisation bugs TestClient skips. Runs locally via make scanapi and on CI via the ScanAPI integration tests workflow.

Report lands in scanapi-report/ (gitignored). Point at a staging deploy by overriding the base URL: make scanapi BASE_URL=https://staging.example.com.


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 β†’ Β· Hugging Face


See it run

Batch Traceability Temperature Monitoring Allergen Matrix
Batch traceability Temperature monitoring Allergen matrix
$ 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:8501

Or 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
  - Mustard

Upload your own data via the Excel/CSV upload tab β€” columns are validated automatically.


Stack

Component Tool
Dashboard Streamlit (4 tabs)
Charts Plotly
Database SQLite (demo) / PostgreSQL (production)
Batch Analytics PySpark, Databricks
Anomaly Detection scipy z-score, excursion duration, trend forecasting
Reports fpdf2 (PDF), JSON
Deployment Docker, Streamlit Cloud

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 /metrics so 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://[email protected]/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 Β· Report Bug

About

BRC/HACCP food safety dashboard. Batch traceability, temperature monitoring, allergen matrix, weight variance. Streamlit + Sentry.

Topics

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages