# jackssrt/josh architecture

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

- Interactive diagram: https://gitdiagram.com/jackssrt/josh
- Repository: https://github.com/jackssrt/josh

## Overview

##### Main Components Identification

The system should be divided into these core components:

a) Client Layer
- Entry point (index.ts)
- Discord.js client integration (client.ts)
- Command registry and handling system

b) Feature Modules
- Rotation System (Splatoon game data)
- Event Management
- Voice System
- Game Systems (Hide & Seek)
- Announcement System

c) External Services
- Discord API
- Splatoon3.ink API
- Database (implied by database.ts)

##### Architectural Patterns to Highlight

The project follows several clear patterns:
- Command Pattern (src/commandHandler/)
- Event-Driven Architecture (src/events/)
- Registry Pattern (src/registry.ts)
- Service-based architecture for features

**┌─ External Services Layer ─┐**
- Discord API  Splatoon API│
- ┬────────────────┘
- ↓
**┌─ Core Service Layer ──────┐**
- Client → Command Handler  │
- ↓          ↓          │
- Event Handler  Registry   │
- ┬────────────────┘
- ↓
**┌─ Feature Modules ─────────┐**
- Rotations  Voice System   │
- Games      Announcements  │
- Statistics TTS System     │
- ┬────────────────┘
- ↓
**┌─ Utility Layer ───────────┐**
- Logger    Queue    Signal │
- ┘

##### Component Relationships

Key interactions:
- Command Handler → Feature Modules
- Events → Feature Modules
- Client → External Services
- Feature Modules ↔ Utility Layer

##### Implementation Details

Notes for:
- TypeScript implementation
- Discord.js framework usage
- API integration points
- Database interactions
- Event system architecture

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph External
        DiscordAPI["Discord API"]
        SplatoonAPI["Splatoon3.ink API"]
        DB[(Database)]:::database
    end

    subgraph Core["Core Service Layer"]
        Entry["Entry Point"]:::core
        Client["Discord Client"]:::core
        CmdHandler["Command Handler"]:::core
        CmdRegistry["Command Registry"]:::core
        
        Entry --> Client
        Client --> CmdHandler
        CmdHandler --> CmdRegistry
    end

    subgraph Features["Feature Modules"]
        Rotations["Rotation System"]:::feature
        Voice["Voice System"]:::feature
        HideSeek["Hide & Seek Game"]:::feature
        Announce["Announcement System"]:::feature
        TTS["TTS System"]:::feature
        Stats["Statistics"]:::feature
    end

    subgraph Events["Event System"]
        Welcome["Welcome System"]:::event
        VoiceManager["Voice Channel Manager"]:::event
        RotationNotif["Rotation Notifier"]:::event
        StatsEvent["Stats Events"]:::event
    end

    subgraph Utils["Utility Layer"]
        Logger["Logger"]:::util
        Queue["Queue"]:::util
        Signal["Signal"]:::util
        HTTP["HTTP Utils"]:::util
        Image["Image Utils"]:::util
        Color["Color Utils"]:::util
        Time["Time Utils"]:::util
        DiscordUtil["Discord Utils"]:::util
    end

    %% Core Connections
    Client --> DiscordAPI
    Rotations --> SplatoonAPI
    Client --> DB

    %% Feature Dependencies
    CmdHandler --> Features
    Events --> Features
    Features --> Utils
    Core --> Events

    %% Style Definitions
    classDef core fill:#2b6cb0,stroke:#1a4971,color:#fff
    classDef feature fill:#2f855a,stroke:#22543d,color:#fff
    classDef event fill:#805ad5,stroke:#553c9a,color:#fff
    classDef util fill:#718096,stroke:#4a5568,color:#fff
    classDef database fill:#d69e2e,stroke:#975a16,color:#fff
    
    %% Click Events
    click Entry "https://github.com/jackssrt/josh/blob/main/src/index.ts"
    click Client "https://github.com/jackssrt/josh/blob/main/src/client.ts"
    click CmdHandler "https://github.com/jackssrt/josh/tree/main/src/commandHandler/"
    click CmdRegistry "https://github.com/jackssrt/josh/blob/main/src/commandRegistry.ts"
    click Rotations "https://github.com/jackssrt/josh/tree/main/src/rotations/"
    click Voice "https://github.com/jackssrt/josh/blob/main/src/voice.ts"
    click HideSeek "https://github.com/jackssrt/josh/tree/main/src/commands/hideandseek/"
    click Announce "https://github.com/jackssrt/josh/blob/main/src/announcements.ts"
    click TTS "https://github.com/jackssrt/josh/blob/main/src/events/ttsChannel.ts"
    click Welcome "https://github.com/jackssrt/josh/blob/main/src/events/welcomeMessage.ts"
    click VoiceManager "https://github.com/jackssrt/josh/blob/main/src/events/expandingVoiceChannels.ts"
    click RotationNotif "https://github.com/jackssrt/josh/blob/main/src/events/rotationNotifier.ts"
    click StatsEvent "https://github.com/jackssrt/josh/blob/main/src/events/statsMessage.ts"
    click Logger "https://github.com/jackssrt/josh/blob/main/src/utils/Logger.ts"
    click Queue "https://github.com/jackssrt/josh/blob/main/src/utils/Queue.ts"
    click Signal "https://github.com/jackssrt/josh/blob/main/src/utils/Signal.ts"
    click HTTP "https://github.com/jackssrt/josh/blob/main/src/utils/http.ts"
    click Image "https://github.com/jackssrt/josh/blob/main/src/utils/image.ts"
    click Color "https://github.com/jackssrt/josh/blob/main/src/utils/color.ts"
    click Time "https://github.com/jackssrt/josh/blob/main/src/utils/time.ts"
    click DiscordUtil "https://github.com/jackssrt/josh/tree/main/src/utils/discord/"
```
