# abhinavxd/libredesk architecture

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

- Interactive diagram: https://gitdiagram.com/abhinavxd/libredesk
- Repository: https://github.com/abhinavxd/libredesk

## Overview

##### Main Components Identification
- Backend (Go Application):
- Core business logic is spread across many internal directories (e.g., internal/auth, internal/conversation, internal/automation, internal/inbox, internal/csat, internal/macro, internal/notification, internal/sla, etc.). There is also a “cmd” folder which indicates multiple entry points or commands for various functionalities such as AI, authentication, conversation, etc.
- Database interactions are evident through many queries.sql files and database setup in the installation section.
- Additional modules provide support for attachments, file/media handling, integrations with channels/messages, event notifications, and websockets.
- Automation, rules evaluation, and auto-assignment further indicate business rule engines within the backend.
- Frontend (Vue.js Application):
- A dedicated “frontend” directory holds assets, components (many UI components, layouts, views, composables, router, and stores), and testing configurations.
- The frontend is structured to support a dynamic user interface with modules for login, administration, conversation details, reporting, and more.
- Database:
- The README and the installation instructions reference a Postgres DB setup.
- External Services:
- Docker Compose files, a Dockerfile, and references to deployment workflows indicate containerization.
- AI functionality and web socket communications are integrated (look at internal/ai, internal/ws).
- Configuration & Deployment:
- Configuration is managed through TOML files (config.sample.toml) and deployment scripts (Makefile, goreleaser config, Docker-compose) plus CI/CD workflows under .github.

##### Architectural Relationships and Interactions
- How the frontend (Vue.js) communicates with the backend via HTTP APIs and possibly web sockets for real-time updates.
- Backend to the Postgres Database. Indicate the use of SQL queries in various modules.
- Docker and deployment configuration as components for setup and scalability.

##### Architectural Patterns and Design Principles
- The project follows a modular monolith structure where functionalities (conversations, automations, roles, users, etc.) are encapsulated in dedicated packages.
- There is a clear separation of concerns:
- Backend business logic and core functionalities are well-organized by domain in the internal directory.
- The frontend is structured into UI components, layouts, views, and state management (stores).
- Communication is based on API calls (HTTP REST) and websockets.
- The design hints at extensibility via modular internal components (for example, automation rules and customizable macros).

## Diagram (Mermaid)

