Hardware Lab is a fully operational e-commerce platform designed and engineered
by James Mwangi as a live portfolio piece. It runs as a production environment
for secure payment flows, real-time inventory management, and global logistics
automation. The frontend is built on Cloudflare Pages with a Supabase (PostgreSQL)
backend, integrating both Stripe (international card payments) and the Safaricom
Daraja API (M-Pesa STK Push) for dual-currency checkout — a pattern common in
African FinTech systems. Every product listing is fetched dynamically from
Supabase with Row Level Security policies enforced at the database layer.
Cloudflare Pages
Supabase PostgreSQL
Row Level Security
Stripe / M-Pesa Daraja
DHL Express API
Vanilla JS ES2022
localStorage Cart
Real-Time Order Tracking
// System Design — How This Platform Works
Technical Architecture
This platform is designed as a modern JAMstack application demonstrating
production-level patterns relevant to senior software engineering roles.
The following components form the core of the system.
🗄️
// Layer 1 — Data
Supabase (PostgreSQL)
Products, orders, returns and reviews are persisted in a normalised relational schema with Row Level Security (RLS) policies enforced at the database layer. Anon users can read active inventory; only authenticated service roles may write order state.
- RLS policies per table
- Real-time subscriptions (orders)
- Indexed on active + created_at
💳
// Layer 2 — Payments
Dual-Gateway Checkout
Stripe handles international card payments via the Elements SDK. M-Pesa payments use the Safaricom Daraja STK Push API, triggering a payment prompt on the customer's handset. A Cloudflare Worker serves as the callback receiver, updating order state in Supabase upon confirmation.
- Stripe Elements (PCI DSS)
- M-Pesa Daraja OAuth 2.0
- Worker callback → DB update
🚚
// Layer 3 — Logistics
Intelligent Shipping Engine
Shipping cost and carrier selection are computed client-side based on a zone lookup table (Nairobi / Rest of Kenya / International). DHL Express is integrated for tracked international fulfilment. The order tracking portal queries Supabase for live state transitions (Processing → Shipped → In Transit → Delivered).
- Zone-based cost calculation
- DHL tracking reference storage
- 4-state order machine
🔐
// Layer 4 — Security
Authentication & Authorisation
Supabase Auth provides email/password and Google OAuth 2.0 flows. Checkout fields are pre-filled from authenticated user metadata, reducing friction. The admin gateway uses session-scoped PIN + Supabase service role — a pattern appropriate for low-traffic internal tooling while a full RBAC system is overkill.
- Supabase Auth (JWT)
- Google OAuth 2.0
- RLS + service role separation