# pradhyuman-yadav/video-steaming architecture

> Architecture diagram of the GitHub repository pradhyuman-yadav/video-steaming, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-11). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/pradhyuman-yadav/video-steaming
- Repository: https://github.com/pradhyuman-yadav/video-steaming

## Overview

##### Project Type and Purpose
- This is a monolithic, full-stack web application built on Laravel (PHP) that powers an online learning/video-streaming platform. It provides:
- Admin dashboard (course/blog/user management)
- Public frontend (course catalog, blogs, forums, live classes)
- RESTful API endpoints (for mobile/SPA)
- CLI tooling (scheduled tasks, data migrations)
- Integrations with payment gateways and real-time services

##### Architectural Overview from File Structure
- Top-level “app” directory contains MVC backend:
- app/Http/Controllers → HTTP entry points
- app/Models → Eloquent ORM
- app/Services → external-integration (payments, Agora, Zoom)
- app/Console → scheduled/queue workers
- “public” hosts two frontends:
- public/admin → admin panel static assets & Blade views
- public/frontend → student/instructor/organization UI assets & views
- “routes” splits HTTP into domains: admin.php, api.php, frontend.php, instructor.php, organization.php, student.php
- “config” holds external-service credentials (DB, cache, mail, Zoom, BigBlueButton, payment gateways).
- Docker config under “docker/” and docker-compose.yml orchestrates containers: web (Nginx + PHP-FPM), DB, cache, queue workers.

##### Key Components
a. Clients
- Web browsers (Admin UI / Public UI)
- Mobile apps or SPAs consuming API endpoints
b. Edge/Load Balancer
- (Optional) AWS ELB or CDN → Routes traffic to Nginx
c. Web Server Layer
- Nginx container → forwards to PHP-FPM
d. Application Layer
- Laravel monolith (MVC + Service layer + Events)
- Queue Workers (php artisan queue:work)
- Scheduled Jobs (php artisan schedule:run)
e. Data Stores
- MySQL (or MariaDB) relational database
- Redis for cache, session store, queue backend
- File storage (local disk or AWS S3)
f. External Services
- Payment Gateways (Stripe, PayPal, etc.)
- Real-time/Video services: Agora RTC/RTM, Jitsi, Zoom, BigBlueButton
- Email SMTP or 3rd-party (Mailgun/SES)
- Optional: Google Calendar, Pusher for websockets

##### Relationships and Data Flows
- Client → Nginx → Laravel (Controllers)
- Controllers call Services & Models → read/write MySQL or Redis
- Controllers return rendered Blade views or JSON (API)
- Async tasks (email notifications, video processing) dispatched to queue → queue workers process and may talk back to Laravel, DB, Redis
- Events published (ChatEvent) → broadcasting via Pusher or websockets → clients receive updates
- Payment flows: Laravel PaymentService → external gateway API → webhook callback → Laravel updates order status
- Real-time class flows: Instructor/Student → Agora/Jitsi/Zoom SDK → backend generates tokens via app/Services/Agora or related classes

