Laptop mockup showing the ApexStore catalog: sector and category filters, product cards with prices.
E-Commerce & Integration

EMS Commerce

B2B E-Commerce Platform

<100ms
Response Time
3 roles
Role-based Pricing
1000+
Products
Multi-device
Cart Sync

Overview

The Problem

APEX Invest is a holding company active in construction, photovoltaics and energy. In Burkina Faso it distributes materials to resellers and wholesalers. 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 and complex pricing logic (sector markups, per-item VAT, customer-specific discounts), the process was slow and limited growth. The system supports three currencies, although the client uses just one today, the XOF.

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 (consumers see VAT-inclusive prices, resellers see them VAT-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 responses under 100ms thanks to Next.js caching. The cart is persistent and syncs across devices.

Key Features

  • No duplication with the EMS ERP: products, inventory and customers shared
  • 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
  • Catalog under 100ms: Next.js caching and React Server Components

Technologies Used

Next.jsBetter AuthZustandERP Integration