```mermaid
flowchart TD
    A["Frontend (Vue.js Application)"]:::frontend
    B["API Gateway"]:::backend
    A -->|"HTTPAPI/WebSocket"| B

    subgraph "Authentication"
        authCmd["cmd/auth"]:::cmd
        authInternal["Auth Module"]:::backend
    end
    B --> authCmd
    authCmd --> authInternal
    authInternal -->|"DB Query"| DB

    subgraph "Conversation"
        convoCmd["cmd/conversation"]:::cmd
        convoInternal["Conversation Module"]:::backend
    end
    B --> convoCmd
    convoCmd --> convoInternal
    convoInternal -->|"DB Query"| DB

    subgraph "Automation"
        autoCmd["cmd/automation"]:::cmd
        autoInternal["Automation Module"]:::backend
    end
    B --> autoCmd
    autoCmd --> autoInternal
    autoInternal -->|"DB Query"| DB

    subgraph "Macros"
        macroCmd["cmd/macro"]:::cmd
        macroInternal["Macros Module"]:::backend
    end
    B --> macroCmd
    macroCmd --> macroInternal
    macroInternal -->|"DB Query"| DB

    subgraph "SLA & Business Rules"
        slaCmd["cmd/sla"]:::cmd
        slaInternal["SLA Module"]:::backend
    end
    B --> slaCmd
    slaCmd --> slaInternal
    slaInternal -->|"DB Query"| DB

    subgraph "CSAT"
        csatCmd["cmd/csat"]:::cmd
        csatInternal["CSAT Module"]:::backend
    end
    B --> csatCmd
    csatCmd --> csatInternal
    csatInternal -->|"DB Query"| DB

    subgraph "Inbox/Email"
        inboxCmd["cmd/inboxes"]:::cmd
        inboxInternal["Inbox/Email Module"]:::backend
    end
    B --> inboxCmd
    inboxCmd --> inboxInternal
    inboxInternal -->|"DB Query"| DB

    subgraph "AI Integration"
        aiCmd["cmd/ai"]:::cmd
        aiInternal["AI Module"]:::backend
    end
    B --> aiCmd
    aiCmd --> aiInternal
    aiInternal -->|"DB Query"| DB

    subgraph "Media/Attachment"
        mediaCmd["cmd/media"]:::cmd
        mediaInternal["Media Module"]:::backend
    end
    B --> mediaCmd
    mediaCmd --> mediaInternal
    mediaInternal -->|"DB Query"| DB

    subgraph "Websocket/Real-Time"
        wsCmd["cmd/websocket"]:::cmd
        wsInternal["Websocket Module"]:::backend
    end
    B --> wsCmd
    wsCmd --> wsInternal
    wsInternal -->|"Socket Events"| DB

    DB["Postgres Database"]:::db

    subgraph "Deployment & Configuration"
        deploy1["Docker & Compose"]:::deploy
        deploy2["Configuration Files"]:::deploy
    end
    deploy1 --- A
    deploy1 --- B
    deploy2 --- A
    deploy2 --- B

    %% Click Events
    click A "https://github.com/abhinavxd/libredesk/tree/main/frontend/"
    click authInternal "https://github.com/abhinavxd/libredesk/tree/main/internal/auth"
    click authCmd "https://github.com/abhinavxd/libredesk/blob/main/cmd/auth.go"
    click convoInternal "https://github.com/abhinavxd/libredesk/tree/main/internal/conversation"
    click convoCmd "https://github.com/abhinavxd/libredesk/blob/main/cmd/conversation.go"
    click autoInternal "https://github.com/abhinavxd/libredesk/tree/main/internal/automation"
    click autoCmd "https://github.com/abhinavxd/libredesk/blob/main/cmd/automation.go"
    click macroInternal "https://github.com/abhinavxd/libredesk/tree/main/internal/macro"
    click macroCmd "https://github.com/abhinavxd/libredesk/blob/main/cmd/macro.go"
    click slaInternal "https://github.com/abhinavxd/libredesk/tree/main/internal/sla"
    click slaCmd "https://github.com/abhinavxd/libredesk/blob/main/cmd/sla.go"
    click csatInternal "https://github.com/abhinavxd/libredesk/tree/main/internal/csat"
    click csatCmd "https://github.com/abhinavxd/libredesk/blob/main/cmd/csat.go"
    click inboxInternal "https://github.com/abhinavxd/libredesk/tree/main/internal/inbox/channel/email"
    click inboxCmd "https://github.com/abhinavxd/libredesk/blob/main/cmd/inboxes.go"
    click aiInternal "https://github.com/abhinavxd/libredesk/tree/main/internal/ai"
    click aiCmd "https://github.com/abhinavxd/libredesk/blob/main/cmd/ai.go"
    click mediaInternal "https://github.com/abhinavxd/libredesk/tree/main/internal/media"
    click mediaCmd "https://github.com/abhinavxd/libredesk/blob/main/cmd/media.go"
    click wsInternal "https://github.com/abhinavxd/libredesk/tree/main/internal/ws"
    click wsCmd "https://github.com/abhinavxd/libredesk/blob/main/cmd/websocket.go"
    click DB "https://github.com/abhinavxd/libredesk/blob/main/schema.sql"
    click deploy1 "https://github.com/abhinavxd/libredesk/blob/main/docker-compose.yml"
    click deploy2 "https://github.com/abhinavxd/libredesk/blob/main/config.sample.toml"

    %% Styles
    classDef frontend fill:#ffcccc,stroke:#cc0000,stroke-width:2px;
    classDef backend fill:#ccffcc,stroke:#008800,stroke-width:2px;
    classDef cmd fill:#cce5ff,stroke:#0055aa,stroke-width:2px;
    classDef db fill:#ffffcc,stroke:#999900,stroke-width:2px;
    classDef deploy fill:#e0e0ff,stroke:#6666ff,stroke-width:2px;
```
