Ductape Multi-Provider Commerce
Agent-operable commerce engine with atomic inventory reservation, multi-gateway routing, and an idempotent checkout saga.


An enterprise-grade, agent-operable commerce backend built as a strict Modular Monolith. The system exposes both a clean REST API and a Model Context Protocol (MCP) server for autonomous AI agents, backed by atomic inventory control and a resilient checkout saga.
High-concurrency commerce systems frequently suffer from inventory overselling during simultaneous checkout attempts, duplicate payment processing caused by repeated or delayed gateway webhooks, and prompt-injection risks when autonomous AI agents execute commerce actions.
Engineered a decoupled domain architecture separating Identity, Inventory, Orders, Payments, Notifications, and Idempotency. Designed an atomic conditional reservation engine verified by concurrent race tests, SHA-256 mutation idempotency, and an MCP server with strict Zod schemas and passive JSON data envelopes.
Architected the entire backend modular monolith solo for a startup client. Implemented the atomic SQL reservation engine guaranteeing zero overselling under simultaneous competing checkout requests. Engineered the multi-provider payment router and checkout saga handling Paystack, Flutterwave, Stripe, and Mock providers in sandbox environments. Created the Model Context Protocol (MCP) server exposing 10 scoped tools with role-based permissions and prompt-injection defense, and authored 72 automated Vitest tests executing against an in-memory PostgreSQL isolation harness.
Adopted database-level atomic conditional updates instead of distributed Redis locks, guaranteeing inventory consistency directly in the PostgreSQL storage engine. Enforced strict integer minor unit arithmetic across all payment calculations to eliminate IEEE 754 floating-point rounding errors. Confined untrusted agent inputs strictly inside passive JSON envelopes to prevent prompt-injection attacks from overriding LLM tool instructions.
Eliminating race conditions during concurrent checkouts competing for the final stock unit, preventing double-processing on repeated gateway webhooks, and orchestrating compensating refunds when late webhooks arrive after reservation expiration.
All 72 automated integration, contract, and concurrency test suites pass cleanly. Validated in sandbox mode across multi-provider checkout flows.
Designing for autonomous agents requires treating the agent as an untrusted client: every tool invocation must enforce rigorous schema validation, bounded pagination, and clear permission scopes.