# shubhamraut01/chatbot-using-aws-bedrock architecture

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

- Interactive diagram: https://gitdiagram.com/shubhamraut01/chatbot-using-aws-bedrock
- Repository: https://github.com/shubhamraut01/chatbot-using-aws-bedrock

## Overview

##### Project type and purpose
- This is a lightweight web application (Streamlit “single-page” app) that captures user text input in a browser UI and forwards it to an external AI service (Amazon Bedrock / Anthropic Claude) for text generation.

##### File structure
- Top-level files only; no separate “frontend” or “backend” folders.
- main.py is the Streamlit app entrypoint (the README refers to it as app.py, so treat main.py as the same).
- Pipfile / Pipfile.lock manage Python dependencies (Streamlit, boto3, etc.).
- No dedicated test or deployment directories, indicating a simple, self-contained service.

##### README for additional insights
- Confirms a Streamlit interface for real-time chat.
- Describes a generate_response(prompt) function that wraps a Bedrock API call.
- Lists prerequisites (AWS credentials, Python, Streamlit).
- Mentions future enhancements (error logging, model selection).

a. Main components
- User’s Web Browser (UI)
- Streamlit Server (main.py running in Python process)
- generate_response() function (in-code component)
- AWS Bedrock Service (external, hosting Anthropic Claude)
- AWS Credentials / AWS SDK (boto3)
- (Optional) Local environment / dependency management (Pipfile, virtual environment)

b. Relationships and interactions
1. The user enters text into the Streamlit text_input widget in their browser.
2. Streamlit server (main.py) captures the input and, on button press, invokes generate_response(prompt).
3. generate_response() uses the AWS SDK (boto3) over HTTPS to call the Bedrock API endpoint, passing credentials/region.
4. Bedrock routes the request to the Anthropic Claude model, generates a response, and returns JSON.
5. generate_response() parses the response and returns the text.
6. Streamlit updates the UI to display the generated text back to the user.

c. Architectural patterns and principles
- Single-process, event-driven web app (Streamlit handles routing & UI updates).
- Clear separation of concerns: UI logic in main.py vs. external AI service invocation in generate_response().
- Use of external, managed service (serverless-ish) for compute, minimizing local complexity.

d. Relevant technologies, frameworks, libraries
- Python 3.x
- Streamlit for UI
- boto3 (AWS SDK) for Bedrock integration
- Amazon Bedrock (Anthropic Claude)
- AWS CLI / environment for credentials & region

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Main flow
    Browser["User Web Browser"]:::local
    Streamlit["Streamlit App (main.py)"]:::local
    Generate["generate_response()"]:::code
    AWS_SDK["AWS SDK (boto3)"]:::code
    Bedrock["AWS Bedrock (Anthropic Claude)"]:::external

    Browser -->|"enter prompt"| Streamlit
    Streamlit -->|"invokes with prompt"| Generate
    Generate -->|"uses boto3"| AWS_SDK
    AWS_SDK -->|"HTTPS POST with prompt"| Bedrock
    Bedrock -->|"JSON response"| AWS_SDK
    AWS_SDK -->|"returns response"| Generate
    Generate -->|"returns text"| Streamlit
    Streamlit -->|"updates UI"| Browser

    %% Side components
    subgraph "Documentation & Environment"
        Pipfile["Pipfile"]:::docs
        PipfileLock["Pipfile.lock"]:::docs
        README["README.md"]:::docs
        Credentials["AWS Credentials"]:::code
    end

    Credentials -.-> AWS_SDK
    Pipfile --> Streamlit
    PipfileLock --> Streamlit
    README --> Streamlit

    %% Click events
    click Streamlit "https://github.com/shubhamraut01/chatbot-using-aws-bedrock/blob/main/main.py"
    click Generate "https://github.com/shubhamraut01/chatbot-using-aws-bedrock/blob/main/main.py"
    click Pipfile "https://github.com/shubhamraut01/chatbot-using-aws-bedrock/tree/main/Pipfile"
    click PipfileLock "https://github.com/shubhamraut01/chatbot-using-aws-bedrock/blob/main/Pipfile.lock"
    click README "https://github.com/shubhamraut01/chatbot-using-aws-bedrock/blob/main/README.md"

    %% Styles
    classDef local fill:#eeeeee,stroke:#333,stroke-width:1px
    classDef code fill:#d6e9fe,stroke:#333,stroke-width:1px
    classDef external fill:#dff0d8,stroke:#333,stroke-width:1px
    classDef docs fill:#fcf8e3,stroke:#333,stroke-width:1px
```
