# balajiragunathan/jiohotstar-architecture architecture

> Architecture diagram of the GitHub repository balajiragunathan/jiohotstar-architecture, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-02). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/balajiragunathan/jiohotstar-architecture
- Repository: https://github.com/balajiragunathan/jiohotstar-architecture

## Overview

##### Project Context and Type
- JioHotstar is a high-performance video streaming platform with a focus on scalable, resilient, and secure streaming of movies, live sports, and TV shows.
- The design supports millions of concurrent users, multiple device types, live streaming, personalized recommendations, and a subscription/payment system.
- It is clearly a full-stack, distributed system combining user management, content management, video streaming infrastructure, analytics, and more.

##### Main Architectural Components
- User Devices: Represent different access points (mobile, web, smart TVs).
- Load Balancer / API Gateway: A central entry point distributing traffic to the web servers.
- Web Servers / APIs: Backend servers handling user requests (using technologies like Node.js or Spring Boot).
- User Management: Encapsulate authentication/authorization (OAuth 2.0, JWT), session management, and profile storage (MongoDB, MySQL).
- Content Management:
- Video Storage (like AWS S3 or Google Cloud Storage)
- Video Metadata in databases (MongoDB, PostgreSQL)
- Content Ingestion & Transcoding pipelines (using FFmpeg).
- Video Streaming Infrastructure:
- Streaming Servers that encode/stream content using adaptive bitrate methods (HLS/DASH).
- Dedicated services for transcoding.
- Content Delivery Network (CDN): A global CDN (AWS CloudFront, Akamai) for edge caching.
- Search and Discovery:
- Search Service using Elasticsearch.
- Personalized recommendation engine (with TensorFlow, Scikit-learn) and trending analytics.
- Subscription and Payment System:
- Tiered subscription modules, payment gateway integrations (Stripe, Razorpay), and content access control.
- Live Streaming Infrastructure:
- Services using WebRTC/RTMP to enable low-latency streaming.
- Real-time processing components that integrate event data.
- Analytics and Data Processing:
- Real-time analytics components like Apache Kafka, Flink.
- BI or dashboard tools (Tableau, Power BI) and data warehouses (Amazon Redshift, BigQuery).
- Monitoring and Logging:
- Centralized logging (ELK/Splunk) and monitoring (Prometheus, Grafana).

##### Relationships and Data Flows
- They communicate with the user management module for authentication and session management.
- They interface with the content management system where video files are ingested, transcoded, and stored.
- They connect to the streaming servers/CDN which deliver video content to end users.
- Data flows from analytics components and monitoring/logging systems back into the centralized control and decision systems.

##### Architectural Patterns and Design Principles
- Horizontal scaling at the web servers, streaming servers, and database layers.
- Fault tolerance using redundant components (e.g., database replication, CDN redundancy).
- Caching layers using Redis where applicable (user session caching, popular content caches).
- Mechanisms for auto-scaling based on traffic pattern observations.
- Make clear the separation of concerns: distinct components for user domain, content handling, streaming, analytics, and monitoring.

