asset-identity-gs1
A label that a laser gun, a phone and an RFID reader can all read, and that never repeats across sites even when each one prints offline.
- 4equivalent forms of one identity
- 0server calls needed to print without collisions
- 148tests, including an anti-leak sweep
- 23specification test cases covered
- ~270,000/sGIAI-96 round trips
- MITlicence · PyPI 0.1.0
Try it: generate and read identities
Change any field and the label is recalculated. It is a JavaScript port of the package's logic, checked against the package published on PyPI. Everything happens in your browser and all data are examples.
Example Town Council · Inventory
- Alias · Code 128 and people
- GIAI · GS1 key (AI 8004)
- EPC GIAI-96 · UHF RFID chip
- GS1 Digital Link · QR
Field reader: paste or type any code
A laser gun reads the alias, a phone reads the QR and an RFID reader returns the EPC. All four forms resolve to the same asset.
The problem
An inventory of physical assets (buildings, furniture, equipment, works of art) has to be labelled and then recognised in the field. That is harder than printing a barcode:
- Several sites. Each one labels at its own pace, often offline. Two sites must never produce the same code.
- Three readers, one identity. The laser gun reads text, the phone reads a URL and the RFID reader returns 96 bits. All of them must lead to the same asset.
- The label outlives the data model. Inventory numbers get renumbered and labels are printed before the asset exists in the system.
How I solved it
- Uniqueness by construction, not by lookup. An authority gives each site one block, once; the site then increments its serial locally. Different blocks give different codes, like MAC address or GS1 company prefixes. Nothing is checked at print time.
- Two numbers, one register. The serial feeds the GIAI and the EPC and never changes; the inventory number feeds the alias because it is what people recognise. Renumbering never invalidates a chip already in place.
- Typos caught on the spot. The alias carries a visible mod-43 check character: a mistyped number is rejected before it reaches the database.
- Labels before assets. A site can reserve a batch of identities before registering the assets, without inflating the indicators; when the assets are registered they inherit the label already stuck on them.
- Full label life cycle (issued, printed, placed, retired), resolution of any scanned code and detection of swapped labels.
- Print-ready output: A4 label sheets as vector PDFs with Code 128 and QR, single labels, and ZPL for printers that also encode the RFID chip.
Decisions
| Decision | Rejected alternative | Reason |
|---|---|---|
| GIAI as the key | SGTIN | A public asset is an individual asset, not a product with a GTIN |
| Partitioned identifier space | Central register queried at print time | Sites print offline |
| Numeric reference | Alphanumeric GIAI-202 | Fits the cheap 96-bit RFID chips |
| Code 128 | Code 39 | Denser: fits 63 mm labels |
| QR with GS1 Digital Link | QR with the alias | One payload that is both a verification URL and a GS1 key |
How it is built
Pure Python with SQLite persistence, reportlab for vector PDFs and the partition table of the EPC Tag Data Standard. 148 tests that follow the 23 specification cases one by one, CI on Python 3.11 and 3.12, and published on PyPI.
A clean-room case study
The patterns come from my work at Intervalor Data and are published with the company’s permission. To publish them without exposing anything from the client or the original code, I followed a three-phase process: a written specification without code, a fresh implementation from that specification and the public standards only, and an independent review comparing both before publishing. An anti-leak test keeps any term from the original system out of the repository.
Technologies
- Python 3.11+
- reportlab
- pytest
- ruff
- GitHub Actions
- gitleaks
- SQLite