# pickzelle/mrkonqi architecture

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

- Interactive diagram: https://gitdiagram.com/pickzelle/mrkonqi
- Repository: https://github.com/pickzelle/mrkonqi

## Overview

##### Main Components Identification

a. Core Bot Infrastructure:
- Discord.js Client Integration
- Command Handler
- Event Handler
- Configuration System

b. Database Layer:
- Prisma ORM
- PostgreSQL Database

c. External Services:
- Arch Linux Repository Integration
- AUR Integration
- Character.ai Integration

**┌─ Discord Bot Core ─────────────┐**
- Command Handler             │
- Event Handler              │
- Configuration Manager      │
- ┘

**┌─ Discord Integration ─┐  ┌─ Database Layer ──┐**
- Commands           │  │ - Prisma Client   │
- Events            │  │ - PostgreSQL DB   │
- ┘  └─────────────────────┘

**┌─ External Services ──┐  ┌─ Utility Modules ──┐**
- Arch Repo API     │  │ - Logger          │
- AUR API           │  │ - File System     │
- Character.ai      │  │ - Paralload       │
- ┘  └─────────────────────┘

##### Connection Types

Different types of connections:
→ Direct dependencies
⇢ Data flow
⇄ Two-way communication

##### Implementation Details

a. File Structure Representation:
- Src/ directory organization
- Separation of concerns (discord/, modules/, lib/)

b. Configuration Flow:
- How config.jsonc is loaded and distributed
- Environment variable integration

##### Technical Stack Indicators

Technology badges or labels for:
- TypeScript/JavaScript
- Bun.js Runtime
- Discord.js
- Prisma ORM
- PostgreSQL

##### Specific Features

Bot features:
- Package management commands (arch, aur)
- Moderation capabilities
- Support functions

Example high-level structure:

**[Discord API] ⇄ [Bot Core] → [Command Handler]**
- ↓             ↓
**[Config] →    [Event System] → [Modules]**
- ↓             ↓
**[Database] ⇄  [Prisma ORM]  ← [Services]**

Remember to maintain a balance between detail and clarity, focusing on the architectural decisions that matter most for understanding the system's structure and flow.

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Core["Core Bot Infrastructure"]
        Client["Discord.js Client"]
        CmdHandler["Command Handler"]
        EventHandler["Event Handler"]
        Config["Configuration System"]
    end

    subgraph Database["Database Layer"]
        Prisma["Prisma ORM"]
        PostgreSQL[(PostgreSQL)]
        LegacyDB["Legacy Database"]
    end

    subgraph External["External Services"]
        ArchRepo["Arch Linux Repository"]
        AUR["AUR Service"]
        CharAI["Character.ai"]
    end

    subgraph Commands["Command Modules"]
        ModernCmd["Modern Commands"]
        LegacyCmd["Legacy Commands"]
    end

    subgraph Events["Event Handlers"]
        ModernEvents["Modern Events"]
        LegacyEvents["Legacy Events"]
    end

    subgraph Util["Utility Modules"]
        Logger["Logger"]
        FSUtil["File System"]
        Paralload["Parallel Loader"]
        ClientLoad["Client Loader"]
    end

    subgraph Interfaces["Interface Definitions"]
        ConfigInterface["Config Interface"]
        StorageInterface["Storage Interface"]
    end

    DiscordAPI["Discord API"]

    DiscordAPI <--> Client
    Client --> CmdHandler
    Client --> EventHandler
    Config --> Client
    
    CmdHandler --> ModernCmd
    CmdHandler --> LegacyCmd
    EventHandler --> ModernEvents
    EventHandler --> LegacyEvents
    
    ModernCmd --> External
    LegacyCmd --> External
    
    Prisma --> PostgreSQL
    ModernCmd --> Prisma
    LegacyCmd --> LegacyDB
    
    Config --> ConfigInterface
    Prisma --> StorageInterface

    ModernCmd --> Logger
    LegacyCmd --> Logger
    ClientLoad --> Client
    Paralload --> Client

    %% Click events for component mapping
    click Client "https://github.com/Pickzelle/MrKonqi/blob/main/src/discord/index.ts"
    click CmdHandler "https://github.com/Pickzelle/MrKonqi/blob/main/src/discord/commands/index.ts"
    click EventHandler "https://github.com/Pickzelle/MrKonqi/blob/main/src/discord/events/index.ts"
    click Config "https://github.com/Pickzelle/MrKonqi/blob/main/src/util/parse/config.ts"
    click Prisma "https://github.com/Pickzelle/MrKonqi/blob/main/prisma/schema.prisma"
    click LegacyDB "https://github.com/Pickzelle/MrKonqi/blob/main/src/discord/_old/legacy-db.ts"
    click ArchRepo "https://github.com/Pickzelle/MrKonqi/blob/main/src/discord/commands/arch.ts"
    click AUR "https://github.com/Pickzelle/MrKonqi/blob/main/src/discord/_old/modules/callAUR.js"
    click CharAI "https://github.com/Pickzelle/MrKonqi/blob/main/src/modules/c.ai/index.ts"
    click Logger "https://github.com/Pickzelle/MrKonqi/blob/main/src/lib/logger/index.ts"
    click FSUtil "https://github.com/Pickzelle/MrKonqi/blob/main/src/util/fs.ts"
    click Paralload "https://github.com/Pickzelle/MrKonqi/blob/main/src/util/paralload.ts"
    click ClientLoad "https://github.com/Pickzelle/MrKonqi/blob/main/src/util/load/clients.ts"
    click ModernCmd "https://github.com/Pickzelle/MrKonqi/tree/main/src/discord/commands"
    click LegacyCmd "https://github.com/Pickzelle/MrKonqi/tree/main/src/discord/_old/commands"
    click ModernEvents "https://github.com/Pickzelle/MrKonqi/tree/main/src/discord/events"
    click LegacyEvents "https://github.com/Pickzelle/MrKonqi/tree/main/src/discord/_old/events"
    click ConfigInterface "https://github.com/Pickzelle/MrKonqi/blob/main/src/interfaces/config.d.ts"
    click StorageInterface "https://github.com/Pickzelle/MrKonqi/blob/main/src/interfaces/storage.d.ts"

    classDef core fill:#2b6cb0,stroke:#1a4971,color:white
    classDef database fill:#ed8936,stroke:#c05621,color:white
    classDef external fill:#48bb78,stroke:#2f855a,color:white
    classDef util fill:#805ad5,stroke:#553c9a,color:white
    classDef interface fill:#718096,stroke:#4a5568,color:white
    classDef api fill:#e53e3e,stroke:#c53030,color:white

    class Client,CmdHandler,EventHandler,Config core
    class Prisma,PostgreSQL,LegacyDB database
    class ArchRepo,AUR,CharAI external
    class Logger,FSUtil,Paralload,ClientLoad util
    class ConfigInterface,StorageInterface interface
    class DiscordAPI api
```
