# madhusudan785/snapstream architecture

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

- Interactive diagram: https://gitdiagram.com/madhusudan785/snapstream
- Repository: https://github.com/madhusudan785/snapstream

## Overview

##### Main Components

A. Client-Side (Android App):
- Presentation Layer:
- Activities (MainActivity, VideoList, VideoPlayer)
- XML Layouts
- Adapters for RecyclerView

- Business Logic Layer:
- ViewModel (VideoListViewModel)
- Repository Pattern (VideoListRepository)
- Data Models (VideoData)

- Network Layer:
- Retrofit API Interface (MyApi)
- Upload Handlers (UploadRequestBody, UploadResponse)

B. Server-Side (Spring Boot):
- API Layer:
- REST Controllers (VideoController)
- Exception Handlers

- Service Layer:
- Video Service Interface and Implementation
- FFmpeg Processing Service

- Data Layer:
- Entities (Video, VideoStatus)
- Repositories (VideoRepo)
- MySQL Database

C. External Services:
- FFmpeg for video processing
- File Storage System
- Docker Container

**[Client Layer]**
- ↑↓
**[Network/API Layer]**
- ↑↓
**[Server Layer]**
- ↑↓
**[Storage Layer]**

##### Key Relationships to Highlight

a. Data Flow:
- Video Upload Path:
Client → API → Video Service → FFmpeg Processing → Storage
- Video Streaming Path:
Storage → Video Service → API → Client

b. Component Interactions:
- Android ViewModel ↔ Repository ↔ Retrofit API Client
- Spring Controller ↔ Service ↔ Repository ↔ Database
- FFmpeg Integration Points

##### Implementation Details

a. Client-Side:
- MVVM Architecture pattern
- Retrofit + Gson implementation
- Video player implementation
- Upload progress tracking

b. Server-Side:
- Spring Boot components
- Exception handling flow
- HLS video processing pipeline
- Thumbnail generation process

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles
    classDef frontend fill:#b3d9ff,stroke:#333,stroke-width:2px
    classDef backend fill:#90EE90,stroke:#333,stroke-width:2px
    classDef database fill:#f5f5f5,stroke:#333,stroke-width:2px
    classDef external fill:#FFE5B4,stroke:#333,stroke-width:2px
    classDef api fill:#FF9999,stroke:#333,stroke-width:2px

    %% Client Layer
    subgraph AndroidApp["Android Application"]
        Activities["Activities"]
        MainActivity["MainActivity"]
        VideoList["VideoList"]
        VideoPlayer["VideoPlayer"]
        
        BusinessLogic["Business Logic"]
        ViewModel["VideoListViewModel"]
        Repository["VideoListRepository"]
        DataModel["VideoData"]
        
        NetworkLayer["Network Layer"]
        ApiInterface["MyApi"]
        UploadHandlers["Upload Handlers"]
        
        Activities --> BusinessLogic
        BusinessLogic --> NetworkLayer
    end
    
    %% Server Layer
    subgraph SpringBoot["Spring Boot Backend"]
        ApiLayer["API Layer"]
        Controller["VideoController"]
        ExceptionHandler["Exception Handler"]
        
        ServiceLayer["Service Layer"]
        VideoService["Video Service"]
        FFmpegService["FFmpeg Service"]
        
        DataLayer["Data Layer"]
        Entities["Video Entities"]
        VideoRepo["Video Repository"]
    end
    
    %% External Services
    subgraph External["External Services"]
        FFmpeg["FFmpeg"]
        Storage["File Storage"]
        Docker["Docker Container"]
    end
    
    %% Database
    Database[(MySQL Database)]
    
    %% Relationships
    NetworkLayer --> ApiLayer
    ApiLayer --> ServiceLayer
    ServiceLayer --> DataLayer
    DataLayer --> Database
    ServiceLayer --> FFmpeg
    ServiceLayer --> Storage
    
    %% Click Events
    click MainActivity "https://github.com/madhusudan785/SnapStream/blob/master/VideoPlay/app/src/main/java/com/example/videoplay/MainActivity.kt"
    click VideoList "https://github.com/madhusudan785/SnapStream/blob/master/VideoPlay/app/src/main/java/com/example/videoplay/VideoList.kt"
    click VideoPlayer "https://github.com/madhusudan785/SnapStream/blob/master/VideoPlay/app/src/main/java/com/example/videoplay/VideoPlayer/VideoPlayer.kt"
    click ViewModel "https://github.com/madhusudan785/SnapStream/blob/master/VideoPlay/app/src/main/java/com/example/videoplay/ViewModel/VideoListViewModel.kt"
    click Repository "https://github.com/madhusudan785/SnapStream/blob/master/VideoPlay/app/src/main/java/com/example/videoplay/repo/VideoListRepository.kt"
    click DataModel "https://github.com/madhusudan785/SnapStream/blob/master/VideoPlay/app/src/main/java/com/example/videoplay/data/VideoData.kt"
    click ApiInterface "https://github.com/madhusudan785/SnapStream/blob/master/VideoPlay/app/src/main/java/com/example/videoplay/Api/MyApi.kt"
    click UploadHandlers "https://github.com/madhusudan785/SnapStream/tree/master/VideoPlay/app/src/main/java/com/example/videoplay/Api"
    click Controller "https://github.com/madhusudan785/SnapStream/blob/master/VideoStreaming-main/src/main/java/com/videoplayback/videoStream/controller/VideoController.java"
    click ExceptionHandler "https://github.com/madhusudan785/SnapStream/blob/master/VideoStreaming-main/src/main/java/com/videoplayback/videoStream/exception/VideoExceptionHandler.java"
    click VideoService "https://github.com/madhusudan785/SnapStream/blob/master/VideoStreaming-main/src/main/java/com/videoplayback/videoStream/Service/VideoService.java"
    click Entities "https://github.com/madhusudan785/SnapStream/tree/master/VideoStreaming-main/src/main/java/com/videoplayback/videoStream/Entity"
    click VideoRepo "https://github.com/madhusudan785/SnapStream/blob/master/VideoStreaming-main/src/main/java/com/videoplayback/videoStream/Reposetory/VideoRepo.java"
    click Docker "https://github.com/madhusudan785/SnapStream/tree/master/VideoStreaming-main/Dockerfile"
    
    %% Apply Classes
    class AndroidApp,Activities,MainActivity,VideoList,VideoPlayer,BusinessLogic,ViewModel,Repository,DataModel,NetworkLayer,ApiInterface,UploadHandlers frontend
    class SpringBoot,ApiLayer,Controller,ExceptionHandler,ServiceLayer,VideoService,FFmpegService,DataLayer,Entities,VideoRepo backend
    class Database database
    class FFmpeg,Storage,Docker external
    class ApiLayer,NetworkLayer api
```
