Table of Contents
- The Challenge
- Architecture & Solution
- Tech Stack
- Monorepo Structure
- Key Engineering Decisions
- 47 Domain Modules
- Dual Design Languages
- B2B Wholesaler Portal
- Financial Intelligence
- Deployment
- Roadmap
The Challenge
Building a premium wellness e-commerce platform that serves both B2C consumers and B2B wholesale partners presents architectural challenges that generic solutions fail to address:
- Platform duality: Consumer-facing experience needs immersive, high-fidelity "Spiritual Premium" design while B2B operations require dense, efficient "Professional Utility" interfaces — one codebase couldn't serve both personas effectively
- Monolithic constraints: The legacy single-repo approach caused deployment coupling — changing the landing page required redeploying the entire system
- Scale requirements: Supporting thousands of products, real-time inventory, GST-compliant invoicing, and B2B credit management required a domain model that could evolve independently
- Search performance: Customer-facing product discovery needed sub-100ms search responses across a growing catalog
The requirement: Build a monorepo that can independently deploy 6 separate Next.js applications while sharing a single NestJS core API, with real-time inventory, full GST compliance, and B2B wholesale capabilities — all while maintaining type safety across the entire codebase.
Architecture & Solution
Aatmanova Universe uses a Turborepo npm workspaces monorepo that enables independent deployment of 6 applications while sharing a single NestJS backend and type-safe packages.
Component Responsibilities
| Layer | Component | Responsibility |
|---|---|---|
| Frontend Apps | 6 Next.js 15 apps | Independent deployment, shared UI package |
| Backend Core | NestJS API | 47 domain modules, business logic |
| Shared Package | TypeScript types | Cross-app type safety, auth utilities |
| Search Engine | MeiliSearch | Sub-100ms product discovery |
| Queue System | BullMQ | Async job processing |
| Object Storage | MinIO | Media and file storage |
| Cache | Redis | Session, query, rate-limit caching |
Tech Stack
| Layer | Technology | Role |
|---|---|---|
| Monorepo | Turborepo + npm workspaces | Independent deployment orchestration |
| Frontend Framework | Next.js 15 | React 19 with App Router |
| Backend Framework | NestJS 11 | Modular API architecture |
| Database | PostgreSQL 16 | Primary data store |
| ORM | Prisma 6 | Type-safe database access |
| Queue | BullMQ + Redis | Async job processing |
| Search | MeiliSearch | Full-text product search |
| Storage | MinIO | S3-compatible object storage |
| Styling | Tailwind 4.0 | Utility-first CSS |
| Authentication | JWT + Cookies | Session management |
| Validation | Zod | Runtime type validation |
| API Docs | Swagger/OpenAPI | API documentation |
| Testing | Playwright, Jest | E2E and unit testing |
| Container | Docker | Deployment packaging |
Monorepo Structure
aatmanova-universe/
├── apps/
│ ├── web/ → Next.js 15 (Consumer Landing)
│ ├── admin/ → Next.js 15 (Admin Dashboard)
│ ├── wholesaler/ → Next.js 15 (B2B Partner Portal)
│ ├── profile/ → Next.js 15 (User Profiles)
│ ├── admin-lite/ → Next.js 15 (Lite Admin)
│ └── api/ → NestJS (Core API)
├── packages/
│ └── shared/ → Universal types, auth, utilities
├── architecture/ → Business logic documentation
├── infra/ → Docker & deployment configs
└── scripts/ → Build & deployment automationApp Port Mapping (Local Development)
| App | Port | Design Language |
|---|---|---|
| web | 3000 | Spiritual Premium |
| admin | 3001 | Professional Utility |
| wholesaler | 3002 | Professional Utility |
| profile | 3003 | Spiritual Premium |
| admin-lite | 3004 | Professional Utility |
| api | 4000 | NestJS |
Key Engineering Decisions
1. Turborepo for Independent Deployments
Each app can be deployed independently without affecting others. Landing page changes don't require redeploying the admin panel:
// turbo.json
{
"pipeline": {
"build": {
"dependsOn": ["^build"],
"outputs": ["dist/**", ".next/**"]
},
"dev": {
"cache": false,
"persistent": true
},
"lint": {},
"test": {}
}
}2. Dual Design Language System
Two completely different UI experiences from the same monorepo:
Spiritual Premium (web, profile):
// Cosmic gradients, glassmorphism, celestial animations
<div className="bg-gradient-to-br from-purple-900 via-indigo-900 to-black">
<GlassCard>{children}</GlassCard>
</div>Professional Utility (admin, wholesaler, admin-lite):
// High-density data grids, Bento layouts, scannable deltas
<div className="grid grid-cols-4 gap-4">
<BentoCard>{children}</BentoCard>
</div>3. Edge Middleware for Route Protection
All B2B dashboard routes protected at the edge:
// apps/wholesaler/middleware.ts
import { NextResponse } from 'next/server';
import type { NextRequest } from 'next/server';
export function middleware(request: NextRequest) {
const token = request.cookies.get('wholesaler_session');
if (!token && request.nextUrl.pathname.startsWith('/dashboard')) {
return NextResponse.redirect(new URL('/login', request.url));
}
return NextResponse.next();
}4. MeiliSearch for Sub-100ms Product Discovery
Real-time search across thousands of products:
// modules/search/search.service.ts
async function searchProducts(query: string, filters: SearchFilters) {
const results = await meiliClient.index('products').search(query, {
filter: filters.category ? `category = "${filters.category}"` : '',
limit: 20,
attributesToHighlight: ['name', 'description'],
});
return results;
}5. BullMQ for Async Job Processing
Inventory alerts, order processing, and notification dispatch:
// jobs/inventory-alerts.processor.ts
@Processor('inventory')
export class InventoryAlertsProcessor {
@Process()
async handleStockAlert(job: Job) {
const product = await this.inventoryService.findById(job.data.productId);
if (product.stock <= product.lowStockThreshold) {
await this.notificationService.sendLowStockAlert(product);
}
}
}47 Domain Modules
The NestJS API contains 47 independently versioned domain modules:
| Category | Modules |
|---|---|
| Core | auth, users, customers, notifications |
| Commerce | catalog, inventory, orders, payments, invoices, shipments |
| Finance | ledger, credit-notes, refunds, quotes, reports, challans |
| B2B | wholesaler, coupons, subscriptions, gift-cards |
| Content | blog, events, faq, testimonials, reviews |
| Wellness | services, bookings, programs, mantra, gita, numerology, pkh |
| Operations | activity-log, audit-logs, analytics, automation, community, search, referrals, health |
Dual Design Languages
1. Spiritual Premium (Consumer-Facing)
- Aesthetic: Cosmic gradients, glassmorphism, celestial animations
- Typography: Outfit (Headings), Plus Jakarta Sans (Body)
- Persona: Immersive, enlightened, high-fidelity
2. Professional Utility (Operations-Facing)
- Aesthetic: High-density data grids, scannable Bento layouts
- Typography: Plus Jakarta Sans / DM Sans
- Persona: Efficient, precise, action-oriented
B2B Wholesaler Portal
A complete B2B partner management system:
- Authentication: JWT + HttpOnly cookies with 7-day expiry
- Partner Dashboard: Real-time credit limit, outstanding balance, available credit
- Procurement Wizard: Connected to live backend catalog and order engine
- Self-Service Invoices: Partner invoice list with real-time status mapping
- Operational Ledger: Credit utilization, balance trends, entry-level analysis
- Secure Middleware: Edge-protected dashboard routes
Financial Intelligence
GST Compliance (India)
- GSTR-1 Reporting: B2B, B2CS, and HSN-wise CSV exports
- Tax Engine: Automatic GST calculation per state
- Invoice Generation: Proper tax breakdown with HSN codes
Multi-Account Treasury
- Bank Account Selection: Precise debit account during payment recording
- Dynamic Treasury API: Real-time liquidity account fetching
Credit Management
- Credit Limits: Partner-specific credit boundaries
- Outstanding Tracking: Real-time balance monitoring
- Credit Notes: Item-level returns and credit issuance
Deployment
Quick Start
# Install dependencies
npm install
# Start local development
./start.sh
# Or manually
cp .env.example .env
docker compose up -d
npm run db:migrate
npm run devInfrastructure (Docker Compose)
services:
postgres:
image: postgres:16
ports:
- "5434:5432"
redis:
image: redis:7
ports:
- "6380:6379"
meilisearch:
image: getmeili/meilisearch
ports:
- "7701:7700"
minio:
image: minio/minio
ports:
- "9005:9000"Production VPS Nodes
| Node | Services |
|---|---|
| node-2 | Primary: Aatmanova Universe, Media Stack |
Production Checklist
# Build all apps
npm run build
# Run database migrations
npm run db:migrate
# Deploy to VPS
npm run deploy:vps
# Verify health
curl https://aatmanova.school/healthRoadmap
Phase 1.0 — Core Foundation (Complete)
- Initial monorepo setup with Turborepo
- Basic auth and user management
Phase 1.5 — Commerce Foundation (Complete)
- Product catalog and inventory
- Basic ordering flow
Phase 1.6 — Monorepo Tectonic Shift (Complete)
- 3-App Architecture: web, admin, wholesaler
- Dual Design Language System
Phase 1.7 — Admin Security Perimeter (Complete)
- Secure login, Edge Middleware, Cookie-based sessions
Phase 1.8 — Wholesaler Portal (Complete)
- B2B authentication, procurement wizard, real-time invoices
Phase 1.9 — Modernized Financial Transparency (Complete)
- Self-service invoices, operational ledger, audit trail
Phase 2.0 — Performance Optimization (In Progress)
- MeiliSearch integration
- Redis caching layer
Phase 2.1 — Mobile Apps (Planned)
- React Native companion apps
Phase 3.0 — International Expansion (Future)
- Multi-currency, multi-language support
Engineering Proof
Real-world validation, system demonstrations, and interface captures of the execution states.
System Demonstration
Video walkthrough detailing core logic, interactions, and system behaviors in action.
System Captures
Architecture Feedback
Spotted a potential optimization or antipattern? Let me know.


