# midday-ai/ai-sdk-tools architecture

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

- Interactive diagram: https://gitdiagram.com/midday-ai/ai-sdk-tools
- Repository: https://github.com/midday-ai/ai-sdk-tools

## Overview

##### Project type and purpose
- This is a Git-managed monorepo containing an open-source SDK (“AI SDK Tools”) and two Next.js applications (an example app and a documentation website).
- It exposes modular packages (agents, cache, artifacts, memory, store, devtools, debug, ai-sdk-tools, etc.) for building production-ready AI workflows, along with sample integrations.

##### File structure
- Top-level directories:
- `.github/` – CI/CD workflows for beta and release.
- `apps/` – Next.js “example” (AI chat sandbox) and “website” (docs & demos).
- `packages/` – NPM-bundled libraries (agents, cache, artifacts, memory, store, devtools, debug, ai-sdk-tools).
- `scripts/` – Publish, release, pre-publish, version bump, etc.
- `.changeset/` – Versioning & changelog management.
- Each package has its own `tsconfig.json` and `tsup.config.ts` for building.
- Apps share a common Next.js structure (`pages` or `app` directory), import the SDK packages, and include API routes (chat, transcription, metadata).

##### README for additional insights
- Describes a “unified package” plus individual installs for each sub-package.
- Highlights key features: state management, debugging tools, structured streaming (artifacts), intelligent agents, caching, persistent memory.
- Directs users to the website for interactive demos and docs.

##### Elements
- From root → CI/CD → published packages.
- From Example App API routes → LLM providers, cache, memory.
- From Devtools → UI panel.
- Green for published packages,
- Blue for apps,
- Gray for scripts/CICD,
- Orange for external services.

##### Detailed capture of essential elements
- Data flow: user chat UI → chat hook (store) → agent orchestrator → tools (cache, memory, artifacts) → LLM → back through store → UI.
- Devtools interceptor tapped into that same data flow for debugging.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Monorepo Root and Management
    subgraph "Monorepo Root" 
        direction TB
        changesets[".changeset/"]:::gray
        github[".github/workflows/"]:::gray
        scripts["scripts/"]:::gray
    end

    %% CI/CD Workflows
    subgraph "CI/CD Workflows" 
        direction TB
        betaYml["beta-release.yml"]:::gray
        releaseYml["release.yml"]:::gray
    end

    %% Changeset Configuration
    subgraph "Changeset Configuration"
        direction TB
        csConfig["config.json"]:::gray
        csReadme["README.md"]:::gray
    end

    %% Release & Publish Scripts
    subgraph "Release & Publish Scripts"
        direction TB
        prePublish["pre-publish.js"]:::gray
        publishSeq["publish-sequential.js"]:::gray
        checkBeta["check-beta-mode.js"]:::gray
        cleanBeta["clean-beta-versions.js"]:::gray
        betaSh["beta-release.sh"]:::gray
        devSetup["dev-setup.sh"]:::gray
        ensureCs["ensure-changesets.js"]:::gray
    end

    %% Packages
    subgraph "Packages" 
        direction TB
        uisdk["ai-sdk-tools"]:::green
        agents["agents"]:::green
        cache["cache"]:::green
        artifacts["artifacts"]:::green
        memory["memory"]:::green
        store["store"]:::green
        devtools["devtools"]:::green
        debugPkg["debug"]:::green
    end

    %% Apps
    subgraph "Apps"
        direction TB
        example["Example App"]:::blue
        website["Docs Website"]:::blue
    end

    %% External Services
    subgraph "External Services"
        direction TB
        openai["OpenAI / LLM Providers"]:::orange
        redis["Redis / Upstash"]:::orange
        vercel["Vercel Platform"]:::orange
    end

    %% Relationships
    changesets --> csConfig
    changesets --> csReadme
    github --> betaYml
    github --> releaseYml
    scripts --> prePublish
    scripts --> publishSeq
    scripts --> checkBeta
    scripts --> cleanBeta
    scripts --> betaSh
    scripts --> devSetup
    scripts --> ensureCs

    changesets --> scripts
    changesets --> github

    betaYml --> uisdk
    releaseYml --> uisdk

    uisdk --> agents
    uisdk --> cache
    uisdk --> artifacts
    uisdk --> memory
    uisdk --> store
    uisdk --> devtools
    uisdk --> debugPkg

    example --> uisdk
    example --> agents
    example --> cache
    example --> memory
    example --> devtools

    website --> uisdk
    website --> artifacts
    website --> store
    website --> debugPkg

    example --> openai
    example --> redis
    example --> vercel
    website --> vercel

    devtools --> example

    %% Click Events
    click changesets "https://github.com/midday-ai/ai-sdk-tools/tree/main/.changeset/"
    click github "https://github.com/midday-ai/ai-sdk-tools/tree/main/.github/workflows/"
    click scripts "https://github.com/midday-ai/ai-sdk-tools/tree/main/scripts/"
    click betaYml "https://github.com/midday-ai/ai-sdk-tools/blob/main/.github/workflows/beta-release.yml"
    click releaseYml "https://github.com/midday-ai/ai-sdk-tools/blob/main/.github/workflows/release.yml"
    click csConfig "https://github.com/midday-ai/ai-sdk-tools/blob/main/.changeset/config.json"
    click csReadme "https://github.com/midday-ai/ai-sdk-tools/blob/main/.changeset/README.md"
    click prePublish "https://github.com/midday-ai/ai-sdk-tools/blob/main/scripts/pre-publish.js"
    click publishSeq "https://github.com/midday-ai/ai-sdk-tools/blob/main/scripts/publish-sequential.js"
    click checkBeta "https://github.com/midday-ai/ai-sdk-tools/blob/main/scripts/check-beta-mode.js"
    click cleanBeta "https://github.com/midday-ai/ai-sdk-tools/blob/main/scripts/clean-beta-versions.js"
    click betaSh "https://github.com/midday-ai/ai-sdk-tools/blob/main/scripts/beta-release.sh"
    click devSetup "https://github.com/midday-ai/ai-sdk-tools/blob/main/scripts/dev-setup.sh"
    click ensureCs "https://github.com/midday-ai/ai-sdk-tools/blob/main/scripts/ensure-changesets.js"
    click uisdk "https://github.com/midday-ai/ai-sdk-tools/tree/main/packages/ai-sdk-tools/"
    click agents "https://github.com/midday-ai/ai-sdk-tools/tree/main/packages/agents/"
    click cache "https://github.com/midday-ai/ai-sdk-tools/tree/main/packages/cache/"
    click artifacts "https://github.com/midday-ai/ai-sdk-tools/tree/main/packages/artifacts/"
    click memory "https://github.com/midday-ai/ai-sdk-tools/tree/main/packages/memory/"
    click store "https://github.com/midday-ai/ai-sdk-tools/tree/main/packages/store/"
    click devtools "https://github.com/midday-ai/ai-sdk-tools/tree/main/packages/devtools/"
    click debugPkg "https://github.com/midday-ai/ai-sdk-tools/tree/main/packages/debug/"
    click example "https://github.com/midday-ai/ai-sdk-tools/tree/main/apps/example/"
    click website "https://github.com/midday-ai/ai-sdk-tools/tree/main/apps/website/"

    %% Styles
    classDef gray fill:#dddddd,stroke:#888888,color:#333333;
    classDef green fill:#b9f6ca,stroke:#388e3c,color:#1b5e20;
    classDef blue fill:#bbdefb,stroke:#1976d2,color:#0d47a1;
    classDef orange fill:#ffe0b2,stroke:#f57c00,color:#e65100;
```
