JAJerry Aneke
Back to all projects

Ductape Multi-Provider Commerce

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

FINTECH / AGENT COMMERCE
Sandbox Tested
Paystack test checkout offering Success, Bank Authentication and Declined test outcomes for a 500 naira payment.
Guarantee: Stock reservation is atomic: UPDATE inventory SET reserved = reserved + qty WHERE (on_hand - reserved) >= qtyVERIFIED
Flutterwave test checkout for a 500 naira payment with a banner stating all transactions are mocked.
Year
2026
Type
FINTECH / AGENT COMMERCE
Role
Backend Engineer (Built solo for a startup client)
Status
Sandbox Tested
Stack
TypeScriptNode.jsPostgreSQLModel Context Protocol (MCP)Vitestpg-mem
Overview

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.

Problem

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.

Solution

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.

My Contribution

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.

Technical Decisions

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.

Challenges

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.

Outcome

All 72 automated integration, contract, and concurrency test suites pass cleanly. Validated in sandbox mode across multi-provider checkout flows.

What I Learned

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.