# cg8-5712/bj35-bot architecture

> Architecture diagram of the GitHub repository cg8-5712/bj35-bot, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-02). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/cg8-5712/bj35-bot
- Repository: https://github.com/cg8-5712/bj35-bot

## Overview

##### Project Type and Purpose
- The project is a full-stack web application designed to provide a visual management interface for the Bj35 robot.
- Its purpose is to offer users capabilities such as robot status monitoring, message sending management, system configuration, and token access management.
- The technology stack includes a Vue3-based frontend built with Vite and a Python Flask backend, using SQLite as the database.

##### Key Architectural Components
a. Frontend Layer:
- The Frontend directory includes config files (e.g., Vite config, .env illustration) and source code under “src”.
- Components are structured into common elements (like LoadingSpinner and MessageInfo), dashboard components, and profile management.
- Entry points include main.js and index.html.
- This layer communicates with the backend via API services (as seen in Frontend/src/services).

b. Backend Layer:
- The Backend folder contains multiple Python modules and subdirectories.
- Main backend components include:
- API layer: The “api” directory (with app.py) sets up the Flask API endpoints.
- Worker/Task components: e.g., “send_message” which includes modules for receiving/sending messages and retrieving user information.
- Access token management: Multiple files indicate specific handling logic under both “accessToken.py” and its handler directories.
- Configuration and data access: Files like config.py and SqliteData.py indicate settings and database interaction using SQLite.
- The backend directory further subdivides components into ‘handler’ folders and submodules that help in logically separating API routing, configuration, and access token management.

c. Database Layer:
- Even though there is no explicit “db” folder, SQLite is the chosen database. The module SqliteData.py encapsulates interactions with the SQLite database.

d. External Libraries and Utilities:
- Within the “send_message” folder, there are modules for interfacing with WeWork APIs (e.g., WXBizMsgCrypt variations and weworkapi_python integration) which serve as external services for message encryption and integration.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Layer
    subgraph "Frontend Layer"
        FE1("Vue App (Frontend Entry)"):::frontend
        FE2("Components"):::frontend
        FE3("Routing"):::frontend
        FE4("API Services"):::frontend
        FE1 --> FE2
        FE1 --> FE3
        FE1 --> FE4
        %% Click Events for Frontend Components
        click FE1 "https://github.com/cg8-5712/bj35-bot/tree/main/Frontend/"
        click FE2 "https://github.com/cg8-5712/bj35-bot/tree/main/Frontend/src/components"
        click FE3 "https://github.com/cg8-5712/bj35-bot/blob/main/Frontend/src/router/index.js"
        click FE4 "https://github.com/cg8-5712/bj35-bot/tree/main/Frontend/src/services"
    end

    %% Backend Layer
    subgraph "Backend Layer"
        BE1("Core App (Backend Entry)"):::backend
        BE2("Flask API Endpoints"):::backend
        BE3("Access Token Management"):::backend
        BE4("Worker & Messaging Tasks"):::backend
        BE5("Configuration & Data Access"):::backend
        BE1 --> BE2
        BE2 --> BE3
        BE2 --> BE4
        BE2 --> BE5
        %% Click Events for Backend Components
        click BE1 "https://github.com/cg8-5712/bj35-bot/blob/main/Backend/app.py"
        click BE2 "https://github.com/cg8-5712/bj35-bot/blob/main/Backend/api/app.py"
        click BE3 "https://github.com/cg8-5712/bj35-bot/blob/main/Backend/accessToken.py"
        click BE4 "https://github.com/cg8-5712/bj35-bot/tree/main/Backend/send_message"
        click BE5 "https://github.com/cg8-5712/bj35-bot/blob/main/Backend/config.py"
    end

    %% Database Layer
    subgraph "Database Layer"
        DB("SQLite Database"):::db
        click DB "https://github.com/cg8-5712/bj35-bot/blob/main/Backend/SqliteData.py"
    end

    %% External Services
    subgraph "External Services"
        EX("WeWork API Integration"):::external
        click EX "https://github.com/cg8-5712/bj35-bot/tree/main/Backend/send_message/weworkapi_python"
    end

    %% Inter-Layer Connections
    FE4 -->|"calls"| BE2
    BE5 -->|"queries"| DB
    BE4 -->|"integrates with"| EX

    %% Styles
    classDef frontend fill:#ADD8E6,stroke:#000,stroke-width:2px;
    classDef backend fill:#90EE90,stroke:#000,stroke-width:2px;
    classDef db fill:#FFA07A,stroke:#000,stroke-width:2px;
    classDef external fill:#DDA0DD,stroke:#000,stroke-width:2px;
```
