B2B Order Entry API (v3 Migration) In Progress

Rebuilt a legacy .NET order pipeline on Bun and Hono, with 69 unit tests covering allocation, UPS ranking across 14 warehouses, and Redis idempotency.

Built at a private employer. Details are sanitized; architecture and outcomes are described without proprietary identifiers.

Role
Lead Full Stack Developer
Year
2026
Category
Software Dev

About This Project

Replaced a legacy .NET and PHP order intake stack with a Bun and Hono B2B API inside the v3 monorepo. Authored the 974-line team reference that specifies the eight-step pipeline, the hybrid inventory model, the idempotency contract, and a 16-code error catalog, then built the pipeline services behind it: SKU and promo validation, UPS warehouse ranking across 14 sites, stock allocation, and a Redis-backed idempotency store, all under 69 unit tests. Landed the supporting Postgres schema across eight Supabase migrations. The repository layer, the processOrder orchestrator, and the public POST /orders route are the remaining MVP slice.

Technologies Used

JavaScriptBunHonoPostgreSQLSupabaseIBM DB2RedisZodUPS API

Engineering Challenges

Hybrid Inventory Model: Synced the slow-moving validation rules such as minimum order quantity, case quantity, and dropship flags into Postgres, while reading per-warehouse quantities live from DB2 at allocation time so stock stays authoritative with no cache to invalidate.

Third-Party Ranking Resilience: UPS rating drives warehouse ranking, so the service caches OAuth tokens with an expiry skew, deduplicates concurrent refreshes, rates candidate warehouses in parallel, and degrades through cached rankings, customer preference rankings, and Haversine distance from ZIP geocoding before it fails.

Stored Procedure Elimination: Replaced SQL Server stored procedures with Postgres tables, data-sync types, and runtime JavaScript actions, delivered as eight migrations covering order processing tables, warehouse ranking locations, and customer order preferences.

Cross-Language Parity: Specified side-by-side JSON diff validation against the legacy .NET harness for roughly 1,000 lines of orchestrator logic and the 57 regression tests that guarded it.

Technical Highlights

Tested Pipeline Services: 69 unit tests across 11 files cover allocation, location assignment, warehouse ranking, UPS rating and OAuth, ZIP geocoding, idempotency, SKU validation rules, promo codes, and response building.

Idempotency Contract: Header-based keys with a SHA-256 canonical body hash, distributed in-flight locking through a Redis lock with a Lua release script, and replay of the original response instead of a duplicate order.

Case-Aware Allocation: Walks the ranked warehouse list allocating full cases before remainders, prefers near warehouses that can fulfill outright, merges repeat assignments, and emits backorder lines only where routing codes allow it.

Token-Scoped Security: Customer identity resolves from the B2B API credential to the customer record, never from a customer number supplied in the request body.

Structured Outcome Catalog: 10 blocking error codes and 6 non-blocking warning codes give integrators and parity tests one vocabulary for ranking, promo, allocation, and stock results.

Business Logic

B2B Channel Enablement: API integrators gain programmatic order placement instead of a manual email intake workflow.

Platform Modernization: Moves order logic off SQL Server stored procedures into a testable Bun service aligned with the broader v3 stack.

ERP Alignment: Preserves AS400 ownership of pricing and final confirmation while the API owns sourcing decisions and structured responses.

Release Risk Reduction: Nine phased user stories, a parity harness against the legacy suite, and the hybrid inventory design de-risk a single-release cutover with no dual-path feature flags.