# hongjungwan/ffmpeg-video-modules architecture

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

- Interactive diagram: https://gitdiagram.com/hongjungwan/ffmpeg-video-modules
- Repository: https://github.com/hongjungwan/ffmpeg-video-modules

## Overview

##### Main Components

a) External Interface Layer:
- HTTP Server (port 3031)
- Swagger Documentation Interface
- REST API Endpoints

b) Application Core:
- Controllers Layer
- Use Cases/Interactors Layer
- Domain Layer
- Repository Interfaces

c) Infrastructure Layer:
- FFmpeg Service
- MariaDB Database
- Repository Implementations
- Configuration Management

d) Supporting Components:
- File Storage System
- Docker Container
- Network Layer

##### Component Relationships

- Implement clean architecture patterns with clear dependency directions
- Clear separation between layers

##### Specific Elements

**[Client/External Requests]**
- ↓
**[API Layer]**
- Health Check
- Video Upload
- Video Processing
- Video Download
- ↓
**[Controllers]**
- FinalVideoController
- VideoController
- VideoJobController
- HealthCheckController
- ↓
**[Use Cases/Interactors]**
- Video Processing Logic
- Job Management
- ↓
**[Domain Layer]**
- Video
- VideoJob
- FinalVideo
- ↓
**[Repository Interface]**
- ↓
**[Infrastructure]**
- [FFmpeg Service]
- [MariaDB Database]
- [File Storage]

##### Additional Details

a) Data Flow Annotations:
- Video upload path
- Processing pipeline flow
- Download path
- Database interactions

b) Key Technical Components:
- FFmpeg integration points
- Database schema references
- File storage locations
- Configuration management

##### Architecture Patterns to Highlight

- Clean Architecture pattern
- Repository pattern for data access
- Dependency injection
- Service layer pattern
- REST API design

##### Implementation Notes

- Clear separation of concerns
- Dependency flow from outer layers inward
- Infrastructure independence
- Testing boundaries
- Error handling paths

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph External
        Client(["Client/External Requests"])
        Swagger["Swagger Documentation"]
        click Swagger "https://github.com/HongJungWan/ffmpeg-video-modules/blob/main/internal/docs/swagger.yaml"
    end

    subgraph API["API Layer"]
        Server["HTTP Server (3031)"]
        Router["Router"]
        click Server "https://github.com/HongJungWan/ffmpeg-video-modules/blob/main/cmd/server.go"
        click Router "https://github.com/HongJungWan/ffmpeg-video-modules/blob/main/internal/infrastructure/router/router.go"

        ReqDTO["Request DTOs"]
        ResDTO["Response DTOs"]
        click ReqDTO "https://github.com/HongJungWan/ffmpeg-video-modules/tree/main/internal/interfaces/dto/request/"
        click ResDTO "https://github.com/HongJungWan/ffmpeg-video-modules/tree/main/internal/interfaces/dto/response/"
    end

    subgraph Controllers["Controllers Layer"]
        FVC["FinalVideoController"]
        VC["VideoController"]
        VJC["VideoJobController"]
        HC["HealthCheckController"]
        click Controllers "https://github.com/HongJungWan/ffmpeg-video-modules/tree/main/internal/interfaces/controller/"
    end

    subgraph UseCases["Use Cases/Interactors"]
        VPL["Video Processing Logic"]
        JM["Job Management"]
        click UseCases "https://github.com/HongJungWan/ffmpeg-video-modules/tree/main/internal/usecases/"
    end

    subgraph Domain["Domain Layer"]
        Video["Video Entity"]
        VideoJob["VideoJob Entity"]
        FinalVideo["FinalVideo Entity"]
        RepInt["Repository Interfaces"]
        click Domain "https://github.com/HongJungWan/ffmpeg-video-modules/tree/main/internal/domain/"
        click RepInt "https://github.com/HongJungWan/ffmpeg-video-modules/tree/main/internal/domain/repository/"
    end

    subgraph Infrastructure["Infrastructure Layer"]
        FFmpeg["FFmpeg Service"]
        DB[(MariaDB Database)]
        Storage["File Storage"]
        Config["Configuration"]
        RepImpl["Repository Implementations"]
        DBSchema["Database Schema"]
        Docker["Docker Container"]
        click FFmpeg "https://github.com/HongJungWan/ffmpeg-video-modules/blob/main/internal/infrastructure/ffmpeg/ffmpeg.go"
        click Config "https://github.com/HongJungWan/ffmpeg-video-modules/tree/main/internal/infrastructure/configs/"
        click RepImpl "https://github.com/HongJungWan/ffmpeg-video-modules/tree/main/internal/infrastructure/repository/"
        click DBSchema "https://github.com/HongJungWan/ffmpeg-video-modules/blob/main/database/schema.sql"
        click Docker "https://github.com/HongJungWan/ffmpeg-video-modules/tree/main/deploy/dev/Dockerfile"
    end

    %% Relationships
    Client --> Server
    Client --> Swagger
    Server --> Router
    Router --> ReqDTO
    Router --> ResDTO
    ReqDTO --> Controllers
    Controllers --> ResDTO
    Controllers --> UseCases
    UseCases --> Domain
    Domain --> RepInt
    RepInt --> RepImpl
    RepImpl --> DB
    RepImpl --> Storage
    UseCases --> FFmpeg
    FFmpeg --> Storage
    Config --> DB
    Config --> FFmpeg
    Docker --> Server

    %% Styling
    classDef external fill:#f9f,stroke:#333,stroke-width:2px
    classDef api fill:#aef,stroke:#333,stroke-width:2px
    classDef controller fill:#dfd,stroke:#333,stroke-width:2px
    classDef usecase fill:#dfd,stroke:#333,stroke-width:2px
    classDef domain fill:#ffd,stroke:#333,stroke-width:2px
    classDef infra fill:#ffe,stroke:#333,stroke-width:2px

    class Client,Swagger external
    class Server,Router,ReqDTO,ResDTO api
    class FVC,VC,VJC,HC controller
    class VPL,JM usecase
    class Video,VideoJob,FinalVideo,RepInt domain
    class FFmpeg,DB,Storage,Config,RepImpl,DBSchema,Docker infra
```
