Case Study — Enterprise SaaS

Enterprise Inventory at Staff-Engineer Precision

A 4-tier RBAC inventory management system for a LATAM tire retailer — 5,000+ SKUs across 4 warehouses, built mobile-first, compliance-ready, and permanently hardened against data mutation.

5,000+
SKUs under management
4
Warehouses
4-tier
RBAC
375px
Mobile-first floor ops
Role Lead Engineer
Stack React 18 / Express / Keycloak / NocoDB
Context LATAM tire retail enterprise
01 — The Problem

Inventory at Scale Breaks Without Architecture

The client ran a multi-location tire and rim enterprise with 5,000+ SKUs across four warehouses — and Excel spreadsheets were the database. Every SKU mutation was irreversible. There was no movement history, no approval chain, no compliance surface.

Three structural failures compounded each other. First, no audit trail: zero record of who changed what, when, or why — compliance review was impossible and disputes had no source of truth. Second, flat permissions: every user had the same access level, so catalog staff could overwrite master product identifiers that should have been immutable. Third, no machine auth: point-of-sale systems needed machine-to-machine access to inventory data without session-based auth, and no secure API key system existed.

The fix could not be a spreadsheet with better locking. It had to be a system where data integrity is enforced by the server — not by trust, training, or UI hiding.

02 — Architecture

Four Trust Tiers, One Locked Identifier

The system is built around a single inviolable rule: the master SKU identifier — CODIGO_MACRO — is generated once and never modified. Every write flows through the same enforcement chain, and every layer in that chain exists to protect that constraint.

01
Authenticate
Keycloak JWT
RS256 browser auth
02
Authorize
RBAC Middleware
role enforcement
03
Filter
PATCH Whitelist
field-level guard
04
Persist
NocoDB Write
persistent store
05
Record
Audit Log
append-only trail
Role Product Edit User Management Audit Log API Keys
SUPERADMIN Full (incl. locked fields) Create / revoke all Full read Issue / revoke
ADMIN Whitelist fields only Manage non-superadmin Full read View only
MANAGER Whitelist fields only No access Filtered read No access
CATALOG Description fields only No access No access No access
"CODIGO_MACRO is generated once — {LINEA(3)}-{MEDIDA(10)}-{MARCA(3)}-{4HEX} — and permanently locked. The server strips it from every PATCH payload. No role, including superadmin, can change it after creation. The UI never even renders an input for it."

The permission matrix is enforced at the API boundary, not in UI rendering. A catalog user who crafts a raw PATCH request against a locked field gets the same rejection as one who clicks a button that doesn't exist. The whitelist is the contract; the interface is just a courtesy.

03 — Engineering Decisions

Six Decisions That Carry the System

Every architectural choice below is rooted in compliance, scale, or the operational reality of warehouse staff working from phones on a shop floor.

1

Dual Auth — Keycloak JWT + SHA-256 API Keys

Browser users authenticate via Keycloak 26 JWT tokens (RS256). POS terminals and machine-to-machine integrations use Authorization: ApiKey sk_... headers — with only SHA-256 hashes stored in the database. Raw keys are shown once at issuance and never persisted, so a database leak yields no usable credentials.

2

Immutable, Append-Only Audit Log

Every product mutation writes an audit record with USER_SUB, action, entity type and ID, a payload diff, source IP, warehouse, and timestamp. The log is append-only by construction — no delete API exists. Compliance review went from impossible to a filtered query.

3

Completeness Percentage — Computed, Never Stored

Product completeness (pct_avance) is computed server-side from 14 mandatory spec fields on every read and delivered as a derived field. It is never written to the database, so it can never go stale, drift, or be manually fudged.

4

Auto-Built Commercial Description

The commercial description is assembled automatically on write from structured spec fields — size, brand, model, load index, speed rating, vehicle type, technology, sidewall, construction, ply. No free-text field means no free-text pollution, and downstream catalogs stay machine-parseable.

5

Mobile-First at a 375px Floor

Breakpoints are enforced at 1024px, 768px, and 375px, with the sidebar switching to an overlay pattern via a class-toggled scrim. Warehouse staff operate the full system from phones in the field — the desktop layout is the adaptation, not the phone layout.

6

TanStack Query v5 Caching

All product and inventory reads flow through TanStack Query v5 with stale-while-revalidate semantics, and mutations apply optimistic updates. On the slow mobile networks warehouse staff actually have, the UI stays responsive while the cache reconciles in the background.

"A warehouse worker on a 375px screen gets the same data integrity guarantees as a superadmin on a desktop. Security is not a UI concern — it's enforced at the server."
React 18 Vite 5 TanStack Query v5 keycloak-js 26 Express 4 NocoDB Docker Tailwind CSS SHA-256 API keys RS256 JWT append-only audit log
04 — Proof

What Shipped, and What It Guarantees

Built in a single sprint from discovery to Phase 1 complete — architecture, backend, frontend, auth, and mobile. Every number below is enforced by the server, not by policy documents.

0
Master-ID mutations post-creation
100%
Audit trail coverage
4
Trust tiers at API boundary
14
Spec fields drive completeness

Full Audit Coverage on Every Write

Every mutation is logged with actor, IP, payload diff, and warehouse. Disputes that previously had no source of truth now resolve with a single query against an append-only record.

Permissions Enforced Where It Counts

The 4-tier hierarchy lives in server middleware, not component visibility. Hiding a button was never the security model — rejecting the request is.

POS Integration Without Session Auth

Hashed API keys gave point-of-sale systems a clean machine-to-machine path into inventory data — issuable and revocable by superadmins, with no raw secrets at rest.

Field Operation on Real Devices

The 375px floor means the system works on the phones warehouse staff already carry — no tablets to procure, no desktop-only workflows bottlenecking the receiving dock.

Need Inventory Infrastructure That Can't Be Corrupted?

I build systems where data integrity is a server-enforced property, not a training document.

Let's Work Together
VERIFIED DELIVERY RECORD →
LIVE PROOF

System in Production

Enterprise inventory management running live — structured spec entry with auto-generated master IDs and per-country code lookups.

IMS — add product form

PRODUCT ENTRY — SPEC FIELDS + AUTO MASTER ID

IMS — country codes reference table

COUNTRY CODES — REFERENCE LOOKUP