One Machine, One Code: Technical Architecture of a Product Unique Identification System
This article explains how to build a "one machine, one code" unique identification system for high-value equipment such as robots. It covers the shift from batch-based management to individual-level traceability, the design of segmented unique codes with check digits, the architecture of a central registry for code allocation and verification, full-lifecycle management modeled as a state machine, and security and governance considerations. Readers will learn the four core design threads—segmented encoding for readability and uniqueness, a registry for consistent issuance, an append-only event log for full traceability, and cryptographic verification for non-forgeability—needed to build a trustworthy, scalable identity foundation.
1. Background: From “Batch Management” to “Individual Traceability”
Traditional manufacturing treats the “batch” as the smallest management unit, where products of the same model share a single production record. But when the objects being managed become high-value smart equipment that touches public safety—such as industrial and service robots—batch-level granularity is no longer enough. The reasons come down to four points:
- Safety recalls: When a batch-level defect appears, you need to pinpoint the exact device rather than recall an entire batch indiscriminately.
- Liability definition: In resale, leasing, and second-hand trading scenarios, you need to establish the ownership and transfer history of each individual device.
- Anti-counterfeiting and anti-diversion: A unique identifier is the foundation for distinguishing genuine products, cracking down on counterfeits, and curbing cross-region goods diversion.
- Operations and compliance: A device’s repair records, software versions, and decommissioning/recycling all need to be tied to its unique identity.
So the essence of “one machine, one code” is to upgrade a product from “a stock unit that can be counted in bulk” to “a digitally trackable entity that can be tracked individually.” This is a classic identity system problem, and its technical challenges lie not in the coding itself but in the coordination of four main threads: global uniqueness, code segment allocation, state consistency, and secure anti-counterfeiting.
2. Coding System Design: The Principle of Segmented Unique Identification
The proven industry approach is segmented coding, which splits an identifier into several fields with clear semantics. This aligns with general coding ideas such as the Vehicle Identification Number (VIN) and product barcodes. The core goal is to make the identifier both efficiently machine-parseable and quickly human-readable in terms of origin.
A typical four-segment design looks like this:
| Segment | Name | Purpose | Example Length |
|---|---|---|---|
| 1 | Country/Region Code | Identifies the manufacturing or registration location | 3 digits |
| 2 | Company Code | Identifies the producing entity | 5 digits |
| 3 | Product Code | Identifies the product model/category | 4 digits |
| 4 | Serial Code | Identifies the individual unit | 12 digits |
The design principles for segmented coding include:
- Global uniqueness: The combination of “company code + product code + serial code” naturally deduplicates—no two segments can collide when concatenated.
- Verifiability: A check digit appended at the end quickly detects tampering or data-entry errors during collection, transmission, and input.
- Fixed length first: Fixed length makes database indexing, QR code encoding, and manual transcription easier; if variable length is used, additional delimiter rules must be defined.
- Extensibility: Reserve segments or use radix expansion so serial numbers don’t run out when models proliferate.
The following shows a segmented coding example for generation, verification, and parsing (for structural demonstration only, not a specific product implementation):
def compute_check_digit(body: str) -> str:# Simplified example: weighted sum of characters modulo 10; real systems can use mature algorithms like Luhn / ISO 7064total = sum((i + 1) * ord(c) for i, c in enumerate(body))return str(total % 10)def build_code(country: str, company: str, product: str, serial: str) -> str:"""Build a segmented unique identifier with a check digit"""parts = [country.zfill(3), # Country/region codecompany.zfill(5), # Company codeproduct.zfill(4), # Product codeserial.zfill(12), # Serial code]body = "-".join(parts)return f"{body}-{compute_check_digit(body)}"def parse_code(code: str) -> dict:"""Parse and verify a unique identifier"""head, check = code.rsplit("-", 1)if compute_check_digit(head) != check:raise ValueError("Verification failed: the identifier may have been tampered with or mis-entered")seg = head.split("-")return {"country": seg[0],"company": seg[1],"product": seg[2],"serial": seg[3],}
It’s worth emphasizing: a check digit can only detect “random errors”; it cannot defend against “malicious forgery.” True anti-counterfeiting relies on online verification against the registry and cryptographic signatures (see Section 5).
3. Technical Architecture of the Registry
Coding rules are just a “format convention.” To make an identifier truly trustworthy, you also need a registry responsible for code segment allocation, issuance, and lookup. It typically contains the following components:
- Code segment allocation service: Pre-allocates company codes and serial number ranges to each entity, avoiding runtime conflicts. This is the classic “pre-allocation + local issuance” pattern, which significantly reduces concurrency pressure on the central node.
- Identifier issuance service: Called during production marking, it guarantees consistency under high concurrency. Distributed locks or database unique constraints can prevent duplicate codes.
- Registry data storage: Stores the “identifier → ownership → status” mapping. High-frequency reads and low-frequency writes make it well-suited to read-write separation.
- Query and verification service: Exposes “scan-to-verify” capability for real-time verification by regulators, operations teams, and distribution channels.
The data model can be abstracted as:
CREATE TABLE device_registry (device_code VARCHAR(32) PRIMARY KEY, -- Global unique identifiercompany_code VARCHAR(8) NOT NULL, -- Company codeproduct_code VARCHAR(8) NOT NULL, -- Product codeserial_no VARCHAR(16) NOT NULL, -- Serial codelifecycle_state VARCHAR(16) NOT NULL, -- Lifecycle stateowner_id VARCHAR(32), -- Current owning entitymanufactured_at TIMESTAMP, -- Manufacturing timeupdated_at TIMESTAMP, -- Last update timeUNIQUE (company_code, product_code, serial_no) -- Database-level duplicate constraint);-- Audit table for state transitions, supporting full-lifecycle traceabilityCREATE TABLE device_event_log (event_id BIGSERIAL PRIMARY KEY,device_code VARCHAR(32) NOT NULL,event_type VARCHAR(32) NOT NULL, -- Production/shipping/transfer/repair/decommissionpayload JSONB, -- Event details (version, repair records, etc.)occurred_at TIMESTAMP NOT NULL);
The UNIQUE constraint is the last line of defense: even if the application layer has a concurrency flaw, the database will reject duplicate identifiers.
4. Full Lifecycle Management: A State Machine Perspective
The value of “one machine, one code” goes beyond “issuing an ID card.” It lies in linking a device’s complete lifecycle around the unique identifier. Modeling this as a state machine is the clearest approach:
[Production marking] → [Shipping registration] → [Distribution/delivery] → [In-use operations]│ │└──→ [Repair/modification] ←┘│[Decommission/recycling]
Every state transition is written to device_event_log, answering three key questions:
- Whose is it now? (Ownership tracking)
- What has it been through? (Repairs, software upgrades, incident records)
- What state is it in now? (In production, in use, deactivated, decommissioned)
Lifecycle data is inherently “append-only,” which both guarantees auditability and makes later data analysis and risk early-warning easier.
5. Security and Governance Considerations
Once an identity system takes on public governance functions, security design must be built in from the start:
- Anti-forgery: Online verification plus digital signatures ensure that the “scanned code” matches the “record in the registry.”
- Anti-tampering: Event logs are append-only, key operations leave a trace, and hash chains can be introduced when necessary to guarantee integrity.
- Privacy protection: Sensitive fields such as ownership entity and geographic location should be masked or protected by tiered authorization access.
- Data consistency: Adopt consistency strategies in distributed environments (such as idempotent issuance, eventual consistency plus compensation) to avoid duplicate marking or state corruption caused by network jitter.
6. Summary
At first glance, “one machine, one code” seems like just assigning a number to a product. In reality, it is a systems engineering effort that combines coding standards, a registry, a lifecycle state machine, and security governance. For developers, four main threads should be grasped during implementation: segmented coding ensures readability and uniqueness, the registry ensures consistent issuance, the event log ensures full-lifecycle traceability, and cryptographic verification ensures non-forgeability. Get these four solid, and whether the targets are smart equipment, industrial components, or any other objects that need individual-level tracking, you can build a trustworthy, scalable unique identification foundation.
