# carlreid/streammaster architecture

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

- Interactive diagram: https://gitdiagram.com/carlreid/streammaster
- Repository: https://github.com/carlreid/streammaster

## Overview

##### Major system components
- Frontend (StreamMaster.WebUI): Built with React and TypeScript. This layer includes all the UI components, state management (Redux), hooks, and routing logic. It communicates with backend APIs (HTTP/REST) and uses SignalR for real-time notifications.
- API & Application Layer (e.g., StreamMaster.API, StreamMaster.Application): The entry point for client requests. It hosts controllers (for channels, EPG, schedules, settings, etc.) along with business logic and orchestration services.
- Domain Layer (StreamMaster.Domain): Contains the core business models, DTOs, enumerations, events, and shared utilities. This layer is central to defining the data and behaviors of the IPTV service.
- Infrastructure Layer (StreamMaster.Infrastructure, EF projects): Manages data access (repositories, EF migrations, PostgreSQL integration), external API integrations, caching, authentication, logging and other cross-cutting concerns.
- Additional Modules: There are specialized components such as:
- BuildClientAPI: Tools to generate client code for API integrations.
- EPG and SchedulesDirect modules: For managing electronic program guide (EPG) data and schedule synchronization.
- Streams and PlayList domains: Focusing on handling live streams and media playlist generation.
- WebSocket and SignalR components: For real-time messaging and proxying updates.
- External Services: Integration with public IPTV resources (via iptv-org list, tv-logos repositories) and potential media server integrations (Plex, Emby, Jellyfin).

##### Relationships and interactions between these components
- The Frontend sends HTTP (and web socket/SignalR) requests to the API layer.
- The API layer (controllers) calls into the Application layer to execute business operations.
- The Application layer, orchestrating use cases, manipulates domain objects from the Domain layer.
- The Domain layer encapsulates core business rules, and the Infrastructure layer provides persistence (via repository patterns) and additional services such as logging, caching, and authentication.
- Docker and container orchestration files (e.g., docker-compose.yml, Dockerfiles) indicate that the deployment is containerized, so include a container boundary around the complete system.

