# azure-samples/azure-ai-agents-javascript architecture

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

- Interactive diagram: https://gitdiagram.com/azure-samples/azure-ai-agents-javascript
- Repository: https://github.com/azure-samples/azure-ai-agents-javascript

## Overview

##### Project type and purpose
- This is a Node.js/TypeScript demo CLI application (“Azure AI Agent Service Demo”) that walks users through different Azure AI Agent tooling scenarios (simple calculation, function­call tools, code interpreter, RAG with Azure AI Search, Bing Grounding, usage stats).
- Its goal is to show off various Azure AI Foundry agent capabilities in a modular, extensible way.

##### File structure
- Top-level:
- src/ – application source
- src/config/ – environment & prompt configurations
- src/services/ – three core services: agentService, threadService, toolService
- src/utils/ – shared helpers (console output, formatting)
- src/index.ts – CLI entrypoint
- files/ – sample documents for RAG
- examples/ – example scripts showing usage
- package.json, tsconfig.json – build/config
- Patterns:
- Layered/modular (Config → Services → Utils)
- “Service-oriented” modules wrap specific functionality (agent orchestration, thread management, external tooling)
- External-service integration (Azure AI Foundry, Azure Search, Bing)

##### README for additional insights
- Describes demo features and required Azure setup (AI Foundry project, optional AI Search and Bing Grounding connections).
- Indicates this is a CLI demo: npm start and selecting an agent scenario.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Core Application Layer
    subgraph "Core Application" 
        direction TB
        CLI["CLI Interface"]:::application
        subgraph "Configuration Layer"
            direction TB
            Env["env.ts"]:::config
            PromptConfig["promptConfig.ts"]:::config
        end
        subgraph "Core Services"
            direction TB
            AgentService["AgentService"]:::service
            ThreadService["ThreadService"]:::service
            ToolService["ToolService"]:::service
        end
        subgraph "Utility Layer"
            direction TB
            ConsoleUtils["console.ts"]:::utils
            FormattingUtils["formatting.ts"]:::utils
        end
        Examples["Examples Scripts"]:::examples
    end

    %% Data Store
    DataStore["Local Data Store<br/>(files/)"]:::datastore

    %% External Dependencies
    subgraph "External Services"
        direction TB
        Foundry["Azure AI Foundry"]:::external
        Search["Azure AI Search"]:::external
        Bing["Bing Grounding API"]:::external
    end

    %% Connections
    CLI -->|"user input"| AgentService
    AgentService -->|"load config"| Env
    AgentService -->|"load prompts"| PromptConfig
    AgentService -->|"maintain context"| ThreadService
    AgentService -->|"invoke tools"| ToolService
    ThreadService -->|"context data"| AgentService
    ToolService -->|"LLM calls"| Foundry
    ToolService -->|"search requests"| Search
    ToolService -->|"web queries"| Bing
    Search -->|"vector search over docs"| DataStore
    Foundry -->|"response"| ToolService
    Search -->|"search results"| ToolService
    Bing -->|"grounded info"| ToolService
    ToolService -->|"tool results"| AgentService
    AgentService -->|"format output"| ConsoleUtils
    AgentService -->|"format output"| FormattingUtils
    ConsoleUtils -->|"print to console"| CLI
    FormattingUtils -->|"print to console"| CLI

    %% Click Events
    click CLI "https://github.com/azure-samples/azure-ai-agents-javascript/blob/main/src/index.ts"
    click Env "https://github.com/azure-samples/azure-ai-agents-javascript/blob/main/src/config/env.ts"
    click PromptConfig "https://github.com/azure-samples/azure-ai-agents-javascript/blob/main/src/config/promptConfig.ts"
    click AgentService "https://github.com/azure-samples/azure-ai-agents-javascript/blob/main/src/services/agentService.ts"
    click ThreadService "https://github.com/azure-samples/azure-ai-agents-javascript/blob/main/src/services/threadService.ts"
    click ToolService "https://github.com/azure-samples/azure-ai-agents-javascript/blob/main/src/services/toolService.ts"
    click ConsoleUtils "https://github.com/azure-samples/azure-ai-agents-javascript/blob/main/src/utils/console.ts"
    click FormattingUtils "https://github.com/azure-samples/azure-ai-agents-javascript/blob/main/src/utils/formatting.ts"
    click DataStore "https://github.com/azure-samples/azure-ai-agents-javascript/tree/main/files/"
    click Examples "https://github.com/azure-samples/azure-ai-agents-javascript/tree/main/examples/"

    %% Styles
    classDef application fill:#D6EAFE,stroke:#0366D6,color:#0366D6;
    classDef config fill:#E8F4FD,stroke:#7AA7D9,color:#0366D6;
    classDef service fill:#DEF7EC,stroke:#28A745,color:#0F5132;
    classDef utils fill:#FFF4E5,stroke:#FFC107,color:#856404;
    classDef datastore fill:#FFF1F0,stroke:#D73A49,color:#86181D,shape:cylinder;
    classDef external fill:#E6FFFA,stroke:#20C997,color:#0F5132;
    classDef examples fill:#F0F0F0,stroke:#6A737D,color:#24292E;
```
