# ridhwaans/homehost architecture

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

## Overview

##### Main System Components

a) Client Layer (Frontend):
- React-based web application
- Three main media sections (Movies, TV Shows, Music)
- Search functionality
- Media player components
- Admin interface

b) Server Layer (Backend):
- Node.js server
- RESTful API endpoints
- Media file system integration
- Metadata processing service
- Database integration

c) External Services:
- TMDb API integration
- Spotify Web API integration
- File System (for media storage)

**[External APIs]**
- ↕
**[Client Layer] ←→ [Server Layer] ←→ [File System]**
- ↕
- [Database]

##### Component Details

For each major component, include these elements:

Client Layer:
- Three main media sections (Movies, TV Shows, Music)
- Search component
- Media player components
- Routing system
- Admin interface

Server Layer:
- API routes organization
- Metadata processing service
- Job scheduling system
- Database interaction layer
- File system management

Database:
- Prisma ORM integration
- Media metadata storage
- File reference storage

##### Data Flow Indicators

- API requests between client and server
- External API calls
- File system operations
- Database queries
- Media streaming paths

##### Technical Stack Indicators

- React (Frontend)
- Node.js (Backend)
- Prisma (ORM)
- SQLite (Database)
- Webpack (Build tool)

##### Additional Elements

Include:
- Environment configuration flow
- Media file naming conventions
- Authentication flow (if implemented)
- Streaming protocols
- Cache management

##### File system monitoring

This architecture represents a self-hosted media streaming platform with emphasis on home network usage, metadata enrichment, and organized media management.

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph External["External Services"]
        TMDB["TMDb API"]
        SPOTIFY["Spotify Web API"]
    end

    subgraph Client["Client Layer"]
        APP["React App"]:::frontend
        click APP "https://github.com/ridhwaans/homehost/blob/master/packages/client/components/App.js"
        
        subgraph MediaSections["Media Sections"]
            MOVIES["Movies Section"]:::frontend
            click MOVIES "https://github.com/ridhwaans/homehost/blob/master/packages/client/components/Movies/index.js"
            TV["TV Shows Section"]:::frontend
            click TV "https://github.com/ridhwaans/homehost/blob/master/packages/client/components/TVShows/index.js"
            MUSIC["Music Section"]:::frontend
            click MUSIC "https://github.com/ridhwaans/homehost/blob/master/packages/client/components/Music/index.js"
        end

        subgraph Interface["User Interface"]
            SEARCH["Search Component"]:::frontend
            click SEARCH "https://github.com/ridhwaans/homehost/blob/master/packages/client/components/Search/index.js"
            PLAYER["Media Player"]:::frontend
            click PLAYER "https://github.com/ridhwaans/homehost/blob/master/packages/client/components/Player/index.js"
            ADMIN["Admin Interface"]:::frontend
            click ADMIN "https://github.com/ridhwaans/homehost/blob/master/packages/client/components/Admin/index.js"
            NOWPLAY["Now Playing Bar"]:::frontend
            click NOWPLAY "https://github.com/ridhwaans/homehost/blob/master/packages/client/components/NowPlayingBar/NowPlayingBar.js"
            WIZARD["Media Wizard"]:::frontend
            click WIZARD "https://github.com/ridhwaans/homehost/blob/master/packages/client/components/MediaWizard/StepForm.js"
        end

        CONTEXT["Context Management"]:::frontend
        click CONTEXT "https://github.com/ridhwaans/homehost/blob/master/packages/client/contexts/context.js"
    end

    subgraph Server["Server Layer"]
        MAIN["Main Server"]:::backend
        click MAIN "https://github.com/ridhwaans/homehost/blob/master/packages/server/server.js"
        
        API["API Routes"]:::backend
        click API "https://github.com/ridhwaans/homehost/blob/master/packages/server/routes/index.js"
        
        META["Metadata Service"]:::backend
        click META "https://github.com/ridhwaans/homehost/blob/master/packages/server/services/metadata.js"
        
        JOBS["Job Scheduler"]:::backend
        click JOBS "https://github.com/ridhwaans/homehost/blob/master/packages/server/jobs/index.js"
        
        UTILS["Server Utilities"]:::backend
        click UTILS "https://github.com/ridhwaans/homehost/blob/master/packages/server/utils/index.js"
        
        CONFIG["Server Config"]:::backend
        click CONFIG "https://github.com/ridhwaans/homehost/blob/master/packages/server/constants/index.js"
    end

    subgraph Storage["Storage Layer"]
        DB[(Database)]:::database
        click DB "https://github.com/ridhwaans/homehost/blob/master/packages/server/prisma/schema.prisma"
        FS["File System"]:::storage
    end

    %% Connections
    TMDB & SPOTIFY <--> MAIN
    APP --> API
    MediaSections --> API
    Interface --> API
    CONTEXT --> APP
    API --> MAIN
    MAIN --> META
    MAIN --> JOBS
    MAIN --> UTILS
    CONFIG --> MAIN
    MAIN <--> DB
    MAIN <--> FS

    %% Styles
    classDef frontend fill:#3498db,stroke:#2980b9,color:white
    classDef backend fill:#2ecc71,stroke:#27ae60,color:white
    classDef database fill:#9b59b6,stroke:#8e44ad,color:white
    classDef storage fill:#e67e22,stroke:#d35400,color:white
    classDef external fill:#f1c40f,stroke:#f39c12,color:black

    %% Legend
    subgraph Legend
        F["Frontend"]:::frontend
        B["Backend"]:::backend
        D["Database"]:::database
        S["Storage"]:::storage
        E["External"]:::external
    end
```
