EMS Commerce B2B e-commerce platform showing product catalog with 1000+ solar and electrical materials, real-time inventory sync with ERP, dynamic pricing calculator with role-based VAT display, multi-device persistent shopping cart, and Redis caching performance dashboard with <100ms response time
E-Commerce & Integration

EMS Commerce

B2B E-Commerce Platform

<100ms
Response Time
99.9%
Uptime
1000+
Products
Multi-device
Cart Sync

Overview

The Problem

Apex Invest BF distributes solar and electrical materials to resellers and wholesalers in Burkina Faso. They had a working EMS management system for inventory, customers, and internal orders, but no online sales channel. B2B customers had to call or email to see the catalog and prices, then wait for someone to manually process the order. With hundreds of products, three currencies, and complex pricing logic (sector markups, per-item VAT, customer-specific discounts), the process was slow and limited growth.

The core technical problem wasn't building an e-commerce — it was integrating it with the ERP without duplicating data. Items, inventory, and customers already existed in the management system: a separate copy would create synchronization problems immediately. The system needed to read the same data but apply different pricing logic based on the user's role.

The Solution

I built a custom B2B e-commerce in Next.js 16 with React Server Components, fully integrated with the EMS management system's Express backend. The frontend uses Better Auth with a three-level approval system: consumers are auto-approved, resellers and wholesalers require admin approval before seeing price lists. Zustand manages cart state with multi-device persistence.

The pricing logic was the most complex part: each final price depends on a configurable sector markup, item VAT, customer-assigned discounts, and user role (consumer sees VAT-inclusive prices, resellers see them exclusive). I built a calculation engine that applies these rules in sequence, with real-time validation in the cart.

For secure communication between Next.js and the Express backend I built an API proxy that intercepts every request, extracts the HttpOnly session cookie, and forwards it to the server. HttpOnly cookies aren't accessible from client-side JavaScript: the proxy solves this problem while ensuring the session token is never exposed.

The Result

Production B2B e-commerce with 1000+ products and variants, catalog response time under 100ms thanks to multi-level Redis caching, 99.9% uptime, and a persistent cart synchronized across devices.

Key Features

  • Zero-duplication integration with EMS ERP: shared products, inventory, customers (no sync issues)
  • Multi-device cart sync: add on mobile, see on desktop (persistent Better Auth session)
  • Server-side pricing system: sector markup + VAT + custom discounts calculated by user role
  • Response time <100ms for catalog: Redis distributed caching + request-scoped cache

Technologies Used

Next.jsE-CommerceMulti-tenantERP Integration