# dust-tt/dust architecture

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

- Interactive diagram: https://gitdiagram.com/dust-tt/dust
- Repository: https://github.com/dust-tt/dust

## Overview

- Frontend Clients:
- The “front” directory (a Next.js/React application) which likely powers the primary web user dashboard.
- The “extension” directory, which appears to contain code for a browser extension (e.g., Chrome extension).
- “sparkle” – a UI component library and design system that provides reusable building blocks.
- “viz” – for visualization purposes.
- Backend Services:
- “core”: A Rust-based core API and service layer handling business logic, migrations, and internal processing.
- “connectors”: A large, TypeScript-based module managing integrations with third-party systems (e.g., Google Drive, Slack, Notion, etc.). This module includes admin scripts, migrations, temporal workflows, and API routing.
- “sdks”: Provides client libraries (JavaScript SDK) to help third parties interact with the Dust platform.
- Asynchronous and Job Processing:
- Temporal jobs appear in both the “alerting”, “connectors”, “core”, and even in “front/temporal” directories. These represent background workflows (activities, signals, workers, workflows) for tasks like data synchronization, file processing, and scheduled clean-ups.
- Infrastructure & DevOps:
- Dockerfiles (in “dockerfiles” and in the root) and GitHub workflows (under “.github”) show how the system is built, tested, and deployed.
- Migration scripts (present in “connectors/migrations”, “core/bin/migrations”, “front/migrations”, and “migrations/db”) indicate a structured approach toward managing the database schema.
- External Integrations:
- The connectors and OAuth directories within “core” and “connectors” illustrate integrations with external APIs and authentication providers.
- The project mentions various providers (e.g., Slack, Notion, GitHub, Google Drive) and includes specific modules or temporal jobs for each.

##### Relationships and Interactions
- Data Flow between Frontend and Backend:
- The “front” application communicates with the backend core API (exposed via Next.js API routes and REST endpoints).
- The “extension” likely communicates with backend services either via secure API calls or through a dedicated messaging layer.
- Internal Communication among Backend Modules:
- The “core” service (in Rust) likely provides the foundation for business logic and interacts with the connectors to trigger integrations.
- The “connectors” service (in TypeScript) interacts with external APIs and triggers asynchronous tasks via Temporal workflows.
- Asynchronous Processing:
- CI/CD and Deployment:
- GitHub workflows automate the build, lint, test, and deploy steps for each module, and Dockerfiles suggest that containerization is used for deployment.
- Data and Storage:
- Although not explicitly listed, the multiple database migration scripts (SQL files) suggest a centralized persistent data store (likely relational, such as PostgreSQL) that all backend modules interact with. Also, caching (e.g., Redis) might be included in the “core” and “connectors” libraries.

##### Architectural Patterns and Design Principles
- Modular/Monorepo Organization:
- Separate directories for each functional area (core, connectors, front, extension, sparkle, etc.) show a modular approach.
- Microservices / Service Separation:
- Backends are divided into distinct services (core business services in Rust, connectors in TypeScript) with a clear separation of concerns.
- Event-Driven / Asynchronous Workflow:
- The Temporal integration signifies an event-driven design for background tasks and inter-service coordination.
- API Gateway / Aggregation:
- The Next.js “front” application likely acts as a composition layer or API gateway to aggregate data from various services.
- Containerization and CI/CD:
- Use of Dockerfiles and GitHub Actions indicates deployment automation along with consistent environments for development and production.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Clients
    subgraph "Frontend Clients"
        FE1["Front Web Client (Next.js)"]:::frontend
        FE2["Browser Extension Client"]:::frontend
        FE3["Sparkle Design System"]:::frontend
        FE4["Viz Visualization"]:::frontend
    end

    %% Backend Services
    subgraph "Backend Services"
        BE1["Core API Service (Rust)"]:::backend
        BE2["Connectors Service (TypeScript)"]:::backend
        BE3["Client SDK (JS)"]:::backend
    end

    %% Asynchronous Job Processing
    subgraph "Asynchronous Job Processing"
        TEMP1["Temporal Worker (Alerting)"]:::temporal
        TEMP2["Temporal Worker (Front)"]:::temporal
    end

    %% Infrastructure & DevOps
    subgraph "Infrastructure & DevOps"
        INF1["Database"]:::database
        INF2["CI/CD Pipeline (GitHub Actions)"]:::infrastructure
        INF3["Docker Containers"]:::infrastructure
    end

    %% External Integrations
    subgraph "External Integrations"
        EXT1["External APIs"]:::external
    end

    %% Interactions: Frontend to Backend
    FE1 -->|"API_call"| BE1
    FE2 -->|"API_call"| BE1

    %% Backend initiating asynchronous tasks
    BE1 -->|"async_task"| TEMP1
    BE2 -->|"async_task"| TEMP1
    BE1 -->|"async_task"| TEMP2
    BE2 -->|"async_task"| TEMP2

    %% Internal Backend Communication
    BE1 -->|"trigger_integration"| BE2
    BE3 -->|"API_call"| BE1

    %% Connectors calling External APIs
    BE2 -->|"integration"| EXT1

    %% Database interactions for migrations
    BE1 -->|"migration"| INF1
    BE2 -->|"migration"| INF1

    %% CI/CD and Deployment Pipeline
    INF2 -->|"build_deploy"| INF3
    INF3 --> FE1
    INF3 --> FE2
    INF3 --> BE1
    INF3 --> BE2

    %% External consumption via SDK
    EXT1 -->|"consume"| BE3

    %% Click Events for Component Mapping
    click FE1 "https://github.com/dust-tt/dust/tree/main//front"
    click FE2 "https://github.com/dust-tt/dust/tree/main//extension"
    click FE3 "https://github.com/dust-tt/dust/tree/main//sparkle"
    click FE4 "https://github.com/dust-tt/dust/tree/main//viz"
    click BE1 "https://github.com/dust-tt/dust/tree/main//core"
    click BE2 "https://github.com/dust-tt/dust/tree/main//connectors"
    click BE3 "https://github.com/dust-tt/dust/tree/main//sdks/js"
    click TEMP1 "https://github.com/dust-tt/dust/tree/main//alerting/temporal"
    click TEMP2 "https://github.com/dust-tt/dust/tree/main//front/temporal"
    click INF2 "https://github.com/dust-tt/dust/blob/main//.github"
    click INF3 "https://github.com/dust-tt/dust/tree/main//dockerfiles"

    %% Styles
    classDef frontend fill:#ADD8E6,stroke:#333,stroke-width:2px;
    classDef backend fill:#C1FFC1,stroke:#333,stroke-width:2px;
    classDef temporal fill:#FFFFCC,stroke:#333,stroke-width:2px;
    classDef infrastructure fill:#FFDAB9,stroke:#333,stroke-width:2px;
    classDef external fill:#FFB6C1,stroke:#333,stroke-width:2px;
    classDef database fill:#E0E0E0,stroke:#333,stroke-width:2px;
```
