# kuaifan/dootask architecture

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

- Interactive diagram: https://gitdiagram.com/kuaifan/dootask
- Repository: https://github.com/kuaifan/dootask

## Overview

##### Main Components
- Client Layer:
- Web/Mobile Browser clients and/or Electron (desktop) clients.
- Static assets (in “public/”, “resources/assets/js” and compiled bundles via Vite) that drive the UI.
- API Gateway / Web Server:
- Nginx container (configured in docker/nginx) to serve static assets, handle HTTPS, proxy API requests.
- Application (Backend) Layer:
- Laravel Application: Contains controllers (in app/Http/Controllers), middleware, models, events, tasks, services, observers, and providers.
- API endpoints organized under “api” (in app/Http/Controllers/Api) for various operations (e.g., approve, complaint, dialog, project, report, etc.).
- Artisan commands and custom scripts found in the “cmd” and “bin” directories to control the service (start, stop, install, update, SSL configuration, etc.).
- Data & Storage Layer:
- MySQL container (docker/mysql) running the database with migrations (in database/migrations) and seeders.
- File storage (storage folder) for uploads and application data.
- Caching & Queue/Other Services:
- Redis/Queue could be part of the Laravel setup (if used, as referenced in configuration files and the command shortcuts).
- Elasticsearch container (docker/es) used to sync or handle search indexing, as referenced by modules like ElasticSearch in the app/Module folder.
- Additional Modules / External Services:
- WebSocket Service (app/Services/WebSocketService.php and corresponding models under app/Models) for real-time features.
- AgoraIO module (in app/Module/AgoraIO) for audio/video integrations.
- LDAP integration for user authentication (see app/Ldap).
- Docker and Supervisor setups (provided in docker/*, cmd, and artisan) to manage tasks and background jobs.

##### Relationships and Interactions
- Clients interact over the internet by sending HTTP/HTTPS (or WSS for WebSocket) requests.
- The Nginx container routes requests to the PHP (Laravel) backend. SSL and proxy configurations are handled here.
- The Laravel application processes API requests via its controllers, interacts with the database (MySQL) for persistent storage, and calls auxiliary modules/services (Redis, Elasticsearch, WebSocket services) as needed.
- Background tasks and scheduled jobs (located in app/Tasks) are executed to perform operations like sending notifications, cleaning up data, or synchronizing data (e.g., SyncDialogUserMsgToElasticsearch).
- The Electron client (under the electron directory) and potential mobile views share similar backend APIs or use the same WebSocket service for real-time updates.

##### Architectural Patterns/Design Principles to Highlight
- Layered Architecture: Separate front-end, API, business logic, and data storage.
- Modular Design: Modules (like AgoraIO, ElasticSearch, IpAddr, etc.) encapsulate specific functionality.
- Event-Driven: Observers, events (in app/Events) and tasks indicate asynchronous processing and decoupled interactions.
- Containerization: Use of Docker for isolating services (web server, database, search engine, office, etc.) allowing reproducible and scalable deployments.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Layer
    subgraph "Client Layer"
        A1["Vue.js Frontend"]:::frontend
        A2["Compiled Static Assets"]:::frontend
        A3["Electron Desktop Client"]:::frontend
    end

    %% Docker Compose (Containers & Data/Storage)
    subgraph "Docker Compose"
        B1["Nginx Reverse Proxy"]:::server
        B2["Laravel Application"]:::backend
        B3["MySQL Database"]:::database
        B5["ElasticSearch Module"]:::backend
        B4["Elasticsearch Service"]:::database
        F1["File Storage"]:::storage
        F2["DB Migrations/Seeders"]:::storage
    end

    %% CLI and Management Scripts
    subgraph "CLI & Management"
        D1["Artisan Commands"]:::cli
        D2["Custom Scripts"]:::cli
    end

    %% External Integrations
    subgraph "External Integrations"
        E1["WebSocket Service"]:::external
        E2["AgoraIO Integration"]:::external
        E3["LDAP Integration"]:::external
    end

    %% Connections from Client Layer to Docker Compose
    A1 ---|"HTTP/HTTPS"| B1
    A2 ---|"HTTP/HTTPS"| B1
    A3 ---|"API/WSS"| B1

    %% Nginx proxies requests to Laravel Application
    B1 ---|"Proxies"| B2

    %% Laravel Application interactions
    B2 ---|"CRUD operations"| B3
    B2 ---|"Uses storage"| F1
    B3 ---|"Initialized by"| F2
    B2 ---|"Syncs search data"| B5
    B5 ---|"Integrates with"| B4

    %% External integrations
    B2 ---|"RealTime updates"| E1
    B2 <==>|"Audio/Video"| E2
    B2 <==>|"Auth integration"| E3

    %% CLI interactions with Laravel Application
    D1 ---|"Admin tasks"| B2
    D2 ---|"Service management"| B2

    %% Class definitions with colors
    classDef frontend fill:#AED6F1,stroke:#1B4F72,stroke-width:2px;
    classDef server fill:#F9E79F,stroke:#B9770E,stroke-width:2px;
    classDef backend fill:#D2B4DE,stroke:#7D3C98,stroke-width:2px;
    classDef database fill:#F5CBA7,stroke:#D35400,stroke-width:2px;
    classDef storage fill:#D5F5E3,stroke:#28B463,stroke-width:2px;
    classDef cli fill:#FAD7A0,stroke:#D68910,stroke-width:2px;
    classDef external fill:#F5B7B1,stroke:#C0392B,stroke-width:2px;

    %% Click Events for Client Layer
    click A1 "https://github.com/kuaifan/dootask/tree/pro/resources/assets"
    click A2 "https://github.com/kuaifan/dootask/tree/pro/public"
    click A3 "https://github.com/kuaifan/dootask/tree/pro/electron"

    %% Click Events for Docker Compose
    click B1 "https://github.com/kuaifan/dootask/tree/pro/docker/nginx"
    click B2 "https://github.com/kuaifan/dootask/tree/pro/app"
    click B3 "https://github.com/kuaifan/dootask/tree/pro/docker/mysql"
    click F1 "https://github.com/kuaifan/dootask/tree/pro/storage"
    click F2 "https://github.com/kuaifan/dootask/tree/pro/database"
    click B4 "https://github.com/kuaifan/dootask/tree/pro/docker/es"
    click B5 "https://github.com/kuaifan/dootask/tree/pro/app/Module/ElasticSearch"

    %% Click Events for CLI & Management
    click D1 "https://github.com/kuaifan/dootask/tree/pro/cmd"
    click D2 "https://github.com/kuaifan/dootask/tree/pro/bin"

    %% Click Events for External Integrations
    click E1 "https://github.com/kuaifan/dootask/blob/pro/app/Services/WebSocketService.php"
    click E2 "https://github.com/kuaifan/dootask/tree/pro/app/Module/AgoraIO"
    click E3 "https://github.com/kuaifan/dootask/tree/pro/app/Ldap"
```
