# thedescend/elevatorbot architecture

> Architecture diagram of the GitHub repository thedescend/elevatorbot, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-26). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/thedescend/elevatorbot
- Repository: https://github.com/thedescend/elevatorbot

## Overview

##### External Services Integration (Show as external systems)
- Discord API
- Bungie API
- Steam API
- GitHub API

##### Data Flow Patterns

- User interactions through Discord/Website
- API calls between components
- Database operations
- Background task flows
- Monitoring data flow

##### Key Architectural Elements

a) Backend Services:
**Backend API (FastAPI)**
- Authentication
- Destiny Integration
- CRUD Operations
- Background Tasks
- Monitoring

b) Bot Services:
**Discord Bot**
- Commands
- Events
- Background Tasks
- Networking
- Webserver

c) Website:
**Next.js Frontend**
- Authentication
- Server Management
- Documentation
- Role Management

##### Technical Stack Labels

- Python 3.10+
- FastAPI
- PostgreSQL
- Next.js
- Docker
- Prometheus/Grafana
- Discord API (N.A.F.F)

##### Special Notes

- Modular design with clear separation between Backend, Bot, and Website
- Shared components (Shared/ directory)
- Extensible nature of the command system
- Monitoring and metrics flow

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Frontend
        Auth["Auth Components"]
        ServerMgmt["Server Management"]
        Docs["Documentation System"]
        RoleMgmt["Role Management"]
    end

    subgraph DiscordBot
        CmdHandler["Command Handler"]
        EventSys["Event System"]
        BgTasks["Background Tasks"]
        NetLayer["Networking Layer"]
        PrometheusBot["Prometheus Metrics"]
        WebServer["Webserver Component"]
    end

    subgraph Backend
        APIEndpoints["API Endpoints"]
        AuthSystem["Authentication System"]
        DBModels["Database Models"]
        BgEvents["Background Events"]
        BungieInt["Bungie Integration"]
    end

    subgraph Infrastructure
        PostgreSQL[(PostgreSQL)]
        PrometheusMon["Prometheus"]
        Grafana["Grafana Dashboards"]
        Docker["Docker Containers"]
    end

    subgraph ExternalServices
        DiscordAPI["Discord API"]
        BungieAPI["Bungie API"]
        SteamAPI["Steam API"]
        GitHubAPI["GitHub API"]
    end

    subgraph SharedComponents
        NetSchemas["Network Schemas"]
        CommonFuncs["Common Functions"]
        Enums["Enums"]
    end

    %% Frontend connections
    Auth --> APIEndpoints
    ServerMgmt --> APIEndpoints
    Docs --> APIEndpoints
    RoleMgmt --> APIEndpoints

    %% Bot connections
    CmdHandler --> NetLayer
    EventSys --> NetLayer
    BgTasks --> NetLayer
    NetLayer --> APIEndpoints
    NetLayer --> DiscordAPI
    PrometheusBot --> PrometheusMon
    WebServer --> NetLayer

    %% Backend connections
    APIEndpoints --> AuthSystem
    APIEndpoints --> DBModels
    BgEvents --> BungieInt
    BungieInt --> BungieAPI
    APIEndpoints --> SteamAPI
    APIEndpoints --> GitHubAPI
    DBModels --> PostgreSQL

    %% Infrastructure connections
    PrometheusMon --> Grafana

    %% Shared component usage
    NetLayer --> NetSchemas
    APIEndpoints --> NetSchemas
    NetLayer --> CommonFuncs
    APIEndpoints --> CommonFuncs
    NetLayer --> Enums
    APIEndpoints --> Enums

    %% Click events
    click Auth "https://github.com/TheDescend/elevatorbot/tree/master/Website/components/auth"
    click ServerMgmt "https://github.com/TheDescend/elevatorbot/tree/master/Website/pages/server"
    click Docs "https://github.com/TheDescend/elevatorbot/tree/master/Website/pages/docs"
    click RoleMgmt "https://github.com/TheDescend/elevatorbot/blob/master/Website/pages/server/[guild_id]/roles.js"
    click CmdHandler "https://github.com/TheDescend/elevatorbot/tree/master/ElevatorBot/commands"
    click EventSys "https://github.com/TheDescend/elevatorbot/tree/master/ElevatorBot/discordEvents"
    click BgTasks "https://github.com/TheDescend/elevatorbot/tree/master/ElevatorBot/backgroundEvents"
    click PrometheusBot "https://github.com/TheDescend/elevatorbot/tree/master/ElevatorBot/prometheus"
    click WebServer "https://github.com/TheDescend/elevatorbot/tree/master/ElevatorBot/webserver"
    click APIEndpoints "https://github.com/TheDescend/elevatorbot/tree/master/Backend/endpoints"
    click AuthSystem "https://github.com/TheDescend/elevatorbot/tree/master/Backend/core/security"
    click DBModels "https://github.com/TheDescend/elevatorbot/blob/master/Backend/database/models.py"
    click BgEvents "https://github.com/TheDescend/elevatorbot/tree/master/Backend/backgroundEvents"
    click BungieInt "https://github.com/TheDescend/elevatorbot/tree/master/Backend/bungio"
    click PrometheusMon "https://github.com/TheDescend/elevatorbot/tree/master/Stats/prometheus"
    click Grafana "https://github.com/TheDescend/elevatorbot/tree/master/Stats/grafana"
    click NetSchemas "https://github.com/TheDescend/elevatorbot/tree/master/Shared/networkingSchemas"
    click CommonFuncs "https://github.com/TheDescend/elevatorbot/tree/master/Shared/functions"
    click Enums "https://github.com/TheDescend/elevatorbot/tree/master/Shared/enums"

    classDef frontend fill:#3498db,stroke:#2980b9,color:white
    classDef bot fill:#2ecc71,stroke:#27ae60,color:white
    classDef backend fill:#e74c3c,stroke:#c0392b,color:white
    classDef infrastructure fill:#f1c40f,stroke:#f39c12,color:black
    classDef external fill:#9b59b6,stroke:#8e44ad,color:white
    classDef shared fill:#1abc9c,stroke:#16a085,color:white

    class Auth,ServerMgmt,Docs,RoleMgmt frontend
    class CmdHandler,EventSys,BgTasks,NetLayer,PrometheusBot,WebServer bot
    class APIEndpoints,AuthSystem,DBModels,BgEvents,BungieInt backend
    class PostgreSQL,PrometheusMon,Grafana,Docker infrastructure
    class DiscordAPI,BungieAPI,SteamAPI,GitHubAPI external
    class NetSchemas,CommonFuncs,Enums shared
```