##### Technology Labels and Notations
- Component with its key tech stack (for example, note “Node.js/Spring Boot” on the API servers, “MongoDB/MySQL” on user management, or “AWS S3/Google Cloud Storage” on video storage).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Project Artifact
    Doc("Project Documentation"):::doc

    %% Frontend Layer
    subgraph "Frontend Layer"
        UD1("User Devices (Mobile, Web, Smart TVs)"):::frontend
    end

    %% Application Layer
    subgraph "Application Layer"
        LB("Load Balancer / API Gateway<br>(Distributes Traffic)"):::gateway
        API("Web Servers / APIs<br>(Node.js/Spring Boot)"):::app
    end

    %% User Management
    subgraph "User Management"
        UM("User Management<br>(OAuth2, JWT,<br>MongoDB/MySQL)"):::user
    end

    %% Content Management
    subgraph "Content Management"
        VS("Video Storage<br>(AWS S3/Google Cloud Storage)"):::storage
        VM("Video Metadata<br>(MongoDB/PostgreSQL)"):::db
        CI("Content Ingestion & Transcoding<br>(FFmpeg)"):::transcoder
    end

    %% Video Streaming Infrastructure
    subgraph "Video Streaming Infrastructure"
        SS("Streaming Servers<br>(HLS/DASH)"):::streaming
        TS("Transcoding Service"):::transcoder
        LIVE("Live Streaming<br>(WebRTC/RTMP)"):::live
    end

    %% Delivery & CDN
    subgraph "Delivery & CDN"
        CDN("Content Delivery Network<br>(Edge Caching)"):::cdn
    end

    %% Search & Discovery
    subgraph "Search & Discovery"
        SSrv("Search Service<br>(Elasticsearch)"):::search
        RE("Recommendation Engine<br>(TensorFlow, Scikit-learn)"):::recommend
    end

    %% Subscription & Payment
    subgraph "Subscription & Payment"
        SP("Subscription & Payment System<br>(Stripe, Razorpay)"):::payment
    end

    %% Analytics & Data Processing
    subgraph "Analytics & Data Processing"
        AN("Real-time Analytics<br>(Kafka, Flink)"):::analytics
        BI("BI/Dashboard Tools<br>(Tableau, Power BI)"):::analytics
    end

    %% Monitoring & Logging
    subgraph "Monitoring & Logging"
        ML("Monitoring & Logging<br>(Prometheus, Grafana,<br>ELK/Splunk)"):::monitoring
    end

    %% Data Flows
    Doc -->|"provides context"| UD1

    UD1 -->|"HTTP/API Calls"| LB
    LB -->|"Traffic Distribution"| API

    API -->|"Auth&Session"| UM
    API -->|"Content Request"| CI
    API -->|"Stream Request"| SS
    API -->|"Payment Auth"| SP
    API -->|"Search Query"| SSrv
    API -->|"Recommendations"| RE
    API -->|"Analytics Data"| AN
    API -->|"Logging"| ML

    CI -->|"Store Video"| VS
    CI -->|"Insert Metadata"| VM
    CI -->|"Trigger Transcoding"| TS

    SS -->|"Video Stream"| CDN
    LIVE -->|"Live Data"| CDN

    CDN -->|"Delivered Content"| UD1

    AN -->|"BI Dashboard"| BI
    UM -->|"Subscription Info"| SP

    %% Class Definitions for Styling
    classDef frontend fill:#b3e5fc,stroke:#0288d1,stroke-width:2px;
    classDef gateway fill:#a5d6a7,stroke:#2e7d32,stroke-width:2px;
    classDef app fill:#dcedc8,stroke:#7cb342,stroke-width:2px;
    classDef user fill:#fff9c4,stroke:#fbc02d,stroke-width:2px;
    classDef storage fill:#ffe0b2,stroke:#fb8c00,stroke-width:2px;
    classDef db fill:#ffccbc,stroke:#d84315,stroke-width:2px;
    classDef transcoder fill:#d1c4e9,stroke:#7e57c2,stroke-width:2px;
    classDef streaming fill:#e1bee7,stroke:#8e24aa,stroke-width:2px;
    classDef live fill:#f0f4c3,stroke:#9e9d24,stroke-width:2px;
    classDef cdn fill:#ffcdd2,stroke:#e53935,stroke-width:2px;
    classDef search fill:#c8e6c9,stroke:#43a047,stroke-width:2px;
    classDef recommend fill:#f8bbd0,stroke:#d81b60,stroke-width:2px;
    classDef payment fill:#d7ccc8,stroke:#8d6e63,stroke-width:2px;
    classDef analytics fill:#c5e1a5,stroke:#7cb342,stroke-width:2px;
    classDef monitoring fill:#b0bec5,stroke:#546e7a,stroke-width:2px;
    classDef doc fill:#ef9a9a,stroke:#c62828,stroke-width:2px;

    %% Click Events
    click Doc "https://github.com/balajiragunathan/jiohotstar-architecture/blob/main/README.md"
```
