# fly-apps/live_beats architecture

> Architecture diagram of the GitHub repository fly-apps/live_beats, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/fly-apps/live_beats
- Repository: https://github.com/fly-apps/live_beats

## Overview

##### Main Components Identification

The system should be represented with these key components:

a) Web Layer (Phoenix LiveView)
- Live Views (Profile, Player, Settings, SignIn)
- Controllers (OAuth, File, Redirect)
- Components (Layouts, Core Components)

b) Core Business Logic
- Accounts System
- Media Library
- Audio Processing

c) External Services
- GitHub OAuth
- Database (Postgres, indicated by Ecto usage)
- File Storage System

##### Component Relationships

a) User Flow
- GitHub OAuth authentication flow
- File upload pathway
- Real-time music playback flow

b) Data Flow
- WebSocket communications for live updates
- File storage and retrieval paths
- Database interactions

##### Technical Details

Specific technical elements:

- Blue: Phoenix/LiveView components
- Green: External services
- Yellow: Data stores
- Purple: Real-time features
- Gray: Supporting services

##### Specific Implementation Notes

a) Phoenix LiveView Architecture
- Real-time socket connection
- Presence functionality
- Pub/sub system

b) Media Handling
- MP3 processing flow
- File storage and retrieval
- Song position tracking

c) Authentication Flow
- GitHub OAuth integration
- User session management
- Authorization checks

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Web_Layer
        LV[Live Views]:::liveview
        CC[Core Components]:::component
        CTRL[Controllers]:::controller
        
        subgraph LiveViews
            ProfView[Profile View]:::liveview
            PlayView[Player View]:::liveview
            SetView[Settings View]:::liveview
            SignView[Sign In View]:::liveview
        end

        subgraph Controllers
            OAuth[OAuth Controller]:::controller
            FileCtrl[File Controller]:::controller
            RedirCtrl[Redirect Controller]:::controller
            AuthCtrl[Auth Controller]:::controller
        end
    end

    subgraph Core_Business_Logic
        ACC[Accounts System]:::core
        ML[Media Library]:::core
        AP[Audio Processing]:::core

        subgraph Accounts
            User[User Model]:::model
            Identity[Identity]:::model
            AccEvents[Account Events]:::events
        end

        subgraph MediaLib
            Song[Song Model]:::model
            Genre[Genre Model]:::model
            Profile[Profile]:::model
            MLEvents[Media Events]:::events
        end

        subgraph AudioProc
            Audio[Audio Module]:::core
            MP3[MP3 Stats]:::core
        end
    end

    subgraph External_Services
        GitHub[GitHub OAuth]:::external
        DB[(Database)]:::database
        Storage[File Storage]:::external
        Mail[Mailer]:::service
    end

    subgraph RealTime_Features
        WS[WebSocket]:::realtime
        Presence[Presence]:::realtime
        PubSub[Pub/Sub]:::realtime
        TM[Telemetry]:::monitoring
    end

    %% Connections
    LV --> CC
    LV --> CTRL
    OAuth --> GitHub
    FileCtrl --> Storage
    ACC --> DB
    ML --> DB
    AP --> Storage
    WS --> PubSub
    PubSub --> Presence

    %% Click Events
    click ProfView "https://github.com/fly-apps/live_beats/blob/master/lib/live_beats_web/live/profile_live.ex"
    click PlayView "https://github.com/fly-apps/live_beats/blob/master/lib/live_beats_web/live/player_live.ex"
    click SetView "https://github.com/fly-apps/live_beats/blob/master/lib/live_beats_web/live/settings_live.ex"
    click SignView "https://github.com/fly-apps/live_beats/blob/master/lib/live_beats_web/live/sign_in_live.ex"
    click CC "https://github.com/fly-apps/live_beats/blob/master/lib/live_beats_web/components/core_components.ex"
    click OAuth "https://github.com/fly-apps/live_beats/blob/master/lib/live_beats_web/controllers/oauth_callback_controller.ex"
    click FileCtrl "https://github.com/fly-apps/live_beats/blob/master/lib/live_beats_web/controllers/file_controller.ex"
    click RedirCtrl "https://github.com/fly-apps/live_beats/blob/master/lib/live_beats_web/controllers/redirect_controller.ex"
    click AuthCtrl "https://github.com/fly-apps/live_beats/blob/master/lib/live_beats_web/controllers/user_auth.ex"
    click ACC "https://github.com/fly-apps/live_beats/blob/master/lib/live_beats/accounts.ex"
    click User "https://github.com/fly-apps/live_beats/blob/master/lib/live_beats/accounts/user.ex"
    click Identity "https://github.com/fly-apps/live_beats/blob/master/lib/live_beats/accounts/identity.ex"
    click AccEvents "https://github.com/fly-apps/live_beats/blob/master/lib/live_beats/accounts/events.ex"
    click ML "https://github.com/fly-apps/live_beats/blob/master/lib/live_beats/media_library.ex"
    click Song "https://github.com/fly-apps/live_beats/blob/master/lib/live_beats/media_library/song.ex"
    click Genre "https://github.com/fly-apps/live_beats/blob/master/lib/live_beats/media_library/genre.ex"
    click Profile "https://github.com/fly-apps/live_beats/blob/master/lib/live_beats/media_library/profile.ex"
    click MLEvents "https://github.com/fly-apps/live_beats/blob/master/lib/live_beats/media_library/events.ex"
    click Audio "https://github.com/fly-apps/live_beats/blob/master/lib/live_beats/audio.ex"
    click MP3 "https://github.com/fly-apps/live_beats/blob/master/lib/live_beats/mp3_stat.ex"
    click GitHub "https://github.com/fly-apps/live_beats/blob/master/lib/live_beats/github.ex"
    click DB "https://github.com/fly-apps/live_beats/blob/master/lib/live_beats/repo.ex"
    click Mail "https://github.com/fly-apps/live_beats/blob/master/lib/live_beats/mailer.ex"
    click Presence "https://github.com/fly-apps/live_beats/blob/master/lib/live_beats_web/channels/presence.ex"
    click TM "https://github.com/fly-apps/live_beats/blob/master/lib/live_beats_web/telemetry.ex"

    %% Styles
    classDef liveview fill:#e1bee7,stroke:#000
    classDef component fill:#bbdefb,stroke:#000
    classDef controller fill:#c8e6c9,stroke:#000
    classDef core fill:#fff9c4,stroke:#000
    classDef model fill:#ffccbc,stroke:#000
    classDef events fill:#d1c4e9,stroke:#000
    classDef external fill:#b2dfdb,stroke:#000
    classDef database fill:#ffecb3,stroke:#000
    classDef service fill:#f8bbd0,stroke:#000
    classDef realtime fill:#e1bee7,stroke:#000
    classDef monitoring fill:#cfd8dc,stroke:#000
```
