# meta-llama/llama-stack-client-node architecture

> Architecture diagram of the GitHub repository meta-llama/llama-stack-client-node, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-18). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/meta-llama/llama-stack-client-node
- Repository: https://github.com/meta-llama/llama-stack-client-node

## Overview

##### Main Components

a. Client Layer:
- Core Client Component (represented by src/core.ts)
- Error Handling System (src/error.ts)
- Resource Management (src/resource.ts)

b. Resource Groups:
- Agents System
- Inference Services
- Evaluation Services
- Memory Management
- Post-training Services
- Safety & Telemetry

c. Platform Support Layer:
- Runtime Shims (for different environments)
- Type Definitions
- Network Layer

**┌─────────────────────────────────────────────────────┐**
- Client Applications                 │
- ┘
- ↓
**┌─────────────────────────────────────────────────────┐**
- LlamaStackClient SDK                  │
- ┬─────────────────┬───────────────────┤
- Core Client │  Error Handling │ Resource Manager  │
- ┴─────────────────┴───────────────────┘
- ↓
**┌─────────────────────────────────────────────────────┐**
- Resource Groups                     │
- ┬──────────┬──────────┬──────────┬────────┤
- Agents  │Inference │Evaluate  │ Memory   │  etc.   │
- ┴──────────┴──────────┴──────────┴────────┘
- ↓
**┌─────────────────────────────────────────────────────┐**
- Platform Support Layer                  │
- ┬──────────────┬─────────────┬────────────┤
- Shims   │Type Systems  │Fetch Client │  Utils     │
- ┴──────────────┴─────────────┴────────────┘
- ↓
**┌─────────────────────────────────────────────────────┐**
- Llama Stack REST API                 │
- ┘

##### Important Details to Highlight

a. Client Configuration:
- Environment settings (sandbox/production)
- Retry mechanism
- Timeout handling
- Custom fetch client support
- HTTP agent configuration

b. Resource Interactions:
- How different resource groups interact
- Streaming capabilities
- Error handling flow

c. Cross-Platform Support:
- Different runtime support (Node.js, web)
- Type system integration
- Shim architecture

##### Additional Elements

- Different component types
- Configuration options

##### Technical Details to Note

- Retry logic flow (2 retries by default)
- Timeout boundaries (1-minute default)
- Error handling hierarchy
- Type system integration points

##### Implementation Notes

- The modular nature of the resource system
- The flexibility of the platform support layer
- The comprehensive error handling system
- The type-safe nature of the client

Remember to include notes about:
- TypeScript support (>= 4.5)
- Runtime compatibility
- Error handling hierarchy
- Configuration options

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Client ["Client Applications"]
        App[Client Application]
    end

    subgraph SDK ["LlamaStackClient SDK"]
        Core["Core Client"]:::core
        Error["Error Handler"]:::core
        Resource["Resource Manager"]:::core
    end

    subgraph Resources ["Resource Groups"]
        direction TB
        Agents["Agents System"]:::resource
        Inference["Inference Services"]:::resource
        Evaluate["Evaluation Services"]:::resource
        Memory["Memory Management"]:::resource
        PostTraining["Post-training Services"]:::resource
        Safety["Safety System"]:::resource
        Telemetry["Telemetry System"]:::resource
        Batch["Batch Processing"]:::resource
        Datasets["Dataset Management"]:::resource
        Models["Model Management"]:::resource
        Shields["Shield Services"]:::resource
        Synthetic["Synthetic Data"]:::resource
    end

    subgraph Platform ["Platform Support Layer"]
        direction TB
        Shims["Runtime Shims"]:::platform
        Types["Type Definitions"]:::platform
        NodeRuntime["Node.js Runtime"]:::platform
        WebRuntime["Web Runtime"]:::platform
        BunRuntime["Bun Runtime"]:::platform
        Streaming["Streaming Support"]:::platform
        Uploads["File Upload Handler"]:::platform
        Version["Version Manager"]:::platform
    end

    subgraph API ["Llama Stack REST API"]
        REST[REST Endpoints]:::external
    end

    %% Connections
    App --> Core
    Core --> Error
    Core --> Resource
    Resource --> Resources
    Resources --> Platform
    Platform --> API

    %% Click Events
    click Core "https://github.com/meta-llama/llama-stack-client-node/blob/main/src/core.ts"
    click Error "https://github.com/meta-llama/llama-stack-client-node/blob/main/src/error.ts"
    click Resource "https://github.com/meta-llama/llama-stack-client-node/blob/main/src/resource.ts"
    click Agents "https://github.com/meta-llama/llama-stack-client-node/tree/main/src/resources/agents/"
    click Inference "https://github.com/meta-llama/llama-stack-client-node/tree/main/src/resources/inference/"
    click Evaluate "https://github.com/meta-llama/llama-stack-client-node/tree/main/src/resources/evaluate/"
    click Memory "https://github.com/meta-llama/llama-stack-client-node/tree/main/src/resources/memory/"
    click PostTraining "https://github.com/meta-llama/llama-stack-client-node/tree/main/src/resources/post-training/"
    click Safety "https://github.com/meta-llama/llama-stack-client-node/blob/main/src/resources/safety.ts"
    click Telemetry "https://github.com/meta-llama/llama-stack-client-node/blob/main/src/resources/telemetry.ts"
    click Shims "https://github.com/meta-llama/llama-stack-client-node/tree/main/src/_shims/auto/"
    click NodeRuntime "https://github.com/meta-llama/llama-stack-client-node/blob/main/src/_shims/node-runtime.ts"
    click WebRuntime "https://github.com/meta-llama/llama-stack-client-node/blob/main/src/_shims/web-runtime.ts"
    click BunRuntime "https://github.com/meta-llama/llama-stack-client-node/blob/main/src/_shims/bun-runtime.ts"
    click Types "https://github.com/meta-llama/llama-stack-client-node/blob/main/src/_shims/manual-types.d.ts"
    click Streaming "https://github.com/meta-llama/llama-stack-client-node/blob/main/src/streaming.ts"
    click Uploads "https://github.com/meta-llama/llama-stack-client-node/blob/main/src/uploads.ts"
    click Version "https://github.com/meta-llama/llama-stack-client-node/blob/main/src/version.ts"
    click Batch "https://github.com/meta-llama/llama-stack-client-node/blob/main/src/resources/batch-inference.ts"
    click Datasets "https://github.com/meta-llama/llama-stack-client-node/blob/main/src/resources/datasets.ts"
    click Models "https://github.com/meta-llama/llama-stack-client-node/blob/main/src/resources/models.ts"
    click Shields "https://github.com/meta-llama/llama-stack-client-node/blob/main/src/resources/shields.ts"
    click Synthetic "https://github.com/meta-llama/llama-stack-client-node/blob/main/src/resources/synthetic-data-generation.ts"

    %% Styles
    classDef core fill:#2374ab
    classDef resource fill:#57a773
    classDef platform fill:#ff8c42
    classDef external fill:#808080

    %% Legend
    subgraph Legend
        CoreLegend["Core Components"]:::core
        ResourceLegend["Resource Components"]:::resource
        PlatformLegend["Platform Components"]:::platform
        ExternalLegend["External Systems"]:::external
    end
```
