
Inventory Guard: one last item, one reservation
Independent portfolio project · Synthetic data · AI-assisted development
The problem
Duplicate requests can decrement stock twice. Two competing orders can claim the same last item if checking and updating stock are separate operations.
The prototype
A dependency-free Python/SQLite model uses a local transaction to check availability, reserve units and record the order together. Identical order-ID replays do not change stock again; conflicting payloads are rejected. Cancellation releases reserved stock once. Confirmation marks an order fulfilled without a second decrement. Invalid transitions and unknown SKUs produce explicit errors.
Verified evidence
All 16 functional tests passed on November 9, 2026, including two threads with separate connections competing for the last item, duplicate requests, conflicting IDs, invalid input and reopening the database. A synthetic example starts with two mugs and ends with one available plus one fulfilled after a cancellation; four committed transition events are recorded.
Reproducible handoff
Python source, automated tests, fictional demonstration, JSON output and a run guide. No client information or commercial results are represented.
Limits
This is a local file-backed SQLite prototype, not a production inventory system or Make/n8n workflow. No Shopify, live APIs, payment processing, multi-SKU orders, expiry, restocking or cross-channel overselling protection. No high-volume, crash or distributed-system testing. The log is not a compliance audit trail. Confirming means fulfilment in this simplified model. Real integrations require separately agreed semantics, security review and failure testing. Do not connect this demo to live stock.
0 likes · 1 view · Nov 9, 2026
Synthetic Python/SQLite prototype: atomic reservations, replay-safe changes and 16 functional tests. AI-assisted. No live integrations or production claims.
Timeline
Nov 9, 2026 - Nov 9, 2026