# meta-llama/llama-stack-apps architecture

> Architecture diagram of the GitHub repository meta-llama/llama-stack-apps, 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-apps
- Repository: https://github.com/meta-llama/llama-stack-apps

## Overview

##### Project Type and Purpose
This is a full-stack application framework that demonstrates how to build AI-powered applications using the Llama Stack. The project includes multiple example applications, SDKs, and integration patterns.

##### Main Components

A. Core Infrastructure Layer:
- Llama Stack Server (Central component)
- Safety System (Llama Guard)
- Inference Engine (Llama Models)
- Tool Execution Environment

B. Client SDK Layer:
- Python Client
- Node.js Client
- Swift Client
- Kotlin Client

C. Example Applications Layer:
- DocQA Application
- Agent Store
- iOS Calendar Assistant
- Android App
- Interior Design Assistant
- Custom Tools Integration

**[Client Applications Layer]**
- ↑↓
**[Client SDKs Layer]**
- ↑↓
**[Llama Stack Server]**
- ↑↓
**[Core Services Layer]**

##### Specific Elements

a) Core Services (Bottom Layer):
- Model Inference Service (Llama 3.1)
- Safety Check Service (Llama Guard)
- Tool Execution Runtime
- Memory Bank System
- Session Management

b) Server Layer (Middle):
- API Endpoints
- Agentic System Controller
- Telemetry Service
- Session Manager

c) SDK Layer:
- Language-specific SDKs with their respective APIs
- Common Interface Definitions
- Authentication/Authorization

d) Applications Layer (Top):
- Example Applications
- Integration Patterns
- Custom Tool Implementations

##### Important Relationships to Highlight

- Flow of requests from SDKs to Server
- Safety check pipeline
- Demonstrate tool execution flow
- Memory management and context retrieval paths

##### Additional Details

- Annotations for key components like:
- Safety check flows
- Tool execution paths
- Memory bank interactions
- Model inference requests

##### Implementation Notes

- Version compatibility information
- External service dependencies (Brave Search, WolframAlpha)

##### Deployment Context

- Local development setup
- Server deployment options
- Required environment variables
- Port configurations (5000 for server, 7860 for web interface)

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles and Classes
    classDef application fill:#2196F3,stroke:#1565C0,color:white
    classDef sdk fill:#4CAF50,stroke:#388E3B,color:white
    classDef server fill:#9C27B0,stroke:#7B1FA2,color:white
    classDef core fill:#FF9800,stroke:#F57C00,color:white
    classDef api fill:#607D8B,stroke:#455A64,color:white
    classDef safety fill:#FF5252,stroke:#D32F2F,color:white

    %% Client Applications Layer
    subgraph Applications
        DocQA["DocQA Application"]:::application
        AgentStore["Agent Store"]:::application
        iOSCalendar["iOS Calendar Assistant"]:::application
        AndroidApp["Android App"]:::application
        InteriorDesign["Interior Design Assistant"]:::application
        CustomTools["Custom Tools Integration"]:::application
    end

    %% SDK Layer
    subgraph SDKs
        PythonSDK["Python Client"]:::sdk
        NodeSDK["Node.js Client"]:::sdk
        SwiftSDK["Swift Client"]:::sdk
        KotlinSDK["Kotlin Client"]:::sdk
    end

    %% Server Layer
    subgraph Server
        LlamaServer["Llama Stack Server"]:::server
        SessionMgr["Session Manager"]:::server
        TelemetryService["Telemetry Service"]:::server
        AgentController["Agentic System Controller"]:::server
    end

    %% Core Services Layer
    subgraph CoreServices
        InferenceEngine["Inference Engine<br/>(Llama 3.1)"]:::core
        SafetySystem["Safety System<br/>(Llama Guard)"]:::safety
        ToolExecution["Tool Execution<br/>Environment"]:::core
        MemoryBank["Memory Bank System"]:::core
    end

    %% Relationships
    DocQA --> PythonSDK
    AgentStore --> NodeSDK
    iOSCalendar --> SwiftSDK
    AndroidApp --> KotlinSDK
    InteriorDesign --> PythonSDK
    CustomTools --> PythonSDK

    PythonSDK --> LlamaServer
    NodeSDK --> LlamaServer
    SwiftSDK --> LlamaServer
    KotlinSDK --> LlamaServer

    LlamaServer --> SessionMgr
    LlamaServer --> TelemetryService
    LlamaServer --> AgentController

    AgentController --> SafetySystem
    AgentController --> InferenceEngine
    AgentController --> ToolExecution
    AgentController --> MemoryBank

    %% Click Events
    click DocQA "https://github.com/meta-llama/llama-stack-apps/tree/main/examples/DocQA/"
    click AgentStore "https://github.com/meta-llama/llama-stack-apps/tree/main/examples/agent_store/"
    click iOSCalendar "https://github.com/meta-llama/llama-stack-apps/tree/main/examples/ios_calendar_assistant/iOSCalendarAssistant/"
    click AndroidApp "https://github.com/meta-llama/llama-stack-apps/tree/main/examples/android_app/"
    click InteriorDesign "https://github.com/meta-llama/llama-stack-apps/tree/main/examples/interior_design_assistant/"
    click CustomTools "https://github.com/meta-llama/llama-stack-apps/tree/main/examples/custom_tools/"
    click SafetySystem "https://github.com/meta-llama/llama-stack-apps/blob/main/examples/notebooks/LlamaGuard.ipynb"
    click ToolExecution "https://github.com/meta-llama/llama-stack-apps/tree/main/examples/agents/"
    click MemoryBank "https://github.com/meta-llama/llama-stack-apps/blob/main/examples/agents/rag_with_memory_bank.py"

    %% Legend
    subgraph Legend
        L1["Application"]:::application
        L2["SDK"]:::sdk
        L3["Server Component"]:::server
        L4["Core Service"]:::core
        L5["Safety System"]:::safety
    end
```
