# superglue-ai/superglue architecture

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

- Interactive diagram: https://gitdiagram.com/superglue-ai/superglue
- Repository: https://github.com/superglue-ai/superglue

## Overview

##### Project Type & Purpose
- This project is an open-source API proxy and data transformation tool. It “translates data from external systems into exactly the format you need” by intercepting API calls, performing LLM-powered data mappings, handling file processing, and applying self-healing mechanisms.

##### Analysis of the File Structure
- The top-level directories indicate the project is organized as a monorepo with multiple packages:
- packages/core: Contains the fundamental logic with modules divided into authentication, datastore integrations (memory, redis), GraphQL resolvers, and various utility functions.
- packages/shared: Likely contains shared types or utility code.
- packages/web: Contains the web application (dashboard/GUI) built with Next.js and supporting UI components.
- Other important files include Dockerfiles and docker-compose.yml for containerized deployment. Configuration files (.env.example, tsconfig.json, turbo.json) and GitHub workflows indicate a standard CI/CD setup.
- Documentation in the docs folder further details API references and guides, which are also good hints for including runtime and build-time components in the architecture.

##### Main Components & Relationships
a. Data Sources (Input):
b. Data Transformation Engine:
- The “superglue engine” which includes:
- GraphQL processing (packages/core/graphql)
- Data mapping/resolvers (various resolvers in packages/core)
- LLM-powered translation (suggested by the README’s “LLM-Powered Data Mapping” feature).
c. Authentication & API Key Management:
- Components in packages/core/auth (apiKeyManager, localKeyManager, supabaseKeyManager) which manage secure access.
d. Datastore:
- Support for both in-memory (fast but non-persistent) and redis (persistent) as seen under packages/core/datastore modules.
e. Web Dashboard (Frontend):
- Located in packages/web, it provides the interactive dashboard for configuration and monitoring, built with Next.js.
f. External Service Integrations:
- Communication of the core engine with enhanced APIs, GraphQL endpoints and potentially external LLM services (OpenAI integration based on the README’s instructions).
g. Infrastructure / Deployment:
- Dockerfiles, docker-compose, and CI/CD workflows to containerize and orchestrate the application.

Relationships between these components include:
- Data flows from external sources into the superglue engine.
- The engine uses internal modules (authentication, datastore, transformers) to process, validate, and transform data.
- Processed data is then sent toward the user’s system (destination) as per configuration.
- The web dashboard communicates with the core API (GraphQL server) for configuration and monitoring.
- Deployment components (Docker, CI/CD pipelines) manage the lifecycle and scaling of the services.

##### Architectural Patterns and Technologies
- Layered/MVC-like separation between business logic (core engine) and presentation (web dashboard).
- Use of GraphQL as an API interface.
- Containerization (Docker) and orchestration (docker-compose) for deployment.
- The modular monorepo structure (with Turbo repo support via turbo.json) that supports separation of concerns.
- TypeScript, Next.js for the frontend, and Redis/in-memory for datastore functionality.

##### Important Detail
- Don’t just list components – show interactions. For instance, connect the GraphQL resolvers (data mapping and transformation) to both the datastore and key management systems.
- Ancillary components (Docker, CI/CD pipelines) as part of the overall architecture if deployment is critical to the discussion.
- On any details in the docs (like “architecture.md” under docs/guides) to see if there are any subtle interactions or blueprints mentioned.

Data Sources → Transformation Engine (with authentication, datastore, GraphQL processing, LLM-powered mapping) → Web Dashboard and external API calls,
all while acknowledging the deployment and container orchestration layers.
This detailed breakdown will help any principal software engineer immediately grasp the technical architecture and pathogen of data as it flows and transforms within the system.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Global Entities
    A["Data Sources (External APIs, Files, Legacy Systems)"]:::external
    B["Destination (User System/External API)"]:::external
    WD["Web Dashboard (Frontend)"]:::frontend
    D["Deployment & Containerization"]:::deploy

    %% Transformation Engine Subgraph
    subgraph "Transformation Engine"
        direction TB
        T1["Superglue Engine"]:::engine
        T2["GraphQL Processing"]:::engine
        T3["Authentication & API Key Management"]:::engine
        T4["Datastore Integration"]:::engine
        T5["LLM-Powered Mapping"]:::engine
        T6["Shared Utilities and Types"]:::utility
    end

    %% Data Flow Connections
    A -->|"ingests"| T1
    T1 -->|"calls"| T2
    T1 -->|"transforms"| T5
    T2 -->|"secures"| T3
    T2 -->|"stores"| T4
    T6 -->|"supports"| T1
    T1 -->|"outputs"| B

    %% Web Dashboard and Deployment Interactions
    T1 <-->|"configures"| WD
    D -->|"deploys"| T1
    D -->|"deploys"| WD

    %% Click Events
    click T1 "https://github.com/superglue-ai/superglue/tree/main/packages/core"
    click T2 "https://github.com/superglue-ai/superglue/tree/main/packages/core/graphql"
    click T3 "https://github.com/superglue-ai/superglue/tree/main/packages/core/auth"
    click T4 "https://github.com/superglue-ai/superglue/tree/main/packages/core/datastore"
    click WD "https://github.com/superglue-ai/superglue/tree/main/packages/web"
    click T6 "https://github.com/superglue-ai/superglue/tree/main/packages/shared"

    %% Styles
    classDef external fill:#FFCDD2,stroke:#B71C1C,stroke-width:2px;
    classDef engine fill:#C8E6C9,stroke:#1B5E20,stroke-width:2px;
    classDef frontend fill:#BBDEFB,stroke:#0D47A1,stroke-width:2px;
    classDef deploy fill:#D1C4E9,stroke:#4A148C,stroke-width:2px;
    classDef utility fill:#FFE082,stroke:#FF6F00,stroke-width:2px;
```
