inventory
The web inventory includes item slide-outs, stock, locations and printable sticker templates. Print requests are consumed by the devices service (mock printer driver).
Runs in the apps compose profile on port 8085; the gateway routes /v1/inventory to it.
OpenAPI: API reference (services/inventory/openapi.yaml).
Role: owner of everything physical in the makerspace: tools, machines and consumables, the location tree of each site, consumable stock, maintenance plans, issues and QR labels. Inventory is the owner of item status: borrowing never writes it, it publishes checkout/return events that inventory applies.
Limits: no borrowing logic (sheets, borrowers), no file storage (photos are files IDs), no
purchases (stock increases come from movements with a free reference), no label printer driver (print jobs
are routed through devices). Training requirements are indicative only.
Model
- Item (
kind=tool|consumable|machine): name, description, category, brand, model, serial,site_id,location_id,project_id, required training type IDs, photos (file IDs), tags, purchase info (price, date, supplier), custom fields. Status:available,borrowed,in_maintenance,out_of_service,lost. Event sourced (aggregateitem). - Consumable extras: unit (
piece,m,g,kg,ml,l,sheet), quantity,low_stock_threshold,unit_cost. Stock movementsin|out|adjust(reason, project, reference); a movement making the stock negative is refused (exceptadjust). Project cost = sum ofoutmovements × unit cost. - Low stock: emitted once per downward crossing of the threshold, only when the site setting
low_stock_alertsis enabled (disabled by default). - Short code:
A-+ 8 Crockford base32 symbols (40 random bits). QR content isINVENTORY_PUBLIC_URL/q/<code>; codes are normalised (case, prefix) on resolution. - Locations: tree per site with a materialised
path(subtree queries); node types are configurable per site. Items attach to any node. Moving a node rewrites the paths of its subtree in the same transaction. - Maintenance plans: on one item, every N days and/or every N uses (use count is incremented on each checkout), optional assignee. A job opens one task per due plan; completing it resets the counters.
- Issues: reported on an item (title, description, photos), status
open→in_progress→resolved. The reporter may edit their own issue (not the assignee). Photos are files owned by the issue ARNatl:inventory:<site>:issue/<id>(purposeissue): report the issue, upload the photos, thenPATCHitsphotos. - History: per-item timeline merged from the event store (edits, moves, status/custody, stock, maintenance, issues).
- Deletion: soft delete, purge after
INVENTORY_PURGE_DELAY;?force=truepurges immediately and requires admin mode. A purge removes the item state, its event stream and its maintenance plans; issues are kept.
Authorization
ARNs: atl:inventory:<site>:item/<id>, …:location/<id>, …:maintenance/<id>, …:issue/<id>, plus
…:stock/<id> and …:label/<id> for stock and label permissions. Parents: atl:settings:<site>:site/<site>
and, for project-owned items, atl:projects:<site>:project/<id>. Lists use authz Lookup scopes (sites, projects,
IDs) as MongoDB filters; an empty scope returns 403.
Issue photos (files delegate): inventory.issue.read/update do not exist, so the files service delegates
issue photo checks to POST /internal/v1/attachments/authorize ({owner, parents, action}, caller
X-Atl-Principal required; 204 allowed, 403 denied, 404 unknown owner). Read: the reporter or
inventory.item.read on the issue item. Write: the reporter or inventory.issue.handle, or
inventory.issue.report while the issue is open. /internal/... routes are not routed by the gateway.
Dependencies
- Services: authz (ConnectRPC
Check,LookupResourcesthroughauthzclient), borrowing (consumes its sheet events only). - Infrastructure: MongoDB (replica set, transactions), Kafka.
- Libraries:
authzclient,httpx,principal,pagination,problem,eventstore,outbox,audit,cloudevent,mongox,kafkax,lease,csvx,arn,ids,config. See libraries.
Inputs and outputs
All routes are under /v1/inventory and require authentication. "scope" means the list is filtered with the
Lookup scope of the permission.
Bulk actions (update, move, status, delete, restore) take up to 500 unique IDs, authorize and apply
each item separately and answer 200 with one {id, ok, error} result per item (error = problem code).
| Method | Path | Permission |
|---|---|---|
| GET | /items | inventory.item.read (scope); include_deleted also needs inventory.item.read_all |
| POST | /items | inventory.item.create |
| GET | /items/:id | inventory.item.read |
| PATCH | /items/:id | inventory.item.update (also on the new project when changed) |
| PUT | /items/:id/status | inventory.item.update |
| POST | /items/:id/move | inventory.item.update (+ inventory.item.create on the target site) |
| DELETE | /items/:id | inventory.item.delete (?force=true: admin mode) |
| POST | /items/:id/restore | inventory.item.delete |
| GET | /items/:id/history | inventory.item.read |
| GET, POST | /items/:id/movements | inventory.item.read / inventory.stock.adjust |
| GET | /label-templates | inventory.item.read scope; cursor-paginated physical formats |
| GET | /items/:id/label.svg?template= | inventory.item.read; mini, small, medium (default), large |
| POST | /items/:id/print-label | inventory.label.print (202, publishes the print request) |
| POST | /items/bulk | per item: inventory.item.update (update, move, status; + inventory.item.create on the target site for a cross-site move) or inventory.item.delete (delete, restore; force: admin mode) |
| POST | /items/import, /consumables/import | inventory.item.create on every row (CSV formats) |
| GET | /items/export.csv, /consumables/export.csv | inventory.item.read (scope) |
| POST | /locations/import | inventory.location.create on every site of the file |
| GET | /locations/export.csv | inventory.location.read (scope) |
| GET | /resolve/:code | inventory.item.read on the resolved item |
| GET | /projects/:id/costs | inventory.item.read (scope) |
| GET, PUT | /sites/:site/settings | inventory.item.read / inventory.item.update on item/* of the site |
| GET | /locations | inventory.location.read (scope) |
| POST | /locations | inventory.location.create |
| GET, PATCH, DELETE | /locations/:id | inventory.location.read / update / delete |
| POST | /locations/:id/move | inventory.location.update |
| GET, POST | /sites/:site/location-types | inventory.location.read / inventory.location.update |
| PATCH, DELETE | /location-types/:id | inventory.location.update |
| GET, POST | /maintenance/plans | inventory.item.read (scope) / inventory.maintenance.manage |
| GET | /maintenance/plans/:id | inventory.item.read on the item |
| PATCH, DELETE | /maintenance/plans/:id | inventory.maintenance.manage |
| GET | /maintenance/tasks | inventory.item.read (scope) |
| POST | /maintenance/tasks/:id/complete | inventory.maintenance.manage |
| GET | /issues | inventory.item.read (scope) |
| POST | /issues | inventory.issue.report |
| GET | /issues/:id | inventory.item.read on the item |
| PATCH | /issues/:id | reporter, or inventory.issue.handle |
| PUT | /issues/:id/status | inventory.issue.handle |
| POST | /internal/v1/attachments/authorize (internal, not under /v1/inventory) | see issue photos above |
| Kind | Name | Notes |
|---|---|---|
| RPC out | authz.v1.AuthzService/Check, LookupResources | permission checks and list scopes |
| Kafka out | inventory.item.v1 | created, updated, moved, status_changed, deleted, restored, purged |
| Kafka out | inventory.stock.v1 | moved, low (keyed by item ID) |
| Kafka out | inventory.location.v1 | created, updated, moved, deleted (subject and key = location ID, see below) |
| Kafka out | inventory.maintenance.v1 | plan_created, plan_updated, plan_deleted, task_due, task_completed |
| Kafka out | inventory.issue.v1 | reported, updated, status_changed |
| Kafka out | inventory.label.v1 | print_requested (item, short code, QR URL, template, copies, printer) |
| Kafka out | audit.records.v1 | inventory.item.create/update/status_change/move/delete/restore/custody/purge, inventory.stock.in/out/adjust, inventory.label.print, inventory.location.create/update/delete/move/type_create/type_update/type_delete, inventory.settings.update, inventory.maintenance.plan_create/plan_update/plan_delete/task_due/task_complete, inventory.issue.report/update/status_change, exports inventory.item.export, inventory.location.export |
| Kafka in | finance.purchase.v1 (INVENTORY_PURCHASE_TOPIC), group inventory-purchases | finance.purchase.received: one stock in movement per received line with an item (reference purchase:<purchase>:<line>:<receipt_seq>, legacy events without receipt_seq keep purchase:<purchase>:<line>; idempotent on redelivery; quantity in item units, quantity_milli preferred), weighted average unit_cost (euros, from unit_cost_cents); unknown, deleted or non-consumable items are skipped |
| Kafka in | borrowing.sheet.v1 (INVENTORY_CUSTODY_TOPIC), group inventory-custody | checked_out → borrowed (+1 use), items_returned → available; idempotent per sheet, unknown or deleted items and malformed events (or more than 500 items) are skipped |
Location events carry IDs and structural fields only (no description, no PII), in the same transaction as the write and its audit record:
| Type | Data |
|---|---|
inventory.location.created | id, site_id, parent_id, type, name, depth |
inventory.location.updated | id, site_id, changed (name, type, description, or ancestors), type, name |
inventory.location.moved | id, site_id, root_id, from_parent_id, to_parent_id, depth |
inventory.location.deleted | id, site_id, parent_id |
A move publishes one moved event per node of the moved subtree (root_id is the node that was moved, the
parents are those of the root), and a rename publishes updated with changed: [ancestors] for every
descendant, so consumers that denormalise the ancestor path (search) refresh each node. Locations have no soft
delete. Node types and site settings changes are audited but publish no domain event. Background jobs (purge of soft
deleted items every INVENTORY_PURGE_INTERVAL, maintenance task generation every
INVENTORY_MAINTENANCE_INTERVAL) run on one replica at a time through a MongoDB lease. Events go through the outbox
(CQRS, Kafka).
Data (MongoDB inventory)
| Collection | Key fields | Indexes |
|---|---|---|
items | item state, version, short_code, location_path, search_terms, low_stock, custody, use_count, deleted_at, purge_at | unique partial short_code; partial purge_at; site_id, location_path, location_id, kind, status, category, tags, project_id, search_terms, deleted_at (each + _id); partial low_stock |
locations | site_id, parent_id, type, name, name_key, path, depth | unique (site_id, parent_id, name_key); path; site_id, parent_id, search_terms (+ _id) |
location_types | site_id, key, name, order | unique (site_id, key); (site_id, order) |
site_settings | _id = site, low_stock_alerts | — |
maintenance_plans | item_id, site_id, every_days, every_uses, assignee_id, next_due_at, open_task | (item_id, _id), (site_id, _id), unique partial open_task.id, next_due_at, every_uses |
issues | item_id, site_id, status, reported_by, assignee_id, photos | item_id, site_id, status, project_id (each + _id) |
events | event log (items, plans, issues) | eventstore indexes + data.item_id, (type, data.project_id), aggregate_id |
outbox | pending Kafka messages | — |
locks | leases of the outbox relay and of the inventory-purge and inventory-maintenance jobs (pkg/lease) | — |
Search uses search_terms (normalised tokens of name, brand, model, serial, short code, tags); every list sorts
on _id with cursor pagination.
Configuration
| Variable | Default | Description |
|---|---|---|
HTTP_ADDR | :8085 | Listen address (compose sets :8085) |
METRICS_ADDR | :9185 | Prometheus listener |
PRINCIPAL_PUBLIC_KEY | required | Verifies X-Atl-Principal |
AUTHZ_URL | http://localhost:8081 | authz ConnectRPC endpoint |
KAFKA_BROKERS | localhost:19092 | Outbox relay and custody consumer |
MONGO_URI, MONGO_DATABASE | mongodb://localhost:27017/?directConnection=true, inventory | MongoDB |
INVENTORY_PUBLIC_URL | https://atelier-maker.fr | Base of QR code URLs (/q/<code>); compose: http://localhost:3000 |
INVENTORY_SITES | paris,strasbourg | Sites whose default location types (room, furniture, shelf, bin) are seeded at startup |
INVENTORY_PURGE_DELAY | 24h | Soft delete → purge delay |
INVENTORY_PURGE_INTERVAL | 1h | Purge job period |
INVENTORY_MAINTENANCE_INTERVAL | 15m | Maintenance task generation period |
INVENTORY_CUSTODY_TOPIC | borrowing.sheet.v1 | Topic of borrowing checkout/return events |
INVENTORY_PURCHASE_TOPIC | finance.purchase.v1 | Topic of finance purchase events (received stock) |
Plus the common APP_ENV, LOG_LEVEL, OTEL_EXPORTER_OTLP_ENDPOINT (see
environment variables).