# adllkhan/efeer-dashboard architecture

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

- Interactive diagram: https://gitdiagram.com/adllkhan/efeer-dashboard
- Repository: https://github.com/adllkhan/efeer-dashboard

## Overview

##### Main Components
- Frontend (Client):
- Built with Next.js using standard Next.js files and directories (evidenced by the client folder, pages, components, and configuration files like next.config.mjs, jsconfig.json, etc.).
- Contains UI components (found in client/src/components and client/src/components/ui) and API hooks/utilities (e.g., client/src/api/requests.js) for interacting with backend endpoints.
- Implements theming and interactivity (ThemeSwitcher, ThemeProvider, etc.) plus integrations with external services (e.g., Telegram-related components like SendTelegramButton).

- Backend (Server):
- A Python-based API server (noted by the server folder and the presence of a requirements.txt file) with a clear modular architecture.
- Organized into distinct modules:
▪ API endpoints (server/src/api/endpoints) for agents, events, and reports.
▪ Bot integration endpoints (server/src/api/bot) handling authentication and command/message processing.
▪ Services and repositories (server/src/api/services and server/src/api/repositories) encapsulate business logic and data access.
▪ Schemas (server/src/api/schemas) likely used for data validation/serialization.
▪ Configuration/settings (server/src/settings, server/src/api/core/config.py) and integrations with a database (server/src/api/database/mongo.py).
▪ Additional functions like reports generation (server/src/reports with a report.pdf, server/src/templates/report.html).

- External Dependencies and Integration:
- Although not explicitly named in the README, the presence of a “bot” module and Telegram-related components in the frontend (e.g., TokenButton, SendTelegramButton) suggests integration with an external messaging service/platform (likely Telegram).
- Font optimization via Next.js and usage of Tailwind CSS on the client side.

##### Relationships & Interactions
- The Frontend calls the backend’s API endpoints to fetch data and trigger operations related to agents, events, and reports.
- There is a dedicated API layer on the server that routes and processes requests – applying business logic through services and repositories, and interacting with a Mongo database.
- The backend also has a bot-related subsystem: incoming messages/requests (authentication, state management) from possibly external platforms interact with internal components and may even trigger notifications in the client.
- Reports generation utilizes templating (server/src/templates) and static resources to package data into user-facing documents.

##### Architectural Patterns & Technologies
- Separation of Concerns: The client and server codebases are neatly separated, with each having clearly defined responsibilities.
- MVC-like Structure beyond the client: Server endpoints, services, repositories, and schemas organize business logic, data operations, and request handling.
- Modular Design: Different modules for bot handling, API endpoints, and configurations indicate a layered and modular architecture.
- Use of Next.js for server-side rendering and client-side interactivity.
- Python server likely leverages RESTful API patterns with a layered approach.

##### Be Detailed Yet Organized
- Don’t hesitate to break down the architecture into as many components as necessary to reflect the actual structure.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend (Client)
    subgraph "Frontend (Client)"
        client_app["Next.js Client Application"]
        ui_components["UI Components"]
        ui_components_ui["UI Components (UI)"]
        theme_provider["ThemeProvider"]
        theme_switcher["ThemeSwitcher"]
        api_utils["API Interaction Utilities"]
        send_telegram["SendTelegramButton"]
        token_button["TokenButton"]
    end

    %% Backend (Server)
    subgraph "Backend (Server)"
        python_server["Python API Server"]
        rest_api["REST API Endpoints"]
        bot_integration["Bot Integration Module"]
        business_logic["Business Logic Services"]
        data_repos["Data Repositories"]
        mongo_db[("MongoDB")]
        reports_gen["Reports Generation"]
        templating["Templating"]
        settings["Settings"]
        config["Config"]
    end

    %% External Integration
    external["Telegram External Service"]

    %% Frontend Internal Connections
    client_app -->|"contains"| ui_components
    client_app -->|"contains"| ui_components_ui
    client_app -->|"includes"| theme_provider
    client_app -->|"includes"| theme_switcher
    client_app -->|"triggers"| api_utils
    client_app -->|"includes"| send_telegram
    client_app -->|"includes"| token_button

    %% Frontend to Backend API Call
    api_utils -->|"calls"| rest_api

    %% Backend Internal Connections
    python_server -->|"exposes"| rest_api
    python_server -->|"hosts"| bot_integration
    python_server -->|"configures"| settings
    python_server -->|"configures"| config
    rest_api -->|"delegates"| business_logic
    business_logic -->|"accesses"| data_repos
    data_repos -->|"queries"| mongo_db
    rest_api -->|"generates"| reports_gen
    rest_api -->|"renders"| templating
    bot_integration -->|"integrates_with"| business_logic

    %% Backend to External Service Connection
    bot_integration -->|"sends_updates"| external

    %% Frontend Telegram Integration Connection
    send_telegram -->|"notifies"| external
    token_button -->|"authenticates_with"| external

    %% Styles
    classDef client fill:#B3E5FC,stroke:#0277BD,stroke-width:2px;
    classDef server fill:#FFECB3,stroke:#FF6F00,stroke-width:2px;
    classDef database fill:#C8E6C9,stroke:#2E7D32,stroke-width:2px,stroke-dasharray: 5,5;
    classDef external fill:#E1BEE7,stroke:#8E24AA,stroke-width:2px;

    class client_app,ui_components,ui_components_ui,theme_provider,theme_switcher,api_utils,send_telegram,token_button client;
    class python_server,rest_api,bot_integration,business_logic,data_repos,reports_gen,templating,settings,config server;
    class mongo_db database;
    class external external;

    %% Click Events
    click client_app "https://github.com/adllkhan/efeer-dashboard/tree/main/client/"
    click ui_components "https://github.com/adllkhan/efeer-dashboard/tree/main/client/src/components/"
    click ui_components_ui "https://github.com/adllkhan/efeer-dashboard/tree/main/client/src/components/ui/"
    click theme_provider "https://github.com/adllkhan/efeer-dashboard/blob/main/client/src/components/ThemeProvider.jsx"
    click theme_switcher "https://github.com/adllkhan/efeer-dashboard/blob/main/client/src/components/ThemeSwitcher.jsx"
    click api_utils "https://github.com/adllkhan/efeer-dashboard/blob/main/client/src/api/requests.js"
    click send_telegram "https://github.com/adllkhan/efeer-dashboard/blob/main/client/src/components/SendTelegramButton.jsx"
    click token_button "https://github.com/adllkhan/efeer-dashboard/blob/main/client/src/components/TokenButton.jsx"
    click python_server "https://github.com/adllkhan/efeer-dashboard/tree/main/server/"
    click rest_api "https://github.com/adllkhan/efeer-dashboard/tree/main/server/src/api/endpoints/"
    click bot_integration "https://github.com/adllkhan/efeer-dashboard/tree/main/server/src/api/bot/"
    click business_logic "https://github.com/adllkhan/efeer-dashboard/tree/main/server/src/api/services/"
    click data_repos "https://github.com/adllkhan/efeer-dashboard/tree/main/server/src/api/repositories/"
    click mongo_db "https://github.com/adllkhan/efeer-dashboard/blob/main/server/src/api/database/mongo.py"
    click reports_gen "https://github.com/adllkhan/efeer-dashboard/tree/main/server/src/reports/"
    click templating "https://github.com/adllkhan/efeer-dashboard/tree/main/server/src/templates/"
    click settings "https://github.com/adllkhan/efeer-dashboard/tree/main/server/src/settings/"
    click config "https://github.com/adllkhan/efeer-dashboard/blob/main/server/src/api/core/config.py"
```
