# deepeye/mediacms architecture

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

- Interactive diagram: https://gitdiagram.com/deepeye/mediacms
- Repository: https://github.com/deepeye/mediacms

## Overview

##### Main Components Identification

The system should be divided into these major components:

a) Frontend Layer:
- React-based SPA (/frontend directory)
- Video.js-based custom player (/frontend/packages/player)
- Theme management system
- Multiple page templates

b) Backend Layer:
- Django REST API
- Authentication/Authorization system
- Media processing pipeline
- Storage management

c) Processing Layer:
- Celery workers for async tasks
- Media transcoding system (FFMPEG)
- HLS streaming support

d) Storage Layer:
- PostgreSQL database
- Redis cache
- File storage system

##### Component Relationships

a) Client-Server Flow:
**Browser -> Nginx -> uWSGI -> Django -> API Endpoints**

b) Media Processing Flow:
**Upload -> Django -> Celery Queue -> Workers -> Storage**

c) Streaming Flow:
**Client Request -> Nginx -> HLS/Media Files -> Client Player**

##### Detailed Component Breakdown

Create sections for:

a) Frontend Architecture:
- React components hierarchy
- Theme system
- Routing system
- Player integration

b) Backend Services:
- API endpoints structure
- Authentication flow
- Media processing pipeline
- Task queue system

##### Specific Implementation Details

Key technical elements:

a) Authentication:
- User management system
- Permission layers
- Token-based API access

b) Media Processing:
- Multiple transcoding profiles
- Subtitle/CC support
- Thumbnail generation
- HLS streaming preparation

c) Storage Management:
- File organization
- Caching strategy
- Database schema

##### Key Integration Points

Crucial connections:

- API endpoints with frontend components
- Media processing workflow
- Storage interaction patterns
- Caching strategy
- Authentication flow

##### Deployment Architecture

Containerization strategy:
- Docker containers structure
- Service dependencies
- Network configuration
- Volume management

##### The security implementation

- Line styles
- Component types
- Flow directions
- Integration points

This will create a comprehensive visualization of MediaCMS's architecture while maintaining clarity and providing valuable technical insight.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client
        Browser["Browser/Client"]
    end

    subgraph "Frontend Layer"
        SPA["React SPA"]:::frontend
        Player["Video.js Player"]:::frontend
        Themes["Theme System"]:::frontend
        Templates["Page Templates"]:::frontend
        Components["React Components"]:::frontend
        Routes["Frontend Routes"]:::frontend
    end

    subgraph "Web Server"
        Nginx["Nginx Server"]:::server
        uWSGI["uWSGI Server"]:::server
    end

    subgraph "Backend Layer"
        Django["Django Application"]:::backend
        Auth["Authentication System"]:::backend
        API["REST API"]:::backend
        Upload["Upload Handler"]:::backend
        MediaModels["Media Models"]:::backend
        UserMgmt["User Management"]:::backend
        Actions["Media Actions"]:::backend
    end

    subgraph "Processing Layer"
        Celery["Celery Workers"]:::processing
        FFMPEG["FFMPEG Transcoder"]:::processing
        Pipeline["Processing Pipeline"]:::processing
    end

    subgraph "Storage Layer"
        Postgres[(PostgreSQL)]:::storage
        Redis[(Redis Cache)]:::storage
        FileSystem["File Storage"]:::storage
    end

    %% Client Flow
    Browser --> Nginx
    Nginx --> uWSGI
    uWSGI --> Django

    %% Frontend Connections
    SPA --> Player
    SPA --> Themes
    SPA --> Templates
    SPA --> Components
    SPA --> Routes

    %% Backend Connections
    Django --> Auth
    Django --> API
    Django --> Upload
    Django --> MediaModels
    Django --> UserMgmt
    Django --> Actions

    %% Processing Flow
    Upload --> Pipeline
    Pipeline --> Celery
    Celery --> FFMPEG
    FFMPEG --> FileSystem

    %% Storage Connections
    Django --> Postgres
    Django --> Redis
    Django --> FileSystem

    %% Click Events
    click SPA "https://github.com/deepeye/mediacms/tree/main/frontend/src/static/js/"
    click Player "https://github.com/deepeye/mediacms/tree/main/frontend/packages/player/"
    click Themes "https://github.com/deepeye/mediacms/tree/main/frontend/src/static/css/config/"
    click Templates "https://github.com/deepeye/mediacms/tree/main/frontend/src/templates/"
    click API "https://github.com/deepeye/mediacms/tree/main/cms/"
    click Auth "https://github.com/deepeye/mediacms/tree/main/users/"
    click Pipeline "https://github.com/deepeye/mediacms/blob/main/files/tasks.py"
    click FileSystem "https://github.com/deepeye/mediacms/blob/main/files/backends.py"
    click Celery "https://github.com/deepeye/mediacms/blob/main/cms/celery.py"
    click Upload "https://github.com/deepeye/mediacms/tree/main/uploader/"
    click Routes "https://github.com/deepeye/mediacms/tree/main/frontend/src/static/js/pages/"
    click API "https://github.com/deepeye/mediacms/blob/main/cms/urls.py"
    click MediaModels "https://github.com/deepeye/mediacms/blob/main/files/models.py"
    click UserMgmt "https://github.com/deepeye/mediacms/blob/main/users/models.py"
    click Components "https://github.com/deepeye/mediacms/tree/main/frontend/src/static/js/components/"
    click Actions "https://github.com/deepeye/mediacms/tree/main/actions/"

    %% Styles
    classDef frontend fill:#3498db,stroke:#2980b9,color:#fff
    classDef backend fill:#2ecc71,stroke:#27ae60,color:#fff
    classDef processing fill:#e67e22,stroke:#d35400,color:#fff
    classDef storage fill:#95a5a6,stroke:#7f8c8d,color:#fff
    classDef server fill:#9b59b6,stroke:#8e44ad,color:#fff

    %% Legend
    subgraph Legend
        Frontend["Frontend Component"]:::frontend
        Backend["Backend Service"]:::backend
        Process["Processing System"]:::processing
        Store["Storage System"]:::storage
        ServerComp["Server Component"]:::server
    end
```
