DPP — Anti-counterfeit Traceability for Garments
Anomaly detection and anti-counterfeit traceability for the garment industry. The platform checks factory-reported production figures against real machine data so production records can be verified.
- Role
- AI Engineer — nearly all of the repo (64 of 65 commits)
- Year
- 2026
- Company
- NEAX AI
- Independent detector families
- 3
- Anomaly detectors
- 7
- Automated Python tests
- 300+
- Passport API latency
- 381 → ~95 ms
Context
A DPP (Digital Product Passport) is an evidence pack proving the origin of each shipment. The users are compliance and export teams at Vietnamese garment factories, who must show proof to US customs (UFLPA), brand auditors and under the EU DPP rules.
Problem
Buyers usually have to trust production figures that factories report themselves. Proving material origin, supplier screening and production consistency in a way that cannot be quietly edited is hard.
Solution & architecture
- Collect real machine data from the factory MES
- ETL into PostgreSQL
- 3 families of anomaly detectors
- Quarantine a lot when ≥ 2 families agree
- Per-lot hash chain → Merkle root → anchor on Polygon (Amoy testnet)
- Passport PDF, customs pack, offline verifier
- Data intake: real production data from the factory MES into PostgreSQL; PDF/Excel document import; supplier screening against UFLPA lists via OpenSanctions.
- Anomaly detection: 7 detectors in 3 independent families — business rules, robust statistics and Isolation Forest — catching material fraud (mass balance), impossible output and cycle-time inflation. A lot is quarantined only when at least two families agree, or when a finding is critical, to keep false alarms down.
- Tamper evidence: each lot gets a SHA-256 hash chain rolled into a Merkle root that can be anchored on the Polygon blockchain, so any later edit is detectable. Anchoring currently runs on the Polygon Amoy testnet; mainnet is a config switch.
- System: 4 Docker containers — nginx web, Python API, PostgreSQL, and a separate Node broadcaster that holds the Polygon key with no database access. React + TypeScript UI (12 pages), JWT auth. On-premise deployment with backup/restore.
Moving off AWS
The first version ran as five Lambda-style services on AWS that called each other over HTTP, with Cognito for sign-in, RDS and S3. To run it on a single factory server, I:
- merged the five services into one Python API (a modular monolith), which also removed a deadlock and a hard-coded internal token;
- replaced Cognito with database logins (scrypt password hashing, JWT);
- replaced S3 with a disk store keyed by content hash, and dropped the RDS-specific code;
- merged five copies of the hash-chain code into one;
- kept the key-holding broadcaster in its own container with no database access.
The codebase shrank by about 23,000 lines.
My role
I wrote nearly all of the repo (64 of 65 commits): the data pipeline, anomaly detectors, hash chain and Polygon anchoring, API, UI and deployment.
Results
- Detectors, hash chain and verifier run on real MES data from two factories.
- Faster API after removing per-lot queries: the passport list went from 381 ms to 85–105 ms; with 10 users at once, from 4.2 s to 1.0 s. Gzip shrinks the anomaly list from 168 KB to 21 KB.
- 300+ automated Python tests plus frontend tests, with CI on GitHub Actions.
- Internal demo stage; not yet in production.
- Passport list API95 ms4×381 ms → 95 ms
- 10 users at once1 s4×4.2 s → 1 s
- Anomaly list payload21 KB8×168 KB → 21 KB
Tech stack
Python, PostgreSQL, scikit-learn (Isolation Forest), pandas, PyMuPDF, React + TypeScript + Vite + Tailwind, pdf-lib, Polygon, Docker, GitHub Actions.
- Anomaly Detection
- Isolation Forest
- Hash chain
- Polygon
- PostgreSQL
- Docker
