Skip to main content

System Architecture Diagram

Overview

This document describes the high-level system architecture of the Learnille platform.

Architecture Principles

  • Microservices: Modular, independently deployable services
  • API-First: All interactions through well-defined APIs
  • Scalability: Horizontal scaling for high availability
  • Security: Defense in depth with multiple security layers
  • Observability: Comprehensive logging, monitoring, and tracing

High-Level Architecture

┌─────────────────────────────────────────────────────────────────┐
│ Client Layer │
│ ┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐ │
│ │ Web Client │ │ Mobile App │ │ Admin Panel │ │
│ │ (React) │ │ (React Native)│ │ (React) │ │
│ └─────────────────┘ └─────────────────┘ └─────────────────┘ │
└─────────────────────────────────────────────────────────────────┘


┌─────────────────────────────────────────────────────────────────┐
│ API Gateway Layer │
│ ┌─────────────────┐ │
│ │ API Gateway │ (Rate limiting, Authentication, Routing) │
│ │ (Kong/Nginx) │ │
│ └─────────────────┘ │
└─────────────────────────────────────────────────────────────────┘


┌─────────────────────────────────────────────────────────────────┐
│ Service Layer │
│ ┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐ │
│ │ User Service │ │ Course Service │ │Consultation Svc │ │
│ │ (Node.js) │ │ (Node.js) │ │ (Node.js) │ │
│ └─────────────────┘ └─────────────────┘ └─────────────────┘ │
│ ┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐ │
│ │ Payment Service │ │Notification Svc │ │ Analytics Svc │ │
│ │ (Python) │ │ (Node.js) │ │ (Python) │ │
│ └─────────────────┘ └─────────────────┘ └─────────────────┘ │
└─────────────────────────────────────────────────────────────────┘


┌─────────────────────────────────────────────────────────────────┐
│ Data Layer │
│ ┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐ │
│ │ PostgreSQL │ │ Redis │ │ Elasticsearch │ │
│ │ (Primary DB) │ │ (Cache) │ │ (Search) │ │
│ └─────────────────┘ └─────────────────┘ └─────────────────┘ │
│ ┌─────────────────┐ ┌─────────────────┐ │
│ │ OpenSearch │ │ Cloudflare R2 │ │
│ │ (Search/Vector)│ │ (Files/Media) │ │
│ └─────────────────┘ └─────────────────┘ │
└─────────────────────────────────────────────────────────────────┘


┌─────────────────────────────────────────────────────────────────┐
│ Infrastructure Layer │
│ ┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐ │
│ │ Docker / PM2 │ │ Self-Hosted │ │ Nginx Proxy │ │
│ │ (Containerization│ │ (Linux VPS/Bare)│ │ (Reverse Proxy) │ │
│ └─────────────────┘ └─────────────────┘ └─────────────────┘ │
│ ┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐ │
│ │ New Relic APM │ │ New Relic Logs │ │ Security │ │
│ │ (Performance) │ │ (Aggregation) │ │ (WAF, SSL) │ │
│ └─────────────────┘ └─────────────────┘ └─────────────────┘ │
└─────────────────────────────────────────────────────────────────┘

Component Descriptions

Client Layer

  • Web Client: React-based single-page application for learners and instructors
  • Mobile App: React Native application for iOS and Android
  • Admin Panel: React-based dashboard for platform administrators

API Gateway Layer

  • API Gateway: Centralized entry point handling authentication, rate limiting, and request routing
  • Load Balancer: Distributes traffic across service instances
  • CDN: Content delivery network for static assets and media

Service Layer

  • User Service: Manages user accounts, authentication, and profiles
  • Course Service: Handles course creation, management, and content delivery
  • Consultation Service: Manages one-on-one and group consultation sessions
  • Payment Service: Processes payments and manages subscriptions
  • Notification Service: Handles email, SMS, and in-app notifications
  • Analytics Service: Tracks user behavior and generates insights

Data Layer

  • PostgreSQL: Primary relational database for structured data
  • Redis: In-memory cache for session data and frequently accessed information
  • Elasticsearch: Search engine for course content and user data
  • MongoDB: Document database for flexible data structures
  • S3 Storage: Object storage for files, images, and videos

Infrastructure Layer

  • Docker / PM2: Containerization and process management platform
  • Self-Hosted VPS: High-performance Linux instances (Hetzner / DigitalOcean / Bare Metal)
  • Nginx Proxy: Reverse proxy, SSL termination, and rate-limiting ingress
  • Cloudflare R2: High-performance S3 API object storage with zero egress fees
  • New Relic: Centralized APM, transaction tracing, and structured log management
  • Sentry: Real-time exception tracking and error reporting

Data Flow

  1. User Request: Client sends request to API Gateway
  2. Authentication: Gateway validates JWT token and user permissions
  3. Routing: Request routed to appropriate microservice
  4. Business Logic: Service processes request, interacts with databases
  5. Response: Service returns data through gateway to client
  6. Caching: Frequently accessed data cached in Redis
  7. Logging: All requests logged for monitoring and debugging

Security Architecture

  • Authentication: JWT tokens with refresh mechanism
  • Authorization: Role-based access control (RBAC)
  • Encryption: TLS 1.3 for data in transit, AES-256 for data at rest
  • API Security: Rate limiting, input validation, SQL injection prevention
  • Network Security: VPC isolation, security groups, WAF

Scalability Considerations

  • Horizontal Scaling: Services can be scaled independently
  • Database Sharding: Data partitioned across multiple database instances
  • CDN Integration: Static content served from edge locations
  • Auto-scaling: Services scale based on CPU/memory usage
  • Read Replicas: Database read operations distributed across replicas

Deployment Architecture

  • CI/CD Pipeline: Automated testing and deployment
  • Blue-Green Deployment: Zero-downtime deployments
  • Feature Flags: Gradual feature rollout and rollback
  • Environment Isolation: Separate environments for dev/staging/prod

Monitoring and Observability

  • Metrics: Application performance, error rates, user activity
  • Logging: Structured logs with correlation IDs
  • Tracing: Distributed tracing for request flow
  • Alerting: Automated alerts for system issues
  • Dashboards: Real-time monitoring dashboards

Technology Stack

Frontend

  • React 18
  • TypeScript
  • Redux Toolkit
  • React Router
  • Axios

Backend

  • Node.js (Express/NestJS)
  • Python (FastAPI)
  • GraphQL/REST APIs
  • JWT Authentication

Database

  • PostgreSQL 15
  • Redis 7
  • Elasticsearch 8
  • Cloudflare R2 (Object Storage)

Infrastructure

  • Self-Hosted Linux (Hetzner / DigitalOcean / Bare Metal)
  • Docker & Docker Compose
  • PM2 Process Manager
  • Nginx Reverse Proxy

DevOps & Observability

  • GitHub Actions CI/CD
  • New Relic APM & Log Management
  • Sentry Exception Tracking

Future Considerations

  • Micro-frontend Architecture: Independent frontend applications
  • Event-Driven Architecture: Asynchronous communication between services
  • Multi-Cloud Deployment: Hybrid cloud strategy
  • AI/ML Integration: Machine learning for personalized learning
  • Blockchain: Credential verification and NFT certificates