# ligmajohn/mw architecture

> Architecture diagram of the GitHub repository ligmajohn/mw, 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/ligmajohn/mw
- Repository: https://github.com/ligmajohn/mw

## Overview

##### Main Components
- Frontend Application:
- Located under the “src” folder, this includes React pages (in src/pages), UI components (in src/components), hooks (in src/hooks), and state management (in src/stores).
- Assets, styling (CSS, Tailwind), and themes are present to supply the visual and localization aspects.
- Optional Backend Services:
- Found in src/backend, these include modules for accounts (authentication, sessions, registration), metadata fetching (TMDB, JustWatch, etc.), and extension-related tasks (scraping, proxying, and messaging).
- Public / Static Files:
- The public folder holds index.html, configuration files, and static resources used by the client.
- Build & Deployment Infrastructure:
- Dockerfile, docker-compose.yaml, Vite configuration, GitHub workflows, and other config files indicate containerized deployment and CI/CD pipelines.
- Plugins and Configuration Utilities:
- The plugins folder (with utilities like converting figmaTokens to theme tokens) and various config files (.eslintrc.js, postcss.config.js, tailwind.config.ts, etc.) show important integration and standardization of coding practices.

##### Relationships and Interactions
- The Frontend (UI) initiates user interactions:
- It uses the pages and components to load various views (home, player view, login, settings, etc.).
- Custom hooks and state management (in stores) handle dynamic UI states, data fetching, and authentication.
- The Frontend communicates with the Optional Backend:
- Endpoints under src/backend/accounts provide session and account-related functionality.
- Metadata endpoints under src/backend/metadata provide movie-related data by scraping or interfacing with third-party APIs.
- Communication might be via REST or similar API patterns.
- Integration with Third-Party Providers:
- The architecture emphasizes that video content is not hosted on the server; instead, the client directly streams from third-party providers.
- The backend assists with scraping and data fetching, but the flow of video content bypasses the server to ensure minimal resource usage.
- External Services & Deployment:
- CI/CD and container orchestration (via Docker, GitHub workflows) ensure that the system can be built, tested, and deployed in predictable environments.
- The self-hosting documentation shows that by using Docker and static hosting, deployments remain inexpensive and scalable.

##### Architectural Patterns and Principles
- Minimalism and Separation of Concerns:
- The design emphasizes a “thin” backend for authentication and data aggregation, keeping the client as a fully static optimized application.
- Modular Architecture:
- The clear separation between UI components (React), state management (stores), and backend modules (accounts, metadata, extension) allows for easier scalability and maintenance.
- Client-Side Data Fetching:
- The use of client-side scraping to fetch video streams shows that the business logic is mostly in the browser, with the backend supporting only syncing and minimal proxying.
- Containerized and CI/CD Deployments:
- Docker and GitHub workflows underline the modern DevOps practices integrated into the project.

- Every module is represented—even if not every file is drawn, create a high-level component for each logical grouping (e.g., “Player Components,” “Account Management Module,” “Metadata Fetcher”).
- Separation of concerns, particularly the minimalist design of the frontend versus the optional backend services meant for synchronization.
- Remember to include deployment infrastructure as it is crucial for understanding how the application is built and hosted.

## Diagram (Mermaid)

```mermaid
flowchart TD
    SC["Source Code Repository"]:::core

    subgraph "Infrastructure & Deployment"
        ID1["Dockerfile"]:::deployment
        ID2["docker-compose.yaml"]:::deployment
        ID3["CI/CD Pipelines"]:::deployment
        ID4["Build Tools & Configs"]:::deployment
        ID5["Plugins & Configs"]:::deployment
    end

    subgraph "Application"
        subgraph "Frontend Application"
            FE1["Pages"]:::frontend
            FE2["UI Components"]:::frontend
            FE3["Hooks"]:::frontend
            FE4["State Management"]:::frontend
            FE5["Assets & Styling"]:::frontend
            FE6["Themes"]:::frontend
        end
        subgraph "Optional Backend Services"
            BE1["Accounts Service"]:::backend
            BE2["Metadata Service"]:::backend
            BE3["Extension Service"]:::backend
            BE4["Provider Fetchers"]:::backend
        end
    end

    EX1["Media Providers"]:::external
    PH["Public Files"]:::hosting

    %% Connections: Deployment Flow
    SC -->|"triggers_build"| ID3
    ID3 -->|"builds_frontend"| FE1
    ID3 -->|"builds_backend"| BE1
    ID3 -->|"deploys_to"| PH

    %% Frontend Internal Flow
    FE1 -->|"renders"| FE2
    FE2 -->|"interacts_with"| FE3
    FE3 -->|"updates"| FE4
    FE4 -->|"utilizes"| FE5
    FE5 -->|"styles"| FE6

    %% Frontend to Backend Communication
    FE1 ---|"api_calls"| BE1
    FE1 ---|"api_calls"| BE2
    FE1 ---|"api_calls"| BE3
    FE1 ---|"api_calls"| BE4

    %% Direct Media Streaming from Frontend to External Providers
    FE1 ---|"streams_to"| EX1

    %% Click Events for Component Mapping
    click FE1 "https://github.com/ligmajohn/mw/tree/dev/src/pages"
    click FE2 "https://github.com/ligmajohn/mw/tree/dev/src/components"
    click FE3 "https://github.com/ligmajohn/mw/tree/dev/src/hooks"
    click FE4 "https://github.com/ligmajohn/mw/tree/dev/src/stores"
    click FE5 "https://github.com/ligmajohn/mw/tree/dev/src/assets"
    click FE6 "https://github.com/ligmajohn/mw/tree/dev/themes"

    click BE1 "https://github.com/ligmajohn/mw/tree/dev/src/backend/accounts"
    click BE2 "https://github.com/ligmajohn/mw/tree/dev/src/backend/metadata"
    click BE3 "https://github.com/ligmajohn/mw/tree/dev/src/backend/extension"
    click BE4 "https://github.com/ligmajohn/mw/tree/dev/src/backend/providers"

    click PH "https://github.com/ligmajohn/mw/tree/dev/public"
    click ID1 "https://github.com/ligmajohn/mw/tree/dev/Dockerfile"
    click ID2 "https://github.com/ligmajohn/mw/blob/dev/docker-compose.yaml"
    click ID3 "https://github.com/ligmajohn/mw/tree/dev/.github/workflows"
    click ID4 "https://github.com/ligmajohn/mw/blob/dev/vite.config.mts"
    click ID5 "https://github.com/ligmajohn/mw/tree/dev/plugins"

    %% Styles
    classDef frontend fill:#ADD8E6,stroke:#000,stroke-width:2px;
    classDef backend fill:#F08080,stroke:#000,stroke-width:2px;
    classDef external fill:#FFFACD,stroke:#000,stroke-width:2px;
    classDef deployment fill:#E6E6FA,stroke:#000,stroke-width:2px;
    classDef core fill:#D3D3D3,stroke:#000,stroke-width:2px;
    classDef hosting fill:#98FB98,stroke:#000,stroke-width:2px;
```
