# haveagitgat/tdarr architecture

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

- Interactive diagram: https://gitdiagram.com/haveagitgat/tdarr
- Repository: https://github.com/haveagitgat/tdarr

## Overview

##### Project Type & Purpose
- Tdarr V2 is a full-stack, distributed media processing application. It is entirely focused on automating the process of transcoding and remuxing media files using both community and locally developed plugins.
- The README outlines that there are two key processes: Tdarr_Server (the central coordinator) and Tdarr_Node (the worker that actually processes media files). It also highlights integration with transcoding tools like FFmpeg and HandBrake and emphasizes modularity (via plugin stacks).

##### Analyzing the File Structure
- Top-Level Directories: Notice directories like “docker” (for container definitions and setup), “updater”, and configuration files such as “package.json”. The presence of a .github directory indicates automated builds, CI configuration, and issue templates.
- The docker folder contains multiple Dockerfiles and setup scripts (e.g., in docker/root/etc) which indicate that Docker containers are used to deploy the different components (server and nodes).
- There are clear separation of responsibilities—with updater scripts and container definitions—suggesting that the system is modular with specific subsystems for different functions, including orchestration and plugin management.

##### Key Components to Capture
a. Tdarr_Server:
- Central process that all nodes communicate with.
- Responsible for scheduling, task distribution, configuration, library management, job reports, plugin stack management, and user interface (via the click-to-run web app).
b. Tdarr_Node:
- Worker processes that run on the same or different devices.
- They connect to the Tdarr_Server to fetch transcoding or health-check tasks.
- Different types of workers are mentioned (CPU/GPU for transcode and health check).
c. Media Transcoding Engines:
- External tools like FFmpeg and HandBrake which are integrated within nodes.
- These tool integrations should be represented as part of the nodes’ process pipeline.
d. Docker & Deployment:
- Docker configurations indicate that each component can be deployed in containers.
- Docker environment, the Dockerfile build process, and any orchestration that might be implied.
e. Plugin System:
- Plugin stack mechanism that dynamically determines actions based on conditional rules.
f. External Integrations:
- Potential integrations with applications like Sonarr/Radarr for media management.

##### Relationships & Data Flow
- From the Tdarr_Server to Tdarr_Node, indicating task assignment and health monitoring.
- From media files and library input (imagine a media library source) into the Tdarr_Server.
- From the nodes to external transcoding engines (FFmpeg/HandBrake) to show the actual processing.
- Between the plugin layer and the media pipelines (indicate conditional decision making for executing plugin actions such as transcoding, remuxing, and metadata adjustments).
- That the Server gets results back from the Nodes (job reports, stats, worker verdict history).

##### Architectural Patterns & Design Principles
- Modularity: Emphasize the separation between the central server and worker nodes. The plugin architecture also reinforces modularity by allowing new filters and actions.
- Scalability & Parallel Processing: With Nodes that can be spun up or down, highlight the load balancing and scheduling mechanism, enabling scalability.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% User/Media Library
    ML["Media Library"]:::external

    %% Central Control Components
    subgraph "Central Control"
        TS["Tdarr Server"]:::service
        UI["Web UI"]:::service
        Plugin["Plugin Manager"]:::plugin
    end

    %% Worker Nodes Components
    subgraph "Worker Nodes"
        TN["Tdarr Node"]:::service
        FFmpeg["FFmpeg Engine"]:::engine
        HandBrake["HandBrake Engine"]:::engine
    end

    %% Docker & Deployment
    subgraph "Docker & Deployment"
        Docker["Docker Environment"]:::docker
        Updater["Updater Service"]:::updater
    end

    %% Data and Control Flows
    ML -->|"mediaInput"| TS
    TS -->|"taskAssign"| TN
    TN -->|"jobReport"| TS
    TN -->|"transcodeUsing"| FFmpeg
    TN -->|"transcodeUsing"| HandBrake
    TS -->|"pluginDecision"| Plugin
    Plugin -->|"instructs"| TN
    Docker -->|"deploys"| TS
    Docker -->|"deploys"| TN
    Docker -->|"deploys"| Updater

    %% Click Events
    click TS "https://github.com/haveagitgat/tdarr/tree/master/docker/root/etc/services.d/tdarr_server/run"
    click TN "https://github.com/haveagitgat/tdarr/tree/master/docker/root/etc/services.d/tdarr_node/run"
    click Docker "https://github.com/haveagitgat/tdarr/tree/master/docker/"
    click Updater "https://github.com/haveagitgat/tdarr/blob/master/updater/README.md"

    %% Styles
    classDef service fill:#bbf,stroke:#333,stroke-width:2px;
    classDef external fill:#eef,stroke:#333,stroke-width:2px;
    classDef engine fill:#cfc,stroke:#333,stroke-width:2px;
    classDef docker fill:#fcf,stroke:#333,stroke-width:2px;
    classDef updater fill:#ffc,stroke:#333,stroke-width:2px;
    classDef plugin fill:#f9c,stroke:#333,stroke-width:2px;
```
