# viktoriasemaan/sa-ai-agent architecture

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

- Interactive diagram: https://gitdiagram.com/viktoriasemaan/sa-ai-agent
- Repository: https://github.com/viktoriasemaan/sa-ai-agent

## Overview

##### Main System Components

a) Core Components:
- Amazon Bedrock Agent (Central orchestrator)
- Three Tool Services:
- Knowledge Base Q&A Tool
- IaC Generation Tool
- Cost Estimation Tool
- Lambda Function Container
- Supporting AWS Services (S3, ECR)

b) External Components:
- InfraCost Integration
- Claude 3.5 Sonnet Model
- Knowledge Base Sources

##### Key Interactions to Highlight

a) Knowledge Base Flow:
- Web crawler data ingestion
- S3 document storage
- Vector embedding process
- Query processing

b) IaC Generation Flow:
- User request processing
- Claude model interaction
- Terraform code generation
- S3 storage of generated code

c) Cost Estimation Flow:
- InfraCost container execution
- Cost analysis processing
- Results storage and presentation

##### Important Details

- Security boundaries (IAM roles and permissions)
- API endpoints and interfaces
- Environment variables and configuration points
- Docker container composition
- Lambda function configuration

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph "User Interface Layer"
        UI[User Interface]
        API["OpenAPI Specification"]:::api
    end

    subgraph "Processing Layer"
        BA[Amazon Bedrock Agent]
        
        subgraph "Lambda Container"
            LC["Lambda Function"]:::lambda
            
            subgraph "Tool Services"
                KBT["Knowledge Base Q&A Tool"]:::tool
                IGT["IaC Generation Tool"]:::tool
                CET["Cost Estimation Tool"]:::tool
            end
            
            DC["Docker Container"]:::docker
        end
    end

    subgraph "Services Layer"
        CL["Claude 3.5 Sonnet"]:::aws
        S3["S3 Storage"]:::aws
        ECR["Amazon ECR"]:::aws
    end

    subgraph "External Services"
        IC["InfraCost"]:::external
        KB["Knowledge Base Sources"]:::external
    end

    %% Connections
    UI --> |Request| API
    API --> |Forward| BA
    BA --> |Invoke| LC
    LC --> |Execute| KBT
    LC --> |Execute| IGT
    LC --> |Execute| CET
    
    KBT --> |Query| KB
    KBT --> |Store| S3
    
    IGT --> |Generate| CL
    IGT --> |Store Code| S3
    
    CET --> |Analyze| IC
    CET --> |Store Results| S3
    
    DC --> |Deploy| ECR
    ECR --> |Pull| LC

    %% Click Events
    click API "https://github.com/viktoriasemaan/sa-ai-agent/blob/main/agent_aws_openapi.json"
    click LC "https://github.com/viktoriasemaan/sa-ai-agent/blob/main/index.py"
    click DC "https://github.com/viktoriasemaan/sa-ai-agent/tree/main/Dockerfile"
    click KBT "https://github.com/viktoriasemaan/sa-ai-agent/blob/main/tools.py"
    click IGT "https://github.com/viktoriasemaan/sa-ai-agent/blob/main/tools.py"
    click CET "https://github.com/viktoriasemaan/sa-ai-agent/blob/main/tools.py"
    click CET "https://github.com/viktoriasemaan/sa-ai-agent/blob/main/cost-test/main.tf"

    %% Styling
    classDef aws fill:#FF9900,stroke:#232F3E,color:white
    classDef tool fill:#3B82F6,stroke:#1D4ED8,color:white
    classDef external fill:#6B7280,stroke:#374151,color:white
    classDef docker fill:#2496ED,stroke:#0B4F6C,color:white
    classDef lambda fill:#FF9900,stroke:#232F3E,color:white
    classDef api fill:#10B981,stroke:#065F46,color:white

    %% Legend
    subgraph Legend
        L1[AWS Services]:::aws
        L2[Tool Services]:::tool
        L3[External Services]:::external
        L4[Docker Components]:::docker
        L5[API Components]:::api
    end
```
