StockGuard is a Java inventory reservation engine for limited-stock commerce workflows. It prevents overselling within a shared process, handles idempotent retries, and releases expired reservations.
- Atomic stock reservation under concurrent requests.
- Customer-scoped idempotency keys with payload conflict detection.
- Explicit reservation confirmation, cancellation, and expiration.
- Immutable price snapshots and exact decimal arithmetic.
- UTF-8 inventory report export.
- Automated regression tests on Windows and Linux.
Java 17 or later and PowerShell.
powershell -NoProfile -ExecutionPolicy Bypass -File .\run.ps1 test
powershell -NoProfile -ExecutionPolicy Bypass -File .\run.ps1 demo
powershell -NoProfile -ExecutionPolicy Bypass -File .\run.ps1 stressThis version stores data in memory and provides guarantees only for threads sharing the same inventory store instance. It does not provide database persistence, HTTP endpoints, authentication, or distributed coordination. CSV reports are exports and are not loaded as application state.
The regression suite covers stock conservation, concurrent requests, duplicate retries, ownership matching, state transitions, expiry boundaries, decimal arithmetic, and CSV encoding. The concurrency scenario is a correctness check rather than a throughput benchmark.