Skip to content

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 config

Regional 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:

  1. User visits main domain (iwm.com)
  2. System detects user's geolocation via IP
  3. Confirmation modal appears with detected region and option to change
  4. User confirms or selects different region
  5. Redirect to regional platform

Domain-Aware Frontend

Single React app deployed to multiple domains with platform-specific theming:

DomainDefault RouteModulesLanding
iwm-platform.octosparrow.space/dashboardAll modules✅ Shows landing page
invest.iwm-platform.octosparrow.space/investinvestment, auth, profile-
shop.iwm-platform.octosparrow.space/shopcommerce, auth, profile-
partner.iwm-platform.octosparrow.space/dashboardpartner, auth, profile-
localhost/dashboardAll 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

PlatformKYC RequiredPartner FeaturesNotes
InvestYes (for investment)Widget in profileKYC hub - verification happens here
ShopNoWidget in profileReads KYC status if needed for specific products
PartnerNo (for access)Full dashboardAuto-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