##### Architectural Patterns & Principles
- MVC: Separation of concerns between Models, Views (Blade), Controllers
- Service Layer: encapsulates third-party integrations (app/Services)
- Event-Driven: Laravel Events & Broadcasting for chat/live classes
- Queuing: decouple long-running tasks (emails, exports) via Redis queue
- Modular Routing: domain-specific route files
- Configuration-driven: all credentials and feature flags in config/*.php

##### Detail Recommendations
- Middleware for auth (Sanctum), rate limiting, localization.
- Event flow for chat/live classes: Controller dispatches ChatEvent → Broadcasting → subscribed clients.
- Queue flow: Controller dispatches Job → Redis Queues → Worker → triggers EmailSendService or PDF generation.
- Keep it high-level but ensure all major modules (admin, API, frontend) and integrations are visible.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Clients Layer
    subgraph "Clients" 
        direction TB
        AdminUI["Admin UI"]:::frontend
        PublicUI["Public UI"]:::frontend
        MobileApp["Mobile App / SPA"]:::frontend
    end

    %% Edge / Load Balancer
    ELB["AWS ELB / CDN"]:::edge

    %% Web Server Layer
    Nginx["Nginx"]:::app
    PHPFPM["PHP-FPM"]:::app

    %% Application Layer - Laravel Monolith
    subgraph "Laravel Application" 
        direction TB
        Router["Router"]:::app
        Controllers["Controllers"]:::app
        ServiceLayer["Service Layer"]:::app
        Models["Eloquent Models"]:::app
    end

    %% CLI Tools
    CLITools["CLI Tools (Console)"]:::app

    %% Queue Workers
    Worker["Queue Workers"]:::app

    %% Data Stores
    subgraph "Data Stores"
        direction TB
        MySQL["MySQL"]:::datastore
        Redis["Redis"]:::datastore
        Storage["File Storage (Local/S3)"]:::datastore
    end

    %% External Services
    subgraph "External Services"
        direction TB
        PaymentServices["Payment Gateways"]:::external
        RealTimeServices["Real-Time/Video Services"]:::external
        EmailService["Email SMTP/SES"]:::external
    end

    %% Connections
    AdminUI -->|HTTP/HTTPS| ELB
    PublicUI -->|HTTP/HTTPS| ELB
    MobileApp -->|HTTP/HTTPS| ELB

    ELB -->|HTTP/HTTPS| Nginx
    Nginx -->|FastCGI| PHPFPM

    PHPFPM -->|invoke| Router
    Router -->|dispatch| Controllers
    Controllers -->|use| ServiceLayer
    Controllers -->|read/write| Models
    Controllers -->|enqueue Job| Redis
    Controllers -->|dispatch Event| Redis

    ServiceLayer -->|SQL queries| MySQL
    Models -->|SQL queries| MySQL
    Models -->|cache| Redis

    Controllers -->|return Blade views| AdminUI
    Controllers -->|return Blade views| PublicUI
    Controllers -->|return JSON| MobileApp

    Controllers -->|invoke CLI| CLITools
    CLITools -->|schedule/run| Worker
    Worker -->|process| Redis
    Worker -->|use| ServiceLayer

    Controllers -->|upload/retrieve| Storage

    Controllers -->|call| PaymentServices
    PaymentServices -->|webhook callback| Controllers

    Controllers -->|call| RealTimeServices
    RealTimeServices -->|token generation| Controllers

    Controllers -->|send mail| EmailService

    %% Click Events
    click AdminUI "https://github.com/pradhyuman-yadav/video-steaming/tree/main/public/admin"
    click PublicUI "https://github.com/pradhyuman-yadav/video-steaming/tree/main/public/frontend"
    click MobileApp "https://github.com/pradhyuman-yadav/video-steaming/tree/main/app/Http/Controllers/Api"
    click CLITools "https://github.com/pradhyuman-yadav/video-steaming/tree/main/app/Console"
    click PaymentServices "https://github.com/pradhyuman-yadav/video-steaming/tree/main/app/Http/Services/Payment"
    click RealTimeServices "https://github.com/pradhyuman-yadav/video-steaming/tree/main/app/Http/Services/Agora"
    click Controllers "https://github.com/pradhyuman-yadav/video-steaming/tree/main/app/Http/Controllers"
    click ServiceLayer "https://github.com/pradhyuman-yadav/video-steaming/tree/main/app/Http/Services/Payment"
    click Models "https://github.com/pradhyuman-yadav/video-steaming/tree/main/app/Models"
    click MySQL "https://github.com/pradhyuman-yadav/video-steaming/blob/main/config/database.php"
    click Redis "https://github.com/pradhyuman-yadav/video-steaming/blob/main/config/queue.php"
    click Storage "https://github.com/pradhyuman-yadav/video-steaming/blob/main/config/filesystems.php"
    click Nginx "https://github.com/pradhyuman-yadav/video-steaming/tree/main/docker/nginx"
    click PHPFPM "https://github.com/pradhyuman-yadav/video-steaming/tree/main/docker/php"
    click EmailService "https://github.com/pradhyuman-yadav/video-steaming/blob/main/app/Http/Services/EmailSendService.php"

    %% Styles
    classDef frontend fill:#d4f1be,stroke:#3a7d44,color:#000
    classDef app fill:#a0c4ff,stroke:#1f3c88,color:#000
    classDef datastore fill:#ffd6a5,stroke:#bb5500,color:#000
    classDef external fill:#e0e0e0,stroke:#555,color:#000
    classDef edge fill:#cddc39,stroke:#7a9e1e,color:#000
```
