# zukijourney/openshapes architecture

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

- Interactive diagram: https://gitdiagram.com/zukijourney/openshapes
- Repository: https://github.com/zukijourney/openshapes

## Overview

##### Main Components
- Bot Subsystem (located in the “bot” directory):
– Contains the core AI character logic.
– Organized with a modular “openshapes” package that includes:
- The “base.py” for foundational classes and logic.
- A rich set of “cogs” (modules) for handling different command groups (e.g., basic, API, lore, memory, personality, settings).
- “events.py” for handling Discord events.
- “views.py” for any presentation logic.
- “vectordb” package which integrates with external vector databases (e.g., Chroma) for memory handling.
- “utils” package with configuration management, file parsing, helper functions, and regex extensions.
- Manager Subsystem (located in the “manager” directory):
– Provides additional management and containerization tools.
– Contains its own set of command “cogs” (admin, create, manage, tutorial) and container management files (e.g., in container.py, and Dockerfile).
– Likely manages deployment and control of the bot service through scripts and container orchestration.
- External Services and Integration:
– Discord API for bot connectivity and event management.
– External AI API settings with providers like OpenAI, Anthropic, or Zukijourney.
– Vector database integration (facilitated via the “vectordb” module).

##### Relationships and Interactions
- The Discord Bot (bot/openshapes) acts as the primary interface with Discord, receiving messages, handling commands, and processing events.
- Each “cog” represents a set of features (commands) that are loaded into the bot, communicating with the core “base” components.
- The “vectordb” modules connect the bot’s memory and context storage to external storage services.
- Utilitarian modules (helpers, config_manager, file_parser) support data handling and configuration.
- The Manager subsystem provides administrative capabilities and container management for deployment, likely interacting with the Bot subsystem by starting/stopping services or updating configurations.

##### Architectural Patterns and Principles
- Modular Design: The use of distinct “cogs” (separated by functionality) aligns with common patterns in Discord bot development for maintainability.
- Separation of Concerns: Dividing responsibilities between the bot’s interactive components and the manager’s deployment and administration logic.
- Extensibility: Easy addition of new command modules, API integrations, or database support is intended.
- Containerization: The presence of Dockerfile(s) indicates a design geared toward deployment and potentially microservices-based isolation.

##### Relevant Technologies and Frameworks
- Python (3.7+), as seen from the project’s Python scripts.
- Discord API library (possibly discord.py or a similar framework) to handle bot operations.
- Docker (for containerization in the “manager” directory’s Dockerfile).
- External vector database integration (with Chroma) via the “vectordb/chroma_integration.py” and preload scripts.
- Command-line scripting and shell scripts (run.sh) used to start the services.

##### Elements
- Clear labels for each component: “Discord API Connection,” “Bot Core/Engine,” “Cog Modules” (with sub-labels for API, basic commands, lore, personality, etc.), “Vector DB Integration,” “Configuration & Utils,” and “Manager/Container Service.”
– From Discord to Bot (incoming messages and events).
– From Bot to External Services (API calls, vector database operations).
– Between Manager and Bot (administrative interactions, deployment commands).
– Core logic (e.g., rectangles for code modules),
– Deployment elements (e.g., containers for Docker-managed services).
- Notes or annotations for key functionalities such as migration parsing, API configuration endpoints, and telemetry/events flow.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External Services
    subgraph "External Services"
        discordAPI["Discord API Connection"]:::external
        aiProviders["External AI API Providers"]:::external
        externalVectorDB["External Vector DB Service"]:::external
        migrationParser["File-based Migration Parser"]:::external
    end

    %% Bot Subsystem
    subgraph "Bot Subsystem"
        botCore["Bot Core/Engine"]:::bot
        cogModules["Cog Modules"]:::bot
        discordEvents["Discord Event Handling"]:::bot
        presentation["Presentation Views"]:::bot
        vectorDB["Vector DB Integration"]:::bot
        configUtils["Configuration & Utility Functions"]:::bot
    end

    %% Manager Subsystem
    subgraph "Manager Subsystem"
        managerCore["Manager Core"]:::manager
        managerCogs["Manager Cog Modules"]:::manager
        containerDeploy["Container & Deployment Tools"]:::manager
    end

    %% Connections between External Services and Bot Subsystem
    discordAPI -->|"sendsEvent"| discordEvents
    discordEvents -->|"triggers"| botCore
    cogModules -->|"executes"| botCore
    configUtils -->|"configures"| botCore
    botCore -->|"renders"| presentation
    botCore -->|"callsAI"| aiProviders
    botCore -->|"savesMemory"| vectorDB
    vectorDB -->|"stores"| externalVectorDB
    migrationParser -->|"feeds"| configUtils

    %% Manager and Bot interactions
    managerCore -->|"manages"| botCore
    managerCogs -->|"updates"| botCore
    containerDeploy -->|"deploys"| managerCore

    %% Click Events for Bot Subsystem
    click botCore "https://github.com/zukijourney/openshapes/blob/main/bot/openshapes/base.py"
    click cogModules "https://github.com/zukijourney/openshapes/tree/main/bot/openshapes/cogs"
    click discordEvents "https://github.com/zukijourney/openshapes/blob/main/bot/openshapes/events.py"
    click presentation "https://github.com/zukijourney/openshapes/blob/main/bot/openshapes/views.py"
    click vectorDB "https://github.com/zukijourney/openshapes/tree/main/bot/openshapes/vectordb"
    click configUtils "https://github.com/zukijourney/openshapes/tree/main/bot/openshapes/utils"

    %% Click Events for Manager Subsystem
    click managerCore "https://github.com/zukijourney/openshapes/tree/main/manager/manager"
    click managerCogs "https://github.com/zukijourney/openshapes/tree/main/manager/manager/cogs"
    click containerDeploy "https://github.com/zukijourney/openshapes/blob/main/manager/manager/container.py"

    %% Styles
    classDef bot fill:#9fdfbf,stroke:#333,stroke-width:2px;
    classDef manager fill:#ffb7b2,stroke:#333,stroke-width:2px;
    classDef external fill:#fef65b,stroke:#333,stroke-width:2px;
```
