chemical-inventory
Here is a clean, modern, developer-ready Markdown rewrite of your entire Chemical Inventory (ChemIQ) Developer Checklist, preserving every requirement but organizing it for engineers, QA, and product in a highly structured, readable format.
π₯ Module 4 β Chemical Inventory (Inventory Management + SDS Maintenance)
Developer Implementation Checklist (Markdown Edition)β
Applies to CHEMIQ module across Starter / Standard / Pro tiers
0. Foundations (Blockers β must be completed first)
Feature Flagsβ
inventory.barcode
inventory.ocr
inventory.bulk_upload
inventory.ai_sds_match
inventory.fifra_ppls
inventory.reviews
inventory.offline_sync (Pro)
Service Integrationsβ
- OCR provider (Vision API or Tesseract)
- GS1 / Product DB lookup key
- SDS web search connectors
- EPA PPLS API (FIFRA)
- Object storage for PDFs/images (SDS, label images)
- Background queue (Sentinel Workers)
Database Migrationsβ
chemicalschemical_attributessds_documentssds_sectionspending_sds_reviewsinventory_uploadsfifra_labelslabel_imagessite_location_index
Object Storage Bucketsβ
sds-pdflabel-imagesinventory-importsWith: malware scan + MIME type validation.
Access Controlβ
- RLS by
company_idandsite_id - RBAC gates for create/edit/delete
- Audit on SDS attach/replace
4.1 Purpose (Analytics + Compliance Hooks)
-
Emit events:
chemical_created,chemical_updatedsds_attached,sds_missingsds_revision_updatedbulk_import_started|completedinventory_review_duefifra_label_attached
-
Persist and index:
site_id,location_id -
Ensure SDS is accessible/downloadable per site for OSHA Audits.
Acceptance:
- All inventory actions appear in analytics.
- Each chemical is site/location-scoped.
4.2 Site & Location Context
4.2.1 Selection & Filtersβ
-
User must select Site and optional Location.
-
Filters:
- All
- Missing SDS
- Expiring SDS (β₯3 years or per policy)
- Hazard categories
-
Location hazard summary based on SDS Section 2.
Acceptance:
- Filtering p95 < 300ms for β€ 5k chemicals.
- Hazard summary = SDS data.
4.3 Add Chemical
4.3.1 Manual Entry (Starter)β
Recommended Minimal Fields:
- Product Name
- Manufacturer
- Container Size
- Quantity (with unit)
- Notes (optional)
- Optional SDS Upload (PDF)
Duplicate detection:
- Same Product + Manufacturer (case/space-insensitive) within the same site.
Tests:
- Duplicate β inline warning + βview existingβ.
- SDS optional; CAS/Product Code no longer required in UI.
Acceptance:
- Chemical created correctly, linked to site/location.
4.3.2 Barcode Scan (Starter + Standard)β
-
Accept camera or HID scanner input.
-
Parse UPC/EAN/GS1.
-
Lookup GS1/Product DB β prefill:
- Product Name
- Manufacturer
- Category (if supported)
-
Allow overrides & graceful fallback.
Tests:
- Unknown barcode β fallback to manual, event:
barcode_not_found. - Partial data β allow save with warnings.
Acceptance:
- Prefill works; unknown codes do not block creation.
4.3.3 Picture Label OCR (Standard + Pro)β
-
Upload image β OCR extracts:
- Product Name
- Manufacturer
- Signal Word
- GHS Pictograms
-
Show confidence scores.
-
Store image in
label_images.
Tests:
- Low-quality β βneeds reviewβ + create
pending_sds_reviewsif SDS missing. - Pictograms mapped to standard GHS icons.
Acceptance:
- OCR prefill works; user edits override; confidences stored.
4.3.4 Additional Attributesβ
- Size/Unit
- Batch/Lot
- Manufacture/Expiration Date
- Storage Conditions
Validation: Compare with SDS Section 1 (name/manufacturer) after SDS attachment.
Acceptance:
- Block or warn depending on identifier mismatch policy.
4.3.5 Confirm & Saveβ
- Create chemical
- Link to site/location
- Add to βRecent Additionsβ
- Use idempotency key to avoid double creation.
Acceptance:
- Exactly one record added.
4.4 SDS Attachment & Association
4.4.1 Starter β Web Searchβ
- Query external SDS sources using name + manufacturer.
- Download & store PDF with checksum dedupe.
Acceptance:
- SDS visible in viewer; source logged.
4.4.2 Standard/Pro β AI SDS Suggestionβ
- Search internal SDS DB + web sources.
- Rank top 3 with confidence scoring.
- Display manufacturer snippet + revision date.
Acceptance:
- Suggestions appear with confidence; user selects or uploads.
4.4.3 Preview / Accept / Uploadβ
Preview shows:
- Product Identifier
- Revision Date
- Hazard Classification
- Signal Word
- Pictograms
User accepts/overrides/upload new SDS.
Acceptance:
- Attachment completes; version preserved.
4.4.4 SDS Metadata Extractionβ
Parse SDS PDF β extract at minimum:
-
Section 1:
- Product identifiers
- Manufacturer details
- Emergency phone
-
Section 2:
- Hazard Statements (H)
- Precautionary (P)
- Signal Word
- Pictograms
Persist to sds_sections JSON.
Acceptance:
- Parsed fields visible in UI; usable by Copilot & Insights.
4.5 FIFRA (Pesticides)
4.5.1 Starter β Manual EPA Entryβ
- Input EPA Reg. No.
- Manual label entry
- Optional attach label PDF.
Acceptance:
- EPA Reg. + actives stored.
4.5.2 Standard/Pro β EPA PPLS Integrationβ
- Fetch actives, %, signal word, label PDF from EPA.
- Daily sync job with expiry alerts.
Acceptance:
- Auto-populated; sync logs; Pro alerts fire.
4.6 Bulk Upload (Standard + Pro)
4.6.1 Upload Fileβ
- Accept CSV or invoice PDF β AI converts to CSV.
- Mapping UI to match columns to fields.
- Validate duplicates and required fields.
Acceptance:
- Invalid rows flagged clearly.
4.6.2 Review & Validationβ
- Inline edits allowed in preview table.
- SDS gaps highlighted.
Acceptance:
- User can correct rows before commit.
4.6.3 SDS Associationβ
- Auto-match SDS (internal + web).
- Unresolved β
pending_sds_reviews.
Acceptance:
- Unresolved count shown.
4.6.4 Accept & Commitβ
- Transactional write to DB.
- Summary in
inventory_uploads. - Trigger Sentinel βMissing SDS Alertβ.
Acceptance:
- Either full commit or rollback (except fix-and-retry mode optional).
4.7 Inventory Maintenance & Review
4.7.1 Scheduled Reviewsβ
- Annual inventory review (per site).
- SDS review when SDS β₯ policy age.
- Inventory Drift detection (12+ months inactivity).
Acceptance:
- Reminders and dashboards show due items.
4.7.2 Editing & Deactivationβ
- Soft-delete obsolete chemicals.
- SDS version history maintained.
Acceptance:
- Historical links preserved.
4.7.3 Change Audit Trailβ
- Log add/edit/deactivate with diffs (Pro).
- Exportable by site/date.
Acceptance:
- Admin can export change logs.
4.8 Tier Enforcement
| Feature | Starter | Standard | Pro |
|---|---|---|---|
| Manual Entry | β | β | β |
| Barcode Scan | β | β | Enhanced |
| Web SDS Search | β | β | Enhanced |
| OCR Label | β | β | Enhanced |
| Bulk CSV Import | β | β | Enhanced |
| Internal SDS DB Match | β | β | Enhanced |
| AI Hazard Parsing | β | β | β |
| Invoice OCR Import | β | β | β |
| Offline Sync | β | β | β |
| Sentinel Alerts | Basic Email | In-app | Multi-channel |
Acceptance:
- Tier changes immediately update UI and disable/enable features.
4.9 Notifications & Alerts
| Alert Type | Starter | Standard | Pro |
|---|---|---|---|
| New Chemical Added | Email + In-app | Email + Webhook | |
| SDS Missing | Email + In-app | Email + Slack/Webhook | |
| SDS Expiring | Email + In-app | Multi-channel | |
| Inventory Review Due | Reminder UI | AI Insight Email | |
| FIFRA Label Expiry | β | Email + EPA Sync Alert |
Acceptance:
- No duplicate notifications
- Configurable per site.
π Security Checklist
- Enforce RLS on all tables using
company_id,site_id - Malware scan + MIME restrict SDS & image uploads
- SDS text may contain PII β limit indexing, redact in broad views
- SDS parsing sandboxed in worker with time/memory caps
- Strict input validation (EPA Reg format, CAS if ever surfaced, etc.)
- Idempotent create/update endpoints
- Audit logs for SDS attach/detach with version diffs
- Secret rotation + API quota monitoring
π QA Test Matrix
Happy Pathsβ
- Manual add + SDS upload β SDS Section 1/2 visible
- Barcode scan β prefill β SDS suggest β attach
- OCR label β pictograms detected β SDS mapped
- Bulk CSV 100 rows β fix inline β commit β unresolved SDS in queue
Edge Casesβ
- Duplicate detection works
- Corrupted SDS β graceful failure
- Conflicting identifiers β warning or block (per policy)
- Unknown barcode β manual fallback
- PPLS outage β manual entry
- Invalid site/location in import β inline map
- SDS > 20MB β queue parse job
Cross-Browser & Devicesβ
- Barcode camera scan on mobile
- Responsive lists
- Pro offline: capture then sync
Performanceβ
- Inventory list p95 < 500ms (5k rows)
- SDS parse p95 < 30s
- Bulk import 1k rows < 90s
π§ Observability & Alerts
- Dashboards: SDS parse success rate, OCR confidence, import failures, PPLS health
- Alerts: spikes in failures, quota nearing, pending reviews > N days
π¦ Deliverables (Definition of Done)
- Figma: Add Chemical, SDS Attach, Bulk Import, Review Screens, Errors
- OpenAPI specs for CRUD, SDS attach/preview, imports, PPLS sync
- Localization (EN/ES)
- E2E tests for all flows
- Admin tools: re-run parser, re-link SDS, resolve pending reviews
- Rollback: disable OCR/AI/PPLS via feature flags; manual flows unaffected