# dashotv/tower architecture

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

- Interactive diagram: https://gitdiagram.com/dashotv/tower
- Repository: https://github.com/dashotv/tower

## Overview

##### Main Components

a. Core Services Layer:
- Media Management Service (internal/app)
- Plex Integration Service (internal/plex)
- Import Service (internal/importer)
- Fanart Service (internal/fanart)

b. Worker System:
- Downloads Workers
- File Management Workers
- Plex Sync Workers
- Media Update Workers
- Index Management Workers

c. External Integrations:
- TMDB Client
- TVDB Client
- Plex Media Server
- NZBGet Integration
- Runic Integration
- Seer Integration
- Flame Integration

d. Data Storage:
- MongoDB (evident from models and database operations)
- File System Storage

##### Relationship Flows

- API Routes → Core Services
- Core Services ↔ Worker System
- Core Services ↔ External Integrations
- Workers → Data Storage
- Plex Integration ↔ Plex Media Server

##### Specific Implementation Details

- Blue rectangles: Core services
- Green rectangles: Workers
- Purple diamonds: External integrations
- Yellow rectangles: API routes

##### Key Architectural Patterns to Highlight

a. Event-Driven Architecture:
- Event flow between components (.golem/events/)
- Worker queue system

b. Modular Design:
- Separate internal packages
- Clear separation of concerns

##### Component Details

- Media management flows (movies, series, episodes)
- Download processing pipeline
- Plex synchronization mechanism
- File management system

##### Technical Stack Indicators

Technology labels:
- Go (main implementation language)
- MongoDB
- Plex API
- External APIs (TMDB, TVDB)

##### Additional Elements

Annotations for:
- Configuration management (.golem/config.yaml)
- API endpoints (.golem/routes/)
- Worker definitions (.golem/workers/)
- Model definitions (.golem/models/)

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles and Classes
    classDef core fill:#3498db,stroke:#2980b9,color:white
    classDef worker fill:#2ecc71,stroke:#27ae60,color:white
    classDef external fill:#9b59b6,stroke:#8e44ad,color:white
    classDef storage fill:#e67e22,stroke:#d35400,color:white
    classDef api fill:#f1c40f,stroke:#f39c12,color:black
    classDef model fill:#95a5a6,stroke:#7f8c8d,color:white

    %% Core Services Layer
    subgraph CoreServices
        MediaMgmt["Media Management Service"]:::core
        PlexInt["Plex Integration Service"]:::core
        ImportSvc["Import Service"]:::core
        FanartSvc["Fanart Service"]:::core
    end

    %% Worker System
    subgraph Workers
        DownloadW["Downloads Workers"]:::worker
        FileW["File Management Workers"]:::worker
        PlexW["Plex Sync Workers"]:::worker
        MediaW["Media Update Workers"]:::worker
        IndexW["Index Management Workers"]:::worker
    end

    %% External Integrations
    subgraph ExternalSystems
        TMDB["TMDB Client"]:::external
        TVDB["TVDB Client"]:::external
        PlexMS["Plex Media Server"]:::external
        NZBGet["NZBGet Integration"]:::external
        Runic["Runic Integration"]:::external
        Seer["Seer Integration"]:::external
        Flame["Flame Integration"]:::external
    end

    %% Data Storage
    subgraph Storage
        MongoDB[("MongoDB")]:::storage
        FileSystem[("File System")]:::storage
    end

    %% API Routes
    subgraph APIRoutes
        MoviesAPI["Movies API"]:::api
        SeriesAPI["Series API"]:::api
        DownloadsAPI["Downloads API"]:::api
        PlexAPI["Plex API"]:::api
        LibraryAPI["Library API"]:::api
    end

    %% Data Models
    subgraph Models
        MovieModel["Movie Models"]:::model
        SeriesModel["Series Models"]:::model
        EpisodeModel["Episode Models"]:::model
        DownloadModel["Download Models"]:::model
        LibraryModel["Library Models"]:::model
    end

    %% Relationships
    APIRoutes --> CoreServices
    CoreServices <--> Workers
    CoreServices <--> ExternalSystems
    Workers --> Storage
    PlexInt <--> PlexMS
    Models --> MongoDB

    %% Click Events
    click MediaMgmt "https://github.com/dashotv/tower/blob/main/internal/app/app.go"
    click PlexInt "https://github.com/dashotv/tower/tree/main/internal/plex/"
    click ImportSvc "https://github.com/dashotv/tower/tree/main/internal/importer/"
    click FanartSvc "https://github.com/dashotv/tower/tree/main/internal/fanart/"
    click DownloadW "https://github.com/dashotv/tower/blob/main/.golem/workers/downloads_*.yaml"
    click FileW "https://github.com/dashotv/tower/blob/main/.golem/workers/files_*.yaml"
    click PlexW "https://github.com/dashotv/tower/blob/main/.golem/workers/plex_*.yaml"
    click MediaW "https://github.com/dashotv/tower/blob/main/.golem/workers/movie_update.yaml"
    click IndexW "https://github.com/dashotv/tower/blob/main/.golem/workers/update_indexes.yaml"
    click TMDB "https://github.com/dashotv/tower/blob/main/internal/app/tmdb.go"
    click TVDB "https://github.com/dashotv/tower/blob/main/internal/app/tvdb.go"
    click NZBGet "https://github.com/dashotv/tower/blob/main/internal/app/workers_nzbget.go"
    click Runic "https://github.com/dashotv/tower/blob/main/internal/app/events_runic.go"
    click Seer "https://github.com/dashotv/tower/blob/main/internal/app/events_seer.go"
    click Flame "https://github.com/dashotv/tower/blob/main/internal/app/events_flame.go"
    click MovieModel "https://github.com/dashotv/tower/blob/main/.golem/models/movie.yaml"
    click SeriesModel "https://github.com/dashotv/tower/blob/main/.golem/models/series.yaml"
    click EpisodeModel "https://github.com/dashotv/tower/blob/main/.golem/models/episode.yaml"
    click DownloadModel "https://github.com/dashotv/tower/blob/main/.golem/models/download.yaml"
    click LibraryModel "https://github.com/dashotv/tower/blob/main/.golem/models/library.yaml"
    click MoviesAPI "https://github.com/dashotv/tower/blob/main/.golem/routes/movies.yaml"
    click SeriesAPI "https://github.com/dashotv/tower/blob/main/.golem/routes/series.yaml"
    click DownloadsAPI "https://github.com/dashotv/tower/blob/main/.golem/routes/downloads.yaml"
    click PlexAPI "https://github.com/dashotv/tower/blob/main/.golem/routes/plex.yaml"
    click LibraryAPI "https://github.com/dashotv/tower/blob/main/.golem/routes/library.yaml"
```
