# hantsaniala/hstream architecture

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

- Interactive diagram: https://gitdiagram.com/hantsaniala/hstream
- Repository: https://github.com/hantsaniala/hstream

## Overview

##### Main Components

A. Frontend Layer:
- Vue.js application (located in /ui directory)
- Components for video playback and management
- Router for navigation
- HTTP services for API communication

B. Backend Layer:
- Go server (main application)
- Video processing module (pkg/hStream)
- Key generation and encryption services (pkg/gen)
- Command-line interface (cmd directory)

C. Storage Layer:
- PostgreSQL database
- Redis cache
- File storage system (upload directory)
- Original video storage
- Media storage for processed videos

D. External Services:
- Docker containerization
- Environment configuration

**[Client Browser] → [Frontend (Vue.js)] → [Backend API Server]**
- ↓
- [File Storage] ← [Video Processing Engine] → [Redis Cache]
- ↓
- [PostgreSQL Database]

##### Component Details to Highlight

A. Frontend Components (Blue Section):
- Router and service layers
- Connection to backend API

B. Backend Services (Green Section):
- Main API server
- Video processing module (hStream)
- Encryption and key management
- Task management system

C. Storage Components (Yellow Section):
- Database connections
- Redis cache
- File system storage for videos
- Original video storage
- Processed media storage

##### Data Flow Indicators

- Video upload flow
- Processing pipeline
- Streaming delivery
- API communications
- Cache interactions
- Database operations

##### Security Layer (Red Border)
- Encryption boundaries
- Key management flow
- Access control points

##### Specific Implementation Details

Project-specific elements:
- Video encoding options (from pkg/hStream/encode_options.go)
- Task management system (from pkg/hStream/tasks.go)
- Controller layer (from pkg/hStream/controller.go)
- Database interactions (from pkg/hStream/db.go)

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Client
        Browser["Web Browser"]
    end

    subgraph Frontend
        VueApp["Vue.js Application"]:::frontend
        Router["Router"]:::frontend
        HTTPService["HTTP Services"]:::frontend
        VideoService["Video Service"]:::frontend
    end

    subgraph Backend
        APIServer["API Server"]:::backend
        VideoProcessor["Video Processing Engine"]:::backend
        TaskManager["Task Management"]:::backend
        EncryptionService["Encryption Service"]:::backend
        KeyManager["Key Management"]:::backend
        CLInterface["CLI Interface"]:::backend
        ServerEntry["Server Entry Point"]:::backend
        VideoController["Video Controller"]:::backend
        TaskServer["Task Server"]:::backend
        VideoUtils["Video Processing Utils"]:::backend
        EncodeOptions["Encoding Options"]:::backend
    end

    subgraph Storage
        PostgreSQL[(PostgreSQL)]:::storage
        Redis[(Redis Cache)]:::cache
        subgraph FileStorage
            OriginalVideos["Original Videos"]:::storage
            ProcessedMedia["Processed Media"]:::storage
        end
    end

    subgraph Infrastructure
        Docker["Docker Container"]:::infra
        DockerCompose["Container Orchestration"]:::infra
        EnvConfig["Environment Config"]:::infra
    end

    %% Connections
    Browser --> VueApp
    VueApp --> Router
    VueApp --> HTTPService
    HTTPService --> VideoService
    VideoService --> APIServer
    APIServer --> VideoProcessor
    VideoProcessor --> TaskManager
    VideoProcessor --> VideoController
    VideoProcessor --> TaskServer
    VideoProcessor --> VideoUtils
    VideoProcessor --> EncodeOptions
    TaskManager --> Redis
    VideoProcessor --> PostgreSQL
    VideoProcessor --> FileStorage
    EncryptionService --> KeyManager
    CLInterface --> ServerEntry

    %% Click Events
    click VueApp "https://github.com/hantsaniala/hStream/blob/develop/ui/src/App.vue"
    click Router "https://github.com/hantsaniala/hStream/blob/develop/ui/src/router/index.js"
    click HTTPService "https://github.com/hantsaniala/hStream/blob/develop/ui/src/services/http.js"
    click VideoService "https://github.com/hantsaniala/hStream/blob/develop/ui/src/services/video.js"
    click VideoProcessor "https://github.com/hantsaniala/hStream/blob/develop/pkg/hStream/hStream.go"
    click VideoController "https://github.com/hantsaniala/hStream/blob/develop/pkg/hStream/controller.go"
    click TaskManager "https://github.com/hantsaniala/hStream/blob/develop/pkg/hStream/tasks.go"
    click EncryptionService "https://github.com/hantsaniala/hStream/blob/develop/pkg/gen/enc.go"
    click KeyManager "https://github.com/hantsaniala/hStream/blob/develop/pkg/gen/key.go"
    click CLInterface "https://github.com/hantsaniala/hStream/blob/develop/cmd/root.go"
    click ServerEntry "https://github.com/hantsaniala/hStream/blob/develop/cmd/server.go"
    click OriginalVideos "https://github.com/hantsaniala/hStream/tree/develop/upload/original"
    click ProcessedMedia "https://github.com/hantsaniala/hStream/tree/develop/upload/media"
    click Docker "https://github.com/hantsaniala/hStream/tree/develop/Dockerfile"
    click DockerCompose "https://github.com/hantsaniala/hStream/blob/develop/docker-compose.yml"
    click EnvConfig "https://github.com/hantsaniala/hStream/blob/develop/.env.example"
    click EncodeOptions "https://github.com/hantsaniala/hStream/blob/develop/pkg/hStream/encode_options.go"
    click TaskServer "https://github.com/hantsaniala/hStream/blob/develop/pkg/hStream/tasksServer.go"
    click VideoUtils "https://github.com/hantsaniala/hStream/blob/develop/pkg/hStream/utils.go"

    %% Styles
    classDef frontend fill:#2196F3,color:white
    classDef backend fill:#4CAF50,color:white
    classDef storage fill:#FFC107,color:black
    classDef cache fill:#9C27B0,color:white
    classDef infra fill:#607D8B,color:white

    %% Legend
    subgraph Legend
        Frontend_L["Frontend Component"]:::frontend
        Backend_L["Backend Component"]:::backend
        Storage_L["Storage Component"]:::storage
        Cache_L["Cache Component"]:::cache
        Infra_L["Infrastructure"]:::infra
    end
```
