# awslabs/ask-bedrock architecture

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

- Interactive diagram: https://gitdiagram.com/awslabs/ask-bedrock
- Repository: https://github.com/awslabs/ask-bedrock

## Overview

##### Main Components

a) Client-Side Components:
- CLI Interface Layer
- Configuration Manager (handling ~/.config/ask-bedrock/config.yaml)
- Conversation Handler
- AWS Credentials Manager

b) External Services:
- Amazon Bedrock Service
- AWS CLI/Credentials
- Langchain Integration

##### User Interface Layer
- Two main commands: "converse" and "prompt"

##### Application Layer
- Configuration Management
- Conversation State Management
- AWS Profile Management

##### Integration Layer
- Langchain Integration
- AWS SDK Integration

##### External Services Layer
- Amazon Bedrock
- AWS Authentication

##### Important Details

Annotations for:
- Python version requirement (≥3.9)
- Configuration file location
- Supported model types
- AWS region requirements
- Model parameter handling

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Styles
    classDef cli fill:#2196F3,stroke:#1565C0,color:white
    classDef config fill:#FFC107,stroke:#FFA000,color:black
    classDef aws fill:#4CAF50,stroke:#388E3B,color:white
    classDef storage fill:#9E9E9E,stroke:#616161,color:white
    classDef integration fill:#9C27B0,stroke:#7B1FA2,color:white
    classDef core fill:#2196F3,stroke:#1565C0,color:white

    %% User Interface Layer
    subgraph UI
        User((User))
        CLI["CLI Interface"]
        Commands{"Commands<br/>converse | prompt"}
    end

    %% Application Layer
    subgraph AppLayer
        ConfigMgr["Configuration Manager"]
        ConvoHandler["Conversation Handler"]
        AWSCredMgr["AWS Credentials Manager"]
        ConfigFile[("Local Config File<br/>~/.config/ask-bedrock/")]
    end

    %% Integration Layer
    subgraph IntegrationLayer
        Langchain["Langchain Integration"]
        AWSSDK["AWS SDK"]
    end

    %% External Services
    subgraph ExternalServices
        Bedrock["Amazon Bedrock"]
        AWSAuth["AWS Authentication"]
    end

    %% Relationships
    User --> CLI
    CLI --> Commands
    Commands --> ConvoHandler
    CLI --> ConfigMgr
    ConfigMgr --> ConfigFile
    ConvoHandler --> Langchain
    Langchain --> Bedrock
    AWSCredMgr --> AWSAuth
    AWSAuth --> Bedrock
    AWSSDK --> Bedrock

    %% Click Events
    click CLI "https://github.com/awslabs/ask-bedrock/blob/main/ask_bedrock/main.py"
    click ConfigMgr "https://github.com/awslabs/ask-bedrock/blob/main/pyproject.toml"
    click ConvoHandler "https://github.com/awslabs/ask-bedrock/blob/main/ask_bedrock/__init__.py"
    click Bedrock "https://github.com/awslabs/ask-bedrock/blob/main/model_params_examples.md"
    click AWSAuth "https://github.com/awslabs/ask-bedrock/blob/main/.github/workflows/publish.yaml"

    %% Styling Classes
    class CLI cli
    class ConfigMgr,ConfigFile config
    class Bedrock,AWSAuth aws
    class ConfigFile storage
    class Langchain integration
    class ConvoHandler,AWSCredMgr,AWSSDK core

    %% Legend
    subgraph Legend
        L1["CLI Components"]:::cli
        L2["Configuration"]:::config
        L3["AWS Services"]:::aws
        L4["Storage"]:::storage
        L5["Integrations"]:::integration
        L6["Core Components"]:::core
    end
```
