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

A client company in Burkina Faso (Apex Invest BF) that distributes solar and electrical materials to resellers and wholesalers had an EMS management system that worked well for managing articles, inventory, customers and internal orders, but completely lacked an online sales channel. B2B customers had to call or send emails to see catalog and prices. With hundreds of products and complex pricing system (sector markups, VAT, personalized discounts, 3 currencies), managing orders manually was slow and limited growth.

The main problem wasn't just creating an e-commerce, but integrating it with the ERP without duplicating data. Articles, inventory, customers and price lists were already in the management system - rewriting them would have been a synchronization disaster. A system was needed that used the same data but with different pricing logic: final prices depend on sector markup (configurable), article VAT, discounts assigned to customer, and user role (consumer sees VAT included, reseller/wholesaler sees it excluded).

I developed a custom B2B e-commerce in Next.js 16 with React Server Components for performance, fully integrated with the management system's Express backend. The frontend uses Better Auth for modern authentication with approval system: consumers are auto-approved, resellers and wholesalers require admin approval before seeing prices. Zustand manages state with persistence for cart and user preferences.

To handle authentication between Next.js and Express backend, I created an API proxy (/api/proxy/[...path]) that intercepts all backend calls, extracts the HttpOnly better-auth.session_token cookie and forwards it to the Express server. This solves the problem that HttpOnly cookies aren't accessible from client-side JavaScript, ensuring security (session token never exposed) and automatic CORS handling.

Result: production-ready B2B e-commerce managing 1000+ products with variants, response time <100ms for catalog thanks to multi-level caching (Redis + request-scoped + HTTP headers), 99.9% uptime, user approval system with 3 roles, persistent cart with multi-device synchronization and real-time price validation.

Key Features

  • Zero-duplication integration with EMS ERP: shared products, inventory, customers (no sync issues)
  • Real-time multi-device cart sync: add on mobile, see on desktop (Better Auth session tracking, optimistic UI)
  • Dynamic pricing system: automatic sector markup + VAT + multiple discounts per user role calculation
  • Response time <100ms for catalog: Redis distributed caching + request-scoped cache + batch queries

Technologies Used

Next.jsE-CommerceMulti-tenantERP Integration