# ambival3nt/anne architecture

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

## Overview

##### Main System Components

a) Client Layer:
- Discord Interface
- Web Dashboard (Laravel Livewire UI)
- As separate entry points with different user types

b) Application Layer:
- Laravel Backend (Core)
- Authentication System
- Command Processing System
- Real-time Updates (WebSocket/Broadcasting)

c) Service Layer:
- Core Services:
- OpenAI Integration (GPT-3.5, GPT-4, DALL-E)
- Discord Bot Service
- Spotify Integration
- YouTube Integration
- Lichess Integration
- Trivia System
- Playlist Management
- Vector Database (Pinecone)

d) Data Layer:
- MySQL Database
- File Storage
- Pinecone Vector DB
- Message History Cache

##### Component Relationships

- User interactions flowing from Discord/Web UI to the Laravel backend
- Authentication flow for web dashboard users
- Command processing pipeline from Discord to appropriate services
- Data flow between services and databases
- Integration points with external APIs (OpenAI, Discord, Spotify, etc.)

##### Specific Implementation Details

Specialized components:
- Message Processing Pipeline
- Flow from Discord → Command Handler → GPT Processing → Response
- Memory System
- Connection between messages and Pinecone vector storage
- Feature Services
- Detail how Trivia, Playlist, and other features connect to the core system

##### Technical Stack Indicators

- Laravel 9 Framework
- Livewire 2 for reactive UI
- PHP 8.0
- OpenAI APIs
- Discord Integration
- Vector DB (Pinecone)
- MySQL Database

##### Important Architectural Patterns

Highlight:
- MVC Pattern (Controllers, Models, Views)
- Service Layer Pattern (Core services)
- Job Queue System (for async operations)
- Event-Driven Architecture (for Discord events)

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Client
        DI[Discord Interface]:::ui
        WD[Web Dashboard]:::ui
        click WD "https://github.com/ambival3nt/anne/tree/main/app/Http/Livewire/"
    end

    subgraph Application
        LB[Laravel Backend]:::core
        AS[Authentication System]:::security
        click AS "https://github.com/ambival3nt/anne/tree/main/app/Http/Controllers/Auth/"
        CPS[Command Processing]:::core
        click CPS "https://github.com/ambival3nt/anne/blob/main/app/Core/commands/HandleCommandProcess.php"
        RU[Real-time Updates]:::core
        click RU "https://github.com/ambival3nt/anne/blob/main/app/Events/InteractionCreate.php"
        BC[Bot Core]:::core
        click BC "https://github.com/ambival3nt/anne/blob/main/app/Core/bot_main.php"
    end

    subgraph Services
        direction TB
        OAI[OpenAI Integration]:::service
        click OAI "https://github.com/ambival3nt/anne/blob/main/app/Core/OpenAI/OpenAICore.php"
        DBS[Discord Bot Service]:::service
        SI[Spotify Integration]:::service
        click SI "https://github.com/ambival3nt/anne/blob/main/app/Core/Spotify/QueryAPI.php"
        YI[YouTube Integration]:::service
        click YI "https://github.com/ambival3nt/anne/blob/main/app/Core/YouTube/VideoQuery.php"
        LI[Lichess Integration]:::service
        click LI "https://github.com/ambival3nt/anne/blob/main/app/Core/Features/Lichess.php"
        TS[Trivia System]:::service
        click TS "https://github.com/ambival3nt/anne/blob/main/app/Core/Trivia/TriviaCore.php"
        PM[Playlist Management]:::service
        click PM "https://github.com/ambival3nt/anne/blob/main/app/Core/Features/Playlist.php"
        VDB[Vector Database]:::service
        click VDB "https://github.com/ambival3nt/anne/blob/main/app/Core/VectorDB/PineconeCore.php"
    end

    subgraph "Data Layer"
        DB[(MySQL Database)]:::data
        click DB "https://github.com/ambival3nt/anne/tree/main/app/Models/"
        FS[(File Storage)]:::data
        PDB[(Pinecone Vector DB)]:::data
        MHC[(Message History Cache)]:::data
        click MHC "https://github.com/ambival3nt/anne/blob/main/app/Core/Memory/messageHistoryHandler.php"
    end

    subgraph "Web Components"
        PMI[Prompt Management Interface]:::ui
        click PMI "https://github.com/ambival3nt/anne/blob/main/app/Http/Livewire/PromptInterface.php"
        MHI[Message History Interface]:::ui
        click MHI "https://github.com/ambival3nt/anne/blob/main/app/Http/Livewire/MessageHistory.php"
    end

    DI --> CPS
    WD --> AS
    AS --> LB
    CPS --> BC
    BC --> OAI
    BC --> DBS
    BC --> SI
    BC --> YI
    BC --> LI
    BC --> TS
    BC --> PM
    BC --> VDB

    OAI --> PDB
    VDB --> PDB
    BC --> DB
    BC --> FS
    BC --> MHC

    WD --> PMI
    WD --> MHI
    RU --> DI
    RU --> WD

    classDef core fill:#2374ab
    classDef ui fill:#7d4cdb
    classDef service fill:#00c781
    classDef data fill:#ff8d6d
    classDef security fill:#ff4040
```
