Back to projects

CD Uniform - Multi-Tenant B2B SaaS Platform

CD Uniform - Multi-Tenant B2B SaaS Platform
Freelance

Project Overview

CD Uniform (MyUniforms.au) is a comprehensive multi-tenant B2B SaaS platform enabling uniform suppliers to manage corporate clients with budget allocation, manager approval workflows, and real-time ERP synchronization.

Architected and developed complete system with 18 MongoDB models and 74 RESTful API endpoints, implementing role-based access control across Super Admin, Manager, and Employee roles with tenant isolation.

Implemented complex Cin7 ERP integration synchronizing 30+ price tiers (retail, wholesale, corporate pricing), automating product catalog updates, and bi-directional order/payment syncing with error recovery mechanisms.

Built hybrid payment system combining budget wallet allocation and Stripe credit card processing using MongoDB transactions, ensuring atomicity across distributed operations with automatic rollback support.

Designed flexible product customization engine supporting tenant-specific pricing overrides, logo assignments, and dynamic enhancements (embroidery, text) with real-time price calculation.

Developed manager approval workflow for budget-based orders with notification system, audit logging, and order state machine managing 7 lifecycle stages (pending → processing → shipped → delivered/cancelled/refunded/rejected).

Created CI/CD pipeline with GitHub Actions deploying to AWS EC2 via PM2 and Caddy reverse proxy, automating push-to-deploy workflow.

Key Features

Multi-Tenant Architecture

Isolated tenant data with custom branding (logos, colors, banners) and role-based access control ensuring complete data separation.

Cin7 ERP Integration

Automated product catalog synchronization with 30+ price tier mapping, contact imports, order syncing, and payment posting with transaction tracking.

Hybrid Payment System

Supports budget wallet, Stripe credit card, invoice, on-account, and hybrid payments (partial budget + credit card) with transaction atomicity.

Budget Management System

Per-user, per-period budget allocation with usage tracking, approval workflows, and comprehensive audit logs for compliance.

Order Approval Workflow

Manager approval required for budget-based orders with rejection/approval notes, preventing processing until both payment confirmation and approval.

Product Customization Engine

Dynamic enhancements (embroidery, logos, text) with tenant-specific pricing, color variants, sizes, and real-time price calculation.

Real-Time Inventory Sync

Automatic synchronization with Cin7 ERP for real-time inventory availability checks and product catalog updates.

Notification System

Real-time notifications for order status changes, approvals, budget alerts, and system events with email templates.

Challenges & Solutions

Hybrid Payment Transaction Atomicity

Processing split payments where orders are partially paid from budget wallet and remainder via Stripe required transactional atomicity across budget deduction, Stripe PaymentIntent creation, and order creation.

Solution:

Implemented MongoDB transactions with rollback support, coordinating Stripe API with database operations using try-catch-rollback pattern and Stripe idempotency keys for reliability.

Complex Cin7 ERP Integration

Mapping Cin7's 30+ price tiers (retailAUD, wholesaleAUD, corporate1-10, etc.) to tenant-specific pricing with inconsistent API field naming, rate limits, and precise payload formatting requirements.

Solution:

Built robust service layer with comprehensive error handling, field truncation logic (transactionRef 50 chars), batch processing for contacts/orders, and intelligent price tier mapping logic.

Multi-Tenant Product Assignment

Allowing global product catalog shared across tenants while supporting tenant-specific pricing, logo assignment, and availability required normalized schema design without data duplication.

Solution:

Created TenantProduct model with references to global CIN7Product, implementing tenant-specific price overrides and logo product code assignment with flexible JSON schema.

Manager Approval Workflow

Implementing flexible approval rules based on payment method, order value, and tenant configuration while preventing order processing until both payment confirmation and manager approval.

Solution:

Built state machine for order status with approval_status field; managers can approve/reject with notes; integrated with notification system for real-time updates.

Project Gallery

Multi-tenant dashboard with budget management and order tracking

Multi-tenant dashboard with budget management and order tracking

Product catalog with customization options and real-time pricing

Product catalog with customization options and real-time pricing

Project Details

Timeline

2024 - Present

Company

Freelance

My Role

Full-Stack Engineer (Solo Developer)

Technologies Used

Next.js 14
TypeScript
React 18
Node.js
MongoDB
Mongoose
NextAuth.js
JWT
Stripe
Cin7 ERP API
Cloudinary
Resend
TailwindCSS
Shadcn/ui
Radix UI
React Hook Form
Zod
Recharts
AWS EC2
PM2
GitHub Actions