Architecture Overview
Platform Description
MLM platform with Investment Marketplace, Product Marketplace, and MLM Admin Panel.
Tech Stack
- Frontend: React + TypeScript
- Backend: Node.js + TypeScript (NestJS)
- Database: PostgreSQL with ltree extension
- Cache: Redis (optional, for sessions/rate limiting)
- Queue: pg-boss (PostgreSQL-native)
Project Structure
Turborepo monorepo with pnpm workspaces:
iwm-platform/
├── apps/
│ ├── api/ # Backend API (NestJS)
│ │ ├── src/
│ │ │ ├── modules/ # Business modules
│ │ │ │ ├── auth/ # JWT, 2FA, sessions
│ │ │ │ ├── users/ # User management
│ │ │ │ ├── kyc/ # Sumsub KYC integration
│ │ │ │ ├── mlm/ # MLM core
│ │ │ │ │ ├── partners/ # Partner entity, tree
│ │ │ │ │ ├── ranks/ # 21-rank system
│ │ │ │ │ ├── commissions/ # 7 income types
│ │ │ │ │ ├── payouts/ # Withdrawal requests
│ │ │ │ │ └── pools/ # Leadership pools
│ │ │ │ ├── investment/ # Investment marketplace
│ │ │ │ ├── commerce/ # Product marketplace
│ │ │ │ └── admin/ # Admin panel
│ │ │ │
│ │ │ ├── core/ # Cross-cutting concerns
│ │ │ │ ├── guards/ # Auth, role guards
│ │ │ │ ├── interceptors/ # Logging, transform
│ │ │ │ ├── filters/ # Exception handling
│ │ │ │ └── decorators/ # Custom decorators
│ │ │ │
│ │ │ ├── infrastructure/ # External adapters
│ │ │ │ ├── database/ # Prisma config
│ │ │ │ ├── cache/ # Redis
│ │ │ │ ├── queue/ # pg-boss workers
│ │ │ │ └── external/ # Sumsub, payments, etc.
│ │ │ │
│ │ │ ├── main.ts # Entry point
│ │ │ └── app.module.ts # Root module
│ │ │
│ │ ├── package.json
│ │ ├── tsconfig.json
│ │ └── nest-cli.json
│ │
│ └── web/ # Frontend (React + Vite)
│ ├── src/
│ │ ├── config/
│ │ │ ├── domains.ts # Multi-domain routing config
│ │ │ ├── platformTheme.ts # Platform-specific theming
│ │ │ └── constants.ts # App constants
│ │ ├── i18n/
│ │ │ ├── index.ts # i18n configuration
│ │ │ └── locales/ # EN/RU translation files
│ │ ├── layouts/
│ │ │ ├── LandingLayout.tsx
│ │ │ ├── AppLayout.tsx
│ │ │ ├── CommerceLayout.tsx
│ │ │ ├── InvestmentLayout.tsx
│ │ │ ├── AdminLayout.tsx
│ │ │ └── auth/ # Platform-themed auth layout
│ │ ├── modules/ # Feature modules (lazy-loaded)
│ │ │ ├── landing/ # Platform landing page
│ │ │ ├── auth/ # Login, register, 2FA (i18n)
│ │ │ ├── investment/ # Strategies, wizard, portfolio
│ │ │ ├── commerce/ # Products, cart, checkout
│ │ │ ├── partner/ # MLM dashboard, team, commissions
│ │ │ ├── admin/ # Users, KYC, payouts
│ │ │ └── profile/ # User profile, KYC
│ │ ├── services/
│ │ │ └── api/ # API client, auth service
│ │ ├── hooks/ # useAuth, useCurrentUser
│ │ ├── mocks/ # Mock data for development
│ │ ├── utils/ # Formatters, helpers
│ │ ├── App.tsx # Domain-aware routing
│ │ └── main.tsx # Entry with providers
│ │
│ ├── package.json
│ ├── vite.config.ts
│ ├── tailwind.config.js
│ └── index.html
│
├── packages/ # Shared packages
│ ├── shared-types/ # TypeScript interfaces (BE + FE)
│ ├── shared-utils/ # Common utility functions
│ └── ui-components/ # Shared React components
│
├── docs/ # VitePress documentation
├── prisma/
│ └── schema.prisma # Database schema
├── docker/
│ ├── docker-compose.yml # PostgreSQL + Redis
│ └── init-db.sql # DB initialization
│
├── package.json # Root with Turborepo scripts
├── pnpm-workspace.yaml # Workspace config
├── turbo.json # Turborepo config
└── tsconfig.json # Base TypeScript configRegional Platform Architecture
The platform operates as separate regional deployments for regulatory compliance:
Regional Isolation:
- Each region is a separate deployment with its own database
- User accounts are regional (one account per region)
- KYC status is regional and shared across platforms within the region
- Cross-region access requires separate account registration
Region Detection Flow:
- User visits main domain (iwm.com)
- System detects user's geolocation via IP
- Confirmation modal appears with detected region and option to change
- User confirms or selects different region
- Redirect to regional platform
Domain-Aware Frontend
Single React app deployed to multiple domains with platform-specific theming:
| Domain | Default Route | Modules | Landing |
|---|---|---|---|
iwm-platform.octosparrow.space | /dashboard | All modules | ✅ Shows landing page |
invest.iwm-platform.octosparrow.space | /invest | investment, auth, profile | - |
shop.iwm-platform.octosparrow.space | /shop | commerce, auth, profile | - |
partner.iwm-platform.octosparrow.space | /dashboard | partner, auth, profile | - |
localhost | /dashboard | All modules | ✅ Shows landing page |
Regional SSO (Single Sign-On)
Within each region, user authentication is shared across all platforms:
- One account per region - Register once, access invest, shop, and partner platforms
- Shared session - Login on any platform, stay logged in across all regional platforms
- KYC propagation - Complete KYC on invest platform, status available on shop and partner
Platform-Specific Features
| Platform | KYC Required | Partner Features | Notes |
|---|---|---|---|
| Invest | Yes (for investment) | Widget in profile | KYC hub - verification happens here |
| Shop | No | Widget in profile | Reads KYC status if needed for specific products |
| Partner | No (for access) | Full dashboard | Auto-activates on first login |
Features:
- Platform-specific auth page theming (colors, gradients per platform)
- i18n support with EN/RU language toggle
- External provider integration for investment strategies with deep SSO and bi-directional KYC sync