Skip to main content

Taxonomy ID System

Switchyard uses an 18-digit taxonomy ID system as a scannable, human-readable alternative to UUIDs. Every entity in the system has both a UUID (for internal database operations) and a taxonomy ID (for scanning, display, and external references).

Overview

Taxonomy IDs are designed to be:
  • Scannable - Can be printed as Code 128 barcodes
  • Checksum-protected - MOD-97 validation prevents typos
  • Type-aware - First digits identify the entity type
  • Globally unique - No collisions across entity types
All V1 API endpoints accept both UUIDs and taxonomy IDs as the :id parameter. The system automatically detects and resolves the correct format.

ID Format (Memory Map)

An 18-digit taxonomy ID follows this structure: Total: 18 digits (even number, ideal for Code 128 Set C barcodes)

Type Allocations

Each entity type has a unique 2-digit TYPE code:
Type codes 12, 1519, 26, and 2849 are currently unassigned and available for future entity types.

Entity Type Details

Physical containers used to hold items during fulfillment. Uses tote_code column in the totes table.Use cases:
  • Order picking containers
  • Receiving containers
  • Inter-zone transfer bins
Seeded: 200 totes (SEQ 100001–100200)Example: 01 10 000 0100001 00 CS → Tote #100001
Autonomous delivery robots for warehouse operations. Primary key is the taxonomy ID in the robots table.Use cases:
  • Delivery robots
  • Picking assistants
Seeded: 12 robots (SEQ 100001–100012)Example: 01 11 000 0100001 00 CS → Robot #100001
Sellable products in the catalog. Has a taxonomy_id column on the sellable_products table.Use cases:
  • Product lookup
  • Inventory tracking
  • Order line items
Example: 01 13 000 0100001 00 CS → Product #100001
Warehouse sweep operations for inventory management. Has a taxonomy_id column on the sweeps table.Use cases:
  • Inventory sweep tracking
  • Cycle counts
Example: 01 14 000 0100001 00 CS → Sweep #100001
Picking carts that hold up to 3 totes. Primary key is the taxonomy ID in the carts table. Each cart has a color+animal identification name.Use cases:
  • Order picking workflows
  • Tote assignment
Seeded: 10 carts (SEQ 100001–100010)Example: 01 20 000 0100001 00 CS → Cart #100001
Order bags with temperature zone support (ambient, cold, frozen). Uses bag_code column in the bags table.Use cases:
  • Order packaging
  • Temperature zone segregation
Seeded: 1,000 test bags (SEQ 1–1000) + 5,000 production bags (SEQ 100001–105000)Example: 01 21 000 0100001 00 CS → Bag #100001
Warehouse locations and inventory slots. Has a taxonomy_id column on the inventory_groups table.Use cases:
  • Warehouse location tracking
  • Slot/bin identification
  • Zone management
Example: 01 22 000 0100001 00 CS → Inventory Group #100001
Employees and warehouse staff. Has a taxonomy_id column on the staff table.Use cases:
  • Staff identification
  • Task assignment
  • Access control
Example: 01 23 000 0100001 00 CS → Staff #100001
Store and retailer locations. Has a taxonomy_id column on the retailer_locations table.Use cases:
  • Location identification
  • Multi-store operations
Example: 01 24 000 0100001 00 CS → Retailer Location #100001
Pickup portals for order collection. Has a taxonomy_id column on the pickup_portals table.Use cases:
  • Customer pickup points
  • Portal scanning
Example: 01 25 000 0100001 00 CS → Portal #100001
Partner brand shipment manifests. Has a taxonomy_id column on the partner_manifests table. Used for QR code scanning of incoming partner shipments.Use cases:
  • Partner shipment receiving
  • QR code scanning
  • Manifest tracking
Example: 01 27 000 0100001 00 CS → Manifest #100001

SEQ Reservation Bands

Within each TYPE×FAC combination, the 7-digit SEQ space is divided: This gives each TYPE×FAC up to 8.9 million production IDs, which is more than sufficient for operational scale.

Checksum Calculation

The 2-digit checksum (CS) at positions 16-17 is calculated using MOD-97:
Zero-pad to 2 digits if needed.

Examples (FAC=000, RSV=00)

The checksum provides typo detection. If a user manually enters an ID incorrectly, the checksum validation will fail.

Database Implementation

Taxonomy IDs are automatically generated by database triggers when new entities are created.

Table Structure

Each table with taxonomy IDs has:

Generation Trigger

The set_taxonomy_id() trigger function runs on INSERT for supported tables and auto-generates a taxonomy ID if one is not already provided:
Totes, robots, carts, and bags use their taxonomy ID as a primary key or dedicated code column (tote_code, bag_code) rather than the trigger-based approach. Their IDs are generated during table seeding.

API Usage

Dual ID Support

All V1 API endpoints accept both UUIDs and taxonomy IDs:

ID Resolution

The API automatically detects the ID format and resolves taxonomy IDs to UUIDs for database queries:
Tables currently supported by the resolveId() utility:
  • sellable_products
  • staff
  • inventory_groups
  • sweeps
  • retailer_locations

Detection Logic

Barcode Implementation

Code 128 Set C

Taxonomy IDs are optimized for Code 128 Set C encoding:
  • 18 digits = 9 symbol pairs
  • Highly compact barcode
  • Fast scanning

Label Format

Validation

Client-Side Validation

Server-Side Validation

The API validates taxonomy IDs using Zod schemas:

TypeScript Types

The taxonomy ID system exposes the following types and utilities from apps/api/src/lib/taxonomy-id.ts:

EntityType

TYPE_CODES

Utility Functions

Best Practices

Use Taxonomy IDs for Display

Show taxonomy IDs in user interfaces and printed materials. They’re easier to read and verify than UUIDs.

Store UUIDs Internally

Use UUIDs for database foreign keys and internal references. Taxonomy IDs are for external interfaces.

Validate on Input

Always validate the checksum when accepting taxonomy ID input to catch typos early.

Include Both in Exports

When exporting data, include both the UUID and taxonomy ID for maximum compatibility.