##### Architectural patterns and relevant technologies
- Layered (n-tier) architecture: Separate the UI, API/controllers, application logic, domain, and infrastructure.
- Domain Driven Design: Central Domain models with supporting Application Services.
- Use of modern web technologies: React/Redux for the front end and .NET (with C#) for backend services.
- SignalR is used for real-time communications.
- Entity Framework (EF) with PostgreSQL migrations in the Infrastructure layer.
- Docker containerization for consistent deployments.

##### Elements
- Clearly labeled components for:
- User / Client interface (browsers/mobile)
- Frontend (StreamMaster.WebUI with subcomponents for routing, state management, UI elements)
- API/Backend layer (StreamMaster.API controllers, endpoints for authentication, channel management, EPG management, etc.)
- Application/Service layer (StreamMaster.Application) handling orchestration and business logic
- Core Domain (StreamMaster.Domain) where the business entities and models reside
- Infrastructure (EF repositories, logging services, authentication, caching, and services for external integrations)
- Specialized modules (EPG, SchedulesDirect, Streams, PlayList)

## Diagram (Mermaid)

```mermaid
flowchart TD
    U["User/Client"]:::client

    subgraph "Docker Container"
        subgraph "Frontend Layer"
            FW["StreamMaster.WebUI"]:::frontend
            SR["SignalR Integration"]:::frontend
        end
        subgraph "API & Application Layer"
            API["StreamMaster.API"]:::api
            APP["StreamMaster.Application"]:::application
            WS["WebSocket Integration"]:::application
            EPGC["EPG Controllers"]:::application
            EPGCMD["EPG Commands"]:::application
        end
        subgraph "Domain Layer"
            DOM["StreamMaster.Domain"]:::domain
            EPGCORE["EPG Core"]:::domain
            STREAMSDOM["Streams Domain"]:::domain
            SDDOM["SchedulesDirect Domain"]:::domain
            SDSM["SchedulesDirect Main"]:::domain
        end
        subgraph "Infrastructure & Modules"
            INFRA["Infrastructure Services"]:::infrastructure
            BCLIENT["BuildClientAPI"]:::module
            STREAMSSVC["Streams Services"]:::module
            PLAYLIST["PlayList Module"]:::module
            SDSVC["SchedulesDirect Services"]:::module
            EXT["External Integrations"]:::infrastructure
        end
    end

    U -->|"HTTP/HTTPS"| FW
    FW -->|"RESTAPIcall"| API
    FW -->|"RealTimeSignalR"| SR
    API -->|"InvokeLogic"| APP
    APP -->|"DomainOps"| DOM
    APP -->|"SignalRWebSocket"| WS
    APP -->|"ManageEPG"| EPGC
    APP -->|"EPGOperations"| EPGCMD
    APP -->|"StreamProcessing"| STREAMSSVC
    APP -->|"ScheduleSync"| SDSVC
    APP -->|"ScheduleData"| SDSM
    DOM -->|"DataPersistence"| INFRA
    STREAMSDOM -->|"ServiceCalls"| STREAMSSVC
    SDDOM -->|"ServiceCalls"| SDSVC
    INFRA -->|"ExternalAPICalls"| EXT
    BCLIENT -->|"GeneratesAPICode"| FW

    click FW "https://github.com/carlreid/streammaster/blob/main/src/StreamMaster.WebUI"
    click SR "https://github.com/carlreid/streammaster/tree/main/src/StreamMaster.WebUI/lib/signalr"
    click API "https://github.com/carlreid/streammaster/blob/main/src/StreamMaster.API"
    click APP "https://github.com/carlreid/streammaster/blob/main/src/StreamMaster.Application"
    click DOM "https://github.com/carlreid/streammaster/blob/main/src/StreamMaster.Domain"
    click INFRA "https://github.com/carlreid/streammaster/blob/main/src/StreamMaster.Infrastructure"
    click BCLIENT "https://github.com/carlreid/streammaster/tree/main/src/BuildClientAPI"
    click EPGCORE "https://github.com/carlreid/streammaster/blob/main/src/StreamMaster.EPG"
    click EPGC "https://github.com/carlreid/streammaster/tree/main/src/StreamMaster.Application/EPG"
    click EPGCMD "https://github.com/carlreid/streammaster/tree/main/src/StreamMaster.Application/EPGFiles"
    click STREAMSDOM "https://github.com/carlreid/streammaster/blob/main/src/StreamMaster.Streams.Domain"
    click STREAMSSVC "https://github.com/carlreid/streammaster/blob/main/src/StreamMaster.Streams"
    click PLAYLIST "https://github.com/carlreid/streammaster/blob/main/src/StreamMaster.PlayList"
    click WS "https://github.com/carlreid/streammaster/tree/main/src/StreamMaster.Application/WebSocket"
    click SDDOM "https://github.com/carlreid/streammaster/blob/main/src/StreamMaster.SchedulesDirect.Domain"
    click SDSVC "https://github.com/carlreid/streammaster/blob/main/src/StreamMaster.SchedulesDirect.Services"
    click SDSM "https://github.com/carlreid/streammaster/blob/main/src/StreamMaster.SchedulesDirect"

    classDef client fill:#f9f,stroke:#333,stroke-width:2px
    classDef frontend fill:#ffe,stroke:#333,stroke-width:2px
    classDef api fill:#ccf,stroke:#333,stroke-width:2px
    classDef application fill:#cfc,stroke:#333,stroke-width:2px
    classDef domain fill:#fcf,stroke:#333,stroke-width:2px
    classDef infrastructure fill:#cff,stroke:#333,stroke-width:2px
    classDef module fill:#ffc,stroke:#333,stroke-width:2px
```
