# ninjawarrior1337/hanamaru-go architecture

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

## Overview

##### Main Components

a. Core Framework Layer:
- Custom framework component (framework/) as the foundation
- Voice handling subsystem (framework/voice/)
- Database integration (framework/db.go)

b. Command Modules (organize into functional groups):
- Audio/Visual Commands (commands/av/)
- Fun Commands (commands/fun/)
- Information Commands (commands/info/)
- Japanese Language Features (commands/jp/)
- Music Commands (commands/music/)
- Debug Commands (commands/debug/)

c. Utility Services Layer (util/):
- External API Integrations (Anilist, Exchange Rates, PlayerDB)
- Media Processing (Audio/Video utilities)
- Japanese Language Processing
- LaTeX Rendering
- Translation Services

d. Database Layer:
- PostgreSQL database (indicated by migrations/)
- Data models for awards and tags

e. External Services Integration:
- Discord API Connection
- YouTube Integration (for music playback)
- Various API Services (Jisho, AniList, etc.)

**[External Services Layer]**
- ↕
**[Discord API Interface]**
- ↕
**[Core Framework Layer] ←→ [Database Layer]**
- ↕
**[Command Modules] ←→ [Utility Services Layer]**

##### Important Relationships

- How the framework handles command routing
- Voice system's connection to YouTube
- Demonstrate database interactions for persistent storage
- How utility services support command modules

##### Technical Details

- Go as the primary language
- Required external dependencies (youtube-dl)
- Configuration management
- Embedded resources (assets/)

##### Implementation Notes

- Version information
- Build tags (jp, ij) as conditional features

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Styles and Classes
    classDef core fill:#b3d9ff,stroke:#333
    classDef command fill:#90EE90,stroke:#333
    classDef external fill:#FFE4B5,stroke:#333
    classDef utility fill:#DDA0DD,stroke:#333
    classDef database fill:#FF6B6B,stroke:#333
    classDef event fill:#98FB98,stroke:#333
    classDef build fill:#87CEEB,stroke:#333

    %% External Services Layer
    subgraph ExternalServices
        Discord["Discord API"]:::external
        YouTube["YouTube"]:::external
        JishoAPI["Jisho API"]:::external
        AniListAPI["AniList API"]:::external
    end

    %% Core Framework Layer
    subgraph CoreFramework
        Framework["Framework Core"]:::core
        VoiceSystem["Voice System"]:::core
        DBIntegration["Database Integration"]:::core
        MainBot["Main Bot Logic"]:::core
    end
    click Framework "https://github.com/ninjawarrior1337/hanamaru-go/tree/main/framework/"
    click VoiceSystem "https://github.com/ninjawarrior1337/hanamaru-go/tree/main/framework/voice/"
    click DBIntegration "https://github.com/ninjawarrior1337/hanamaru-go/blob/main/framework/db.go"
    click MainBot "https://github.com/ninjawarrior1337/hanamaru-go/blob/main/framework/hanamaru.go"

    %% Command Modules
    subgraph Commands
        AVCommands["Audio/Visual Commands"]:::command
        FunCommands["Fun Commands"]:::command
        InfoCommands["Information Commands"]:::command
        JPCommands["Japanese Commands"]:::command
        MusicCommands["Music Commands"]:::command
        DebugCommands["Debug Commands"]:::command
    end
    click AVCommands "https://github.com/ninjawarrior1337/hanamaru-go/tree/main/commands/av/"
    click FunCommands "https://github.com/ninjawarrior1337/hanamaru-go/tree/main/commands/fun/"
    click InfoCommands "https://github.com/ninjawarrior1337/hanamaru-go/tree/main/commands/info/"
    click JPCommands "https://github.com/ninjawarrior1337/hanamaru-go/tree/main/commands/jp/"
    click MusicCommands "https://github.com/ninjawarrior1337/hanamaru-go/tree/main/commands/music/"
    click DebugCommands "https://github.com/ninjawarrior1337/hanamaru-go/tree/main/commands/debug/"

    %% Utility Services
    subgraph Utils
        AnilistUtil["Anilist Integration"]:::utility
        ExchangeRates["Exchange Rates"]:::utility
        PlayerDB["PlayerDB"]:::utility
        MediaProc["Media Processing"]:::utility
        JPProc["JP Processing"]:::utility
        LaTeX["LaTeX Rendering"]:::utility
        Translate["Translation Service"]:::utility
        JishoUtil["Jisho Integration"]:::utility
    end
    click AnilistUtil "https://github.com/ninjawarrior1337/hanamaru-go/blob/main/util/anilist.go"
    click ExchangeRates "https://github.com/ninjawarrior1337/hanamaru-go/blob/main/util/exchange_rates.go"
    click PlayerDB "https://github.com/ninjawarrior1337/hanamaru-go/blob/main/util/playerdb.go"
    click MediaProc "https://github.com/ninjawarrior1337/hanamaru-go/tree/main/util/av/"
    click JPProc "https://github.com/ninjawarrior1337/hanamaru-go/tree/main/util/jp/"
    click LaTeX "https://github.com/ninjawarrior1337/hanamaru-go/tree/main/util/latex/"
    click Translate "https://github.com/ninjawarrior1337/hanamaru-go/blob/main/util/translate.go"
    click JishoUtil "https://github.com/ninjawarrior1337/hanamaru-go/tree/main/util/jisho/"

    %% Database Layer
    subgraph Database
        PostgreSQL["PostgreSQL"]:::database
        Migrations["Schema Migrations"]:::database
        Awards["Awards System"]:::database
        Tags["Tags System"]:::database
    end
    click PostgreSQL "https://github.com/ninjawarrior1337/hanamaru-go/tree/main/db/"
    click Migrations "https://github.com/ninjawarrior1337/hanamaru-go/tree/main/db/migrations/"
    click Awards "https://github.com/ninjawarrior1337/hanamaru-go/blob/main/db/awards.go"
    click Tags "https://github.com/ninjawarrior1337/hanamaru-go/blob/main/db/tags.go"

    %% Event System
    EventSystem["Event Handling System"]:::event
    click EventSystem "https://github.com/ninjawarrior1337/hanamaru-go/tree/main/events/"

    %% Build Pipeline
    BuildSystem["Build/Deploy Pipeline"]:::build
    click BuildSystem "https://github.com/ninjawarrior1337/hanamaru-go/tree/main/.github/workflows/"

    %% Assets
    Assets["Assets & Resources"]:::utility
    click Assets "https://github.com/ninjawarrior1337/hanamaru-go/tree/main/assets/"

    %% Relationships
    Discord --> MainBot
    MainBot --> Framework
    Framework --> VoiceSystem
    Framework --> DBIntegration
    VoiceSystem --> YouTube
    DBIntegration --> PostgreSQL
    PostgreSQL --> Migrations
    PostgreSQL --> Awards
    PostgreSQL --> Tags
    Framework --> Commands
    Commands --> Utils
    Utils --> ExternalServices
    EventSystem --> Framework
    BuildSystem --> MainBot
    Assets --> Commands

    %% Legend
    subgraph Legend
        L1["Core Components"]:::core
        L2["Command Modules"]:::command
        L3["External Services"]:::external
        L4["Utility Services"]:::utility
        L5["Database Components"]:::database
        L6["Event System"]:::event
        L7["Build System"]:::build
    end
```
