Protecting the Recycling Line: A 2-Day BRD-to-Build Blueprint for AI-Powered Inbound Conveyor Hazmat Screening — Lithium-Ion Batteries, Solar PV Panels, and Wind Turbine Blade Detection — Platform Layer Engineered to Production Standard; Demonstration Build
This production use case build demonstrates a full end-to-end, prompt-engineering-driven SDLC in action: an industrial-grade Inbound Load & Hazmat Screening Platform (Module 3 of the Renewi EHS Lighthouse CCTV Analytics suite), architected directly from a Business Requirements Document (BRD) and built on a single unified custom-trained YOLOv8 model, into a fully functional, stakeholder-ready, cloud-native application in just 48 hours. What typically requires months of human sprint cycles — requirements analysis, AI infrastructure design, backend services, hazmat data pipelines, and enterprise frontend dashboards — was executed methodically through structured AI collaboration, with the Principal Solution Architect directing and the AI acting as lead engineer across every layer.
Managing inbound recycling conveyor safety across waste management and recycling facilities is one of the most operationally complex and regulatory-critical challenges in the EHS sector. Ensuring that hazardous materials — specifically lithium-ion batteries, solar PV panels, and wind turbine blade fragments — are identified and stopped before entering shredding or processing lines cannot be reliably enforced through manual visual inspection alone. Observer fatigue on high-throughput conveyor lines, the absence of photographic evidence at the moment of detection, and the impossibility of simultaneous multi-belt monitoring leave facilities exposed to catastrophic equipment damage, personnel safety incidents, environmental liability, and regulatory enforcement action.
The platform delivers always-on AI-driven hazmat screening, real-time per-hazard severity-coded alert generation, per-zone incident attribution, and executive-grade analytics dashboards — backed by annotated photographic evidence and a complete audit trail. The following is the detailed account of how this platform was engineered from BRD to a stakeholder-ready demonstration build in 48 hours.
Target
Purpose and Value Proposition
The regulatory and operational mandate for hazardous material control on recycling conveyors is defined by frameworks including the Hazardous Waste (England and Wales) Regulations 2005, the Environment Act 2021 (duty of care provisions), COSHH (Control of Substances Hazardous to Health) Regulations 2002, and applicable WEEE (Waste Electrical and Electronic Equipment) Directive requirements for lithium battery and solar panel handling. Manual inspection processes are inherently fragile on high-throughput recycling lines — creating material exposure risk during peak operational volumes, compliance spot-checks, and incident investigations.
This platform was engineered to close those gaps. By leveraging a structured AI-driven build process to translate complex conveyor safety requirements into a fully governed, automated detection system, the team delivered a platform that identifies three categories of hazardous material in real time, generates evidentiary snapshots at the moment of detection, raises distinct severity-coded alerts per hazard type, and maintains the complete audit trail required by waste management regulatory frameworks.
How It Can Be Used
- EHS Directors / Waste Operations Managers: Monitor live hazmat detection rates, active alert volumes, severity breakdown (CRITICAL / HIGH), and incident trends across all screened conveyor zones via the executive KPI dashboard. Drill into specific battery, solar panel, or wind blade detection events for audit readiness.
- Conveyor Operators / Line Supervisors: Receive real-time push alerts the moment a hazardous item is detected — with distinct named alerts for each hazard class. Review annotated photographic evidence directly in the platform and acknowledge alerts with a traceable digital action.
- Platform Architects / Engineering Leads: Access a production-ready backend service architecture built on SOLID principles, a clean FastAPI layer with REST and WebSocket endpoints, a module=hazmat switch that reuses the established Module 2 (Fire & Smoke) integration patterns, Supabase PostgreSQL repositories, and Docker Compose deployment topology.
- Quality & Compliance Auditors: Execute full audit readiness by inspecting per-hazard incident evidence packages, tracing alerts back to originating detection events, verifying annotated snapshot URLs in Supabase Storage, and reviewing the complete event and alert audit log with UTC timestamps and camera attribution.
- Executive Stakeholders / Innovation Teams: Open the enterprise React dashboard and experience a fully working, stakeholder-presentation-ready AI hazmat screening platform — from live conveyor detection through evidence forensics and analytics — with minimal environment setup via Docker Compose.
Value Provided
- Requirement-to-Code Precision: Every high-level hazmat screening requirement — from three-class hazard detection to per-hazard severity coding, temporal smoothing, snapshot evidence generation, and the three-token JSONB persistence convention — was mapped directly to production FastAPI endpoints, Pydantic validation schemas, Supabase repository methods, and React dashboard components. The HazmatDetectionService, normalize_hazard_label function, and JSONB violating_classes token schema were all implemented in strict alignment with the original BRD specification.
- Fast Detection with Deliberate Smoothing for False-Positive Suppression: The YOLOv8 inference pipeline completes single-image hazmat detection in under 200ms on CPU (observed in testing) — detection is fast. For video and live feeds, confirmed incident alerts are intentionally governed by the temporal smoothing engine: a hazard must persist for 0.3 seconds before an event is raised, then a 5-second suppression cooldown per camera+hazard pair prevents duplicate alerts for ongoing detections. These are two distinct and separate controls — the 0.3s window gates confirmation; the 5s cooldown gates repeat firing. Inference latency and confirmed-alert delivery are appropriately separated: fast detection, deliberate confirmation.
- Three Distinct Severity-Coded Hazard Events: Rather than emitting a single generic “prohibited item” alert, the platform raises named per-hazard events — HAZMAT_BATTERY_DETECTED (CRITICAL), HAZMAT_SOLAR_PANEL_DETECTED (HIGH), HAZMAT_WIND_TURBINE_BLADE_DETECTED (HIGH) — enabling operators to prioritise and respond appropriately to each hazard category.
- Evidence-First Conveyor Safety: Every confirmed hazmat detection triggers an annotated snapshot generation pipeline: bounding boxes, class labels, and confidence scores are rendered directly onto the captured frame using OpenCV, uploaded to Supabase Storage, and linked to the event record with a permanent public URL. Incident response teams receive photographic evidence for every alert without manual screenshot workflows.
- Zero Model Training Overhead — Platform Engineering Focus: The platform treats the custom-trained UC-2 best.pt model — a single unified YOLOv8 model for all three hazard classes — as a production-ready external AI asset for platform integration purposes. No dataset collection, labeling, fine-tuning, or training infrastructure was required from the platform engineering team. The full engineering effort was invested in the service layer, persistence architecture, and dashboard around the model. Note: the model’s confidence threshold is set at 0.20 — intentionally low for a small custom training dataset — to surface true positives that a higher threshold would silently drop. Threshold tuning and accuracy validation against a larger labeled dataset are recommended before full production deployment.
YOLOv8 Framework Licensing Note: The UC-2 best.pt model weights are custom-trained and owned by the project — no third-party model attribution is required for the weights themselves. However, the underlying YOLOv8 architecture and inference framework are provided by Ultralytics under the GNU AGPL-3.0 License. While the surrounding enterprise platform layers (FastAPI backend infrastructure, Supabase data pipelines, and React dashboard) are engineered to production standard, any commercial production deployment of the platform must strictly adhere to AGPL-3.0 open-source copyleft provisions with respect to the YOLOv8 framework, or obtain an upstream commercial enterprise licence from Ultralytics.
- Schema-Free Taxonomy Extension: The UC-2 hazard taxonomy (hazard_class, severity, HAZMAT sentinel) is carried entirely within the existing events.violating_classes JSONB column using a three-token convention — [“HAZMAT”, hazard_class, “SEVERITY:<LEVEL>”] — requiring no schema migration. Metrics queries derive severity-bucketed counts by matching SEVERITY: tokens, keeping the shared platform database clean and migration-free.
- Complete Audit Trail by Default: Every detection, event, alert, and acknowledgement action is logged in Supabase with UTC timestamps, camera source attribution, hazard class, severity, and user identity. The event lifecycle — NEW → ACTIVE → ACKNOWLEDGED → RESOLVED — is fully traceable, providing the complete audit evidence required for waste management regulatory inspection and environmental compliance reporting.
Three-Class Hazmat Taxonomy
The UC-2 best.pt model detects three hazard categories. The canonical class mapping, severity, and operator-facing descriptions are:
|
Class Index |
Canonical Backend Class |
Display Name |
Severity |
Operator Description |
|
0 |
battery |
Lithium-Ion Battery |
CRITICAL |
Loose batteries, battery packs, EV modules. Severe thermal-runaway and fire risk if punctured during shredding. |
|
1 |
solar_panel |
Solar PV Panel |
HIGH |
Broken or intact PV panels. May contain heavy metals (lead, cadmium) which can leach into environment. |
|
2 |
wind_turbine_blade (raw model label: wind_blde) |
Wind Turbine Blade |
HIGH |
Fiberglass/carbon-fiber blade pieces. Releases toxic dust and fumes when processed without specialist handling. |
Label normalisation note: The model’s third training class is wind_blade. The backend HazmatDetectionService.normalize_hazard_label function normalises this label — and all synonyms including blade, fin, turbine — into the canonical id wind_turbine_blade. Non-hazard labels are discarded silently, so the module is designed to report only the three intended hazard categories in normal operation.
Technique: The Kavia AI Streamlined Workflow
The technique used to build this platform represents a fundamental shift in how industrial hazmat screening software can be engineered. Traditional delivery of a platform of this complexity — encompassing computer vision AI services, real-time streaming architecture, per-hazard severity logic, a multi-table cloud database with a schema-free taxonomy extension, an enterprise React dashboard, and production Docker deployment — would typically require 4–6 weeks of sprint cycles across specialised engineers.
This delivery compressed that timeline to 48 hours by positioning a structured, prompt-engineering-driven AI collaboration workflow as the primary delivery mechanism. The Principal Solution Architect acted as strategic director, compliance authority, and integration decision-maker — directing the AI through a three-stage build pipeline that sequentially produced every platform layer from architecture documentation through to deployed frontend.
Crucially, the AI did not just “write code.” It acted as the lead architect and planner — ingesting the full UC-2 BRD, decomposing requirements into functional service boundaries, generating sequence diagrams for the RTSP inference pipeline, the alert lifecycle state machine, and the temporal smoothing and suppression logic, and producing enterprise-grade implementation decisions. This rigorous AI-driven planning phase minimised requirement drift and ensured the HazmatDetectionService singleton pattern, three-class label normalisation, and JSONB taxonomy convention were designed correctly before a single line of implementation code was produced.
|
The Platform Stack Defined at Architecture Stage: React + TypeScript + TailwindCSS + Framer Motion (Frontend) │ Python 3.11 + FastAPI + Ultralytics YOLOv8 + OpenCV (Backend) │ Supabase PostgreSQL + Supabase Storage (Data) Model Asset: UC-2 best.pt — Single unified custom-trained YOLOv8 model for Inbound Load & Hazmat Screening (Renewi EHS Lighthouse platform). Three detection classes: battery (Lithium-Ion), solar_panel (Solar PV), wind_turbine_blade (Wind Turbine Blade pieces). Confidence threshold: 0.20 (intentionally low for small custom dataset; tuning against a larger dataset recommended before full production deployment). Model weights are custom-trained and project-owned. The YOLOv8 inference framework is Ultralytics AGPL-3.0 — commercial production deployment must comply with AGPL copyleft provisions or obtain an Ultralytics commercial licence. |
Project Timeline and the 2-Day Build
Below is the high-velocity pipeline followed to build the Inbound Load & Hazmat Screening Platform from BRD to a fully functional, stakeholder-ready demonstration build:
- Requirement Ingestion and Solution Architecture Design
The build began with the AI ingesting the UC-2 Hazmat Screening BRD in full, performing an automated decomposition into user stories, functional requirements, and non-functional requirements. Within the first session, the AI drafted a complete Solution Architecture Document (SAD) covering Executive Summary, Business Context, Objectives, Scope, Assumptions, Constraints, all Functional and Non-Functional Requirements, End-to-End Architecture, Component Architecture, AI/ML Architecture, Data Flow Architecture, Security Architecture, Integration Architecture, and Deployment Architecture.
It generated detailed Mermaid-syntax architecture diagrams for the full system topology, the UC-2 inference pipeline, the per-hazard alert lifecycle state machine, and the Supabase JSONB taxonomy integration — establishing the complete engineering blueprint before any implementation began. The critical architectural decisions made at this stage included the single unified best.pt model design (consolidating the original dual-model plan onto one trained model), the module=hazmat query-parameter switch reusing established Fire & Smoke integration patterns, and the three-token JSONB violating_classes convention for schema-free taxonomy persistence.
- Backend Implementation — FastAPI + YOLOv8 Hazmat Services
With the architecture blueprint established, the AI implemented the backend as a robust Python 3.11 microservice architecture using FastAPI, built around a singleton YOLOInferenceService that loads the UC-2 best.pt model exactly once during application startup via the FastAPI lifespan context manager. The model is never reloaded per request, ensuring consistent low-latency inference (observed in testing) across the service lifetime.
The backend delivered the following core service components:
- YOLOInferenceService (Hazmat Path): Singleton model loader and inference orchestrator for the UC-2 best.pt model. Runs inference in a thread pool executor to preserve async FastAPI event loop performance. Exposes infer_hazmat_image and infer_hazmat_video methods. The module=hazmat query parameter short-circuits the normal PPE+fire/smoke pipeline and routes exclusively through the hazmat inference path.
- HazmatDetectionService: Core hazmat logic service. Normalises raw model labels to the three canonical classes via normalize_hazard_label, maps each class to its severity via HAZARD_SEVERITY_MAP, and emits distinct HazmatEvent objects with per-hazard event types (HAZMAT_BATTERY_DETECTED, HAZMAT_SOLAR_PANEL_DETECTED, HAZMAT_WIND_TURBINE_BLADE_DETECTED).
- Temporal Smoothing + Suppression Engine: For video and live feeds, process_video_frames maintains per-(camera_id, hazard_class) state and only emits an event after the hazard has persisted for 0.3 seconds (smoothing window), then suppresses duplicates for 5 seconds (suppression cooldown). Prevents alert storms from transient conveyor motion or repeated frames.
- PersistenceService (Hazmat Extension): persist_hazmat_events writes the three-token JSONB convention [“HAZMAT”, hazard_class, “SEVERITY:<LEVEL>”] into events.violating_classes, stores the per-hazard event_type in events.event_type, and records hazard_class, severity, and display_name in detections.summary. Full event lifecycle (NEW → ACTIVE → ACKNOWLEDGED → RESOLVED) with deduplication.
- SnapshotService: Renders annotated incident frames with per-class colour-coded bounding boxes (red for battery, blue for solar panel, cyan for wind blade) and confidence scores using OpenCV, uploads to Supabase Storage, and writes the public URL to the event record in PostgreSQL.
- Metrics Endpoint: get_metrics derives hazmat_events (total), hazmat_critical, and hazmat_high counts by querying the JSONB token sentinels — count_events_by_violating_class(“HAZMAT”), count_events_by_violating_class(“SEVERITY:CRITICAL”), count_events_by_violating_class(“SEVERITY:HIGH”). A backwards-compatibility branch also counts legacy HAZMAT_DETECTED rows.
The AI established the clean folder architecture: src/api/, src/services/, src/repositories/, src/core/, src/schemas/, src/config/, src/middleware/, src/utils/ — strictly enforcing separation of concerns and SOLID principles throughout. A comprehensive Pytest unit test structure was generated covering route wiring, inference service contracts, normalize_hazard_label synonym coverage, temporal smoothing/suppression sequences, and repository interaction patterns.
- Frontend Build — Enterprise React Dashboard (Hazmat Module)
The AI generated a premium enterprise-grade React + TypeScript frontend, structured as a three-module single-page application (PPE, Fire & Smoke, Hazmat) with path-based module routing. The Hazmat module is activated by any URL path starting with /hazmat. The interface uses a professional dark theme, subtle glassmorphism, Framer Motion animations, and enterprise visual hierarchy consistent with the platform’s established design language.
The hazmat dashboard module exposes the following views and components:
- Module Selector: Biohazard-icon chip (yellow-orange gradient) identifying the Hazmat module — “Inbound Load & Hazmat Screening” with subtitle “Battery, solar panel & wind turbine blade screening.”
- KPI Command Centre (Three Hazard Buckets): Glassmorphism KPI cards with count-up animations for Total Hazmat Events, Active Alerts, Lithium-Ion Battery Detections (CRITICAL, red), Solar PV Panel Detections (HIGH, blue), and Wind Turbine Blade Detections (HIGH, cyan). Aggregation prefers per-hazard event_type, falls back to violating_classes tokens, deliberately ignoring HAZMAT sentinel and SEVERITY: tokens to prevent miscounting. Colour legend: severity badges use CRITICAL=red / HIGH=blue; bounding-box overlays use battery=red / solar=blue / wind=cyan — the dual scheme is intentional and consistent throughout the dashboard.
- AI Conveyor Analysis Centre: Image and video upload interface with module=hazmat routing to the backend. Real-time detection overlay rendering with per-class colour-coded bounding boxes: red (battery/lithium), blue (solar/PV), cyan (wind/turbine/blade/fin).
- Real-Time Event Timeline: WebSocket-driven live event feed filtered to HAZMAT* event types. Staggered Framer Motion insertion animations, per-hazard severity badges (CRITICAL in red, HIGH in blue), snapshot thumbnails, and camera attribution.
- Alert Management Centre: Active hazmat alert console with full acknowledge workflow. Per-hazard named alert labels: “Lithium-Ion Battery found,” “Solar PV Panel found,” “Wind Turbine Blade chunk found.” All actions update instantly via React Query cache invalidation.
- Evidence & Forensics Viewer: Professional incident review panel with zoom support, per-class bounding box colour coding, confidence scores, hazard class and severity metadata, and event history — designed to resemble enterprise investigation tooling.
- Analytics Dashboard: Animated Recharts visualisations covering per-hazard detections over time, event trends, severity distribution (CRITICAL vs HIGH), three-bucket hazard class breakdown, and camera zone incident frequency.
- Event Filtering & Module Routing (Client-Side Logic): isHazmatEventType client function matches all HAZMAT* event types via startsWith(“HAZMAT”) check, plus HAZMAT_DETECTED for backwards compatibility. Module event fetching queries four distinct event types (HAZMAT_BATTERY_DETECTED, HAZMAT_SOLAR_PANEL_DETECTED, HAZMAT_WIND_TURBINE_BLADE_DETECTED, HAZMAT_DETECTED) and merges results — ensuring the hazmat dashboard shows only its own incidents from the shared event stream.
Deployment / Hosting: Production-Grade Orchestration via Kavia AI
The platform bridges enterprise-grade architecture with seamless execution by deploying a production Docker topology natively hosted through Kavia AI. Rather than forcing a choice between raw configuration and automated simplicity, Kavia AI ingests and parses the repository’s underlying Docker Compose deployment topology directly. This eliminates the need for manual cloud infrastructure provisioning or custom DevOps scripting while preserving full architectural visibility.
- Automated Containerisation: Kavia AI automatically builds the FastAPI backend container — including the UC-2 best.pt model weights — and handles the compilation of the React frontend to serve it as a high-performance, static Nginx asset.
- Zero-Ops Stack Orchestration: Multi-service dependencies, networking, and environment variables are orchestrated natively with zero manual infrastructure configuration or external cloud overhead (AWS, Azure, GCP).
- Live Operational Runtime: The deployment instantly provisions a secure, live HTTPS URL, instantiates automatic container health checks, and hooks up live log streaming directly to the Kavia AI dashboard.
Architectural Alignment: By leveraging Kavia AI to ingest the team’s production Docker configuration, the entire multi-service ecosystem transitioned from a raw repository to a live, stakeholder-ready environment in under 4 minutes — significantly reducing manual DevOps friction without abstracting away the underlying system design
Before vs. After: Transforming Inbound Conveyor Hazmat Screening
|
Before — Manual Conveyor Inspection |
After — AI-Powered Hazmat Screening Platform |
|
Manual conveyor inspections with significant gaps between checks and observer fatigue on high-volume lines |
Always-on YOLOv8 inference on live RTSP conveyor feeds — providing continuous automated screening across all monitored belts |
|
Hazardous materials (lithium-ion batteries, solar PV panels, wind turbine blade pieces) identified only after entering the shredding line, if at all |
Real-time hazmat detection with confirmed alerts delivered ~0.3s after the smoothing window closes, plus a 5s per-hazard suppression cooldown to prevent duplicate alerts for ongoing detections |
|
No photographic evidence captured at the moment of hazmat detection; incident reports written from memory |
Annotated incident snapshots auto-generated and stored in Supabase Storage at the exact moment of detection — per-hazard bounding boxes and confidence scores embedded |
|
Generic “prohibited item” alerts with no distinction between hazard categories or severity levels |
Three distinct, severity-coded per-hazard event types: HAZMAT_BATTERY_DETECTED (CRITICAL), HAZMAT_SOLAR_PANEL_DETECTED (HIGH), HAZMAT_WIND_TURBINE_BLADE_DETECTED (HIGH) |
|
No incident trend data or audit-ready reporting; compliance evidence gaps for regulatory inspection |
Complete event records with UTC timestamps, camera ID, hazard class, severity, confidence scores, and annotated snapshot URLs — full audit trail by default |
|
No executive visibility into hazmat incident frequency, severity breakdown, or zone attribution |
Executive analytics dashboard with per-hazard KPI cards, incident trends, severity distribution, camera zone attribution, and acknowledgement audit trail |
Team: Human-AI Collaboration
This platform build was brought to life through a lean, high-trust collaboration model between a single human architect and an AI acting as the primary engineer — producing a fully functional, stakeholder-ready AI hazmat screening platform in just 48 hours. This synergy delivered a complex, cloud-native CCTV analytics module — encompassing computer vision AI, per-hazard severity logic, multi-service backend architecture, enterprise frontend, and production Docker deployment — in a timeline that would typically require 4–6 weeks of sprint cycles across a specialised engineering team.
How the Work Was Divided
- The AI (Architect, Backend Developer, Frontend Developer, QA Engineer): Owned the full engineering scope — Solution Architecture Document generation, HLD/LLD design, FastAPI service implementation, YOLOv8 hazmat inference service architecture, HazmatDetectionService with three-class label normalisation and temporal smoothing, JSONB taxonomy persistence layer, React + TypeScript UI across all hazmat dashboard sections, Docker Compose configuration, health endpoints, and the complete Pytest unit test structure.
- The Human Collaborator (Principal Solution Architect): Provided the critical strategic layer — clarifying conveyor safety operational context and Renewi EHS Lighthouse requirements, confirming the single unified best.pt model consolidation decision, directing the module=hazmat integration pattern reuse from Module 2, validating the three-class taxonomy and severity mapping, directing the schema-free JSONB persistence design decision, and confirming the enterprise dashboard design philosophy against stakeholder presentation requirements.
Conclusion
The Inbound Load & Hazmat Screening Platform (Module 3 — UC-2) is a clear demonstration of how structured AI-driven engineering can solve real-world industrial safety and environmental compliance challenges at enterprise scale and startup speed. By leveraging a custom-trained UC-2 YOLOv8 model as a production-ready AI asset — and focusing the entire engineering effort on the platform layer, services, and user experience around it — the team delivered a solution that proves AI can build complex, cloud-native, presentation-ready enterprise software in 48 hours.
The platform goes from BRD to a fully operational CCTV analytics module: detecting lithium-ion batteries, solar PV panels, and wind turbine blade fragments on inbound recycling conveyors in real time, generating severity-coded photographic evidence, attributing incidents to camera zones for precise location tracking, and delivering live operational intelligence through an enterprise React dashboard — all accessible to EHS directors, line supervisors, compliance auditors, and executive stakeholders through a single browser URL.
More than a technical demonstration, this platform represents a new operating model for industrial safety software delivery: one where the engineering timeline is measured in hours rather than months, architectural quality is not traded for speed, and every platform requirement — from SOLID backend architecture and schema-free JSONB taxonomy extension to per-hazard severity-coded Framer Motion dashboard animations — is delivered to production standard in a single structured collaboration workflow.
See What We Built
The Inbound Load & Hazmat Screening Platform went from BRD to a fully functional, stakeholder-ready demonstration build in under 2 days, with the engineered platform layer — FastAPI hazmat services, Supabase data pipeline, and React dashboard — built to production standard, using AI as the primary engineer across architecture, backend, frontend, and deployment. Want to see what your conveyor safety and hazmat compliance requirements can become?
Contact us to discuss your production use case build — connect@digitalt3.com
