Skip to content

Latest commit

Β 

History

History
130 lines (88 loc) Β· 3.98 KB

File metadata and controls

130 lines (88 loc) Β· 3.98 KB

πŸ’Ό MLM Demo β€” Microservices + Flutter Frontend

MLM Demo is a complete multi-level marketing (MLM) system featuring a fully containerized FastAPI-based microservices backend and a Flutter-based mobile frontend β€” all in one repository. Designed to showcase modern backend architecture, frontend integration, and DevOps orchestration.


πŸ”§ Architecture Overview

This project contains the following services:

  • Authentication Service – Handles user registration, login, verification, and tokens
  • MLM Service – Manages MLM trees, spillover logic, bonus distribution, rank evaluations
  • URL Shortener Service – Lightweight service to generate and resolve short URLs
  • Gateway API – Central entry point for frontend clients; routes to appropriate microservices
  • Flutter Frontend App – Cross-platform mobile app that connects via Gateway

Each microservice runs as an isolated FastAPI app on Docker with its own PostgreSQL database and optional Redis cache.


πŸ“ Directory Layout

.
β”œβ”€β”€ authentication/               # Authentication microservice
β”œβ”€β”€ mlm_service/                # MLM tree and bonus microservice
β”œβ”€β”€ url_shortener/      # URL shortening microservice
β”œβ”€β”€ mlm_api_gateway/            # API gateway for frontend
β”œβ”€β”€ mlm_demo_frontend_flutter/           # πŸ“± Flutter frontend app
β”‚   β”œβ”€β”€ lib/
β”‚   β”œβ”€β”€ android/
β”‚   β”œβ”€β”€ ios/
β”‚   └── pubspec.yaml
β”œβ”€β”€ frontend/mlm_demo.apk  # Android build of the app (APK)
β”œβ”€β”€ compose.yml     # Microservices orchestration

🐳 Running Backend Services

Ensure Docker & Docker Compose are installed, then run:

docker compose up --build

This will:

  • Build and start all backend microservices
  • Automatically manage database and redis health checks
  • Launch the API Gateway after all other services are healthy

🌐 Service URLs

Service URL Description
Auth http://localhost:8000 User registration/login etc.
MLM http://localhost:11000 MLM tree, bonus logic, ranks
URL Shortener http://localhost:9000 Short link creation & redirection
Gateway http://localhost:10000 Unified API endpoint for frontend

πŸ“± Flutter Frontend

The frontend is built with Flutter and located at:

/frontend

πŸ“¦ APK Build

An Android APK (mlm_demo.apk) is already included in:

/frontend/mlm_demo.apk

You can install and test it directly using:

adb install frontend/mlm_demo.apk

Or open it on a physical/emulated Android device.

πŸ“² Flutter Setup

To run the Flutter app locally:

cd frontend
flutter pub get
flutter run

Make sure flutter doctor is βœ… and your device/emulator is running.


βœ… Backend Features (MLM)

  • 🌳 Forced matrix tree with spillover logic
  • πŸ’Έ Multi-level bonus distribution engine
  • πŸŽ– Dynamic rank calculation (Bronze β†’ Diamond)
  • πŸ“… Weekly earnings reports
  • ⚑ Redis caching for fast downline traversal
  • πŸš₯ Microservice health checks and startup order
  • πŸ›‘οΈ JWT-compatible user auth via Auth service

πŸ§ͺ Tech Stack

  • Backend: FastAPI (Python 3.11), PostgreSQL, Redis
  • Frontend: Flutter 3.x (Dart)
  • Orchestration: Docker Compose
  • Communication: REST via API Gateway

πŸ“œ License

Built by Irfan Ahmad as a demo project for full-stack microservices + mobile app integration.

For questions, collaboration, or improvements β€” feel free to reach out!