# aws-solutions/qnabot-on-aws architecture

> Architecture diagram of the GitHub repository aws-solutions/qnabot-on-aws, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/aws-solutions/qnabot-on-aws
- Repository: https://github.com/aws-solutions/qnabot-on-aws

## Overview

##### Main Components

a. User Interface Layer:
- Content Designer UI (Admin Interface)
- Chat Client UI
- Amazon Alexa Interface
- Amazon Connect Interface
- Genesys Interface

b. Authentication Layer:
- Amazon Cognito for user authentication
- IAM roles and permissions

c. API Layer:
- Amazon API Gateway for REST endpoints
- WebSocket connections for real-time chat

d. Core Processing Layer:
- Bot Fulfillment Lambda
- Lex Build Lambda
- Import/Export Lambda functions
- Schema validation Lambda
- Custom Lambda hooks

e. Storage Layer:
- Amazon OpenSearch Service (question bank)
- Amazon DynamoDB (session management)
- Amazon S3 (assets and configurations)
- AWS Systems Manager Parameter Store (settings)

f. AI/ML Services Layer:
- Amazon Lex
- Amazon Bedrock
- Amazon Kendra
- Amazon Comprehend
- Amazon Translate
- Amazon SageMaker (optional)

g. Monitoring & Logging Layer:
- Amazon CloudWatch
- Kinesis Data Firehose
- OpenSearch Dashboards

##### Important Workflows to Highlight

a. Content Management Flow:
- Admin → Content Designer UI → API Gateway → Lambda → OpenSearch
- Import/Export processes through S3

b. Chat Interaction Flow:
- User → Chat Interface → Lex → Bot Fulfillment Lambda → OpenSearch/Kendra
- Multi-language support through Amazon Translate
- LLM integration through Bedrock/SageMaker

c. Monitoring Flow:
- Lambda → CloudWatch → Kinesis → S3
- OpenSearch Dashboards for analytics

##### Version Information

- Current version number
- Supported AWS regions
- Required service versions

Remember to include the optional components (like Kendra and SageMaker) with clear indicators that they are optional, and show the alternative paths when these services are not used.

This system design should help developers understand both the overall architecture and the specific implementation details of the QnABot solution.

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph UI["User Interface Layer"]
        CD["Content Designer UI"]:::ui
        CC["Chat Client UI"]:::ui
        AX["Alexa Interface"]:::ui
        CN["Connect Interface"]:::ui
        GN["Genesys Interface"]:::ui
    end

    subgraph AUTH["Authentication Layer"]
        CG["Amazon Cognito"]:::auth
        IAM["IAM Roles"]:::auth
    end

    subgraph API["API Layer"]
        APIG["API Gateway REST"]:::api
        WS["WebSocket API"]:::api
    end

    subgraph PROC["Core Processing Layer"]
        BF["Bot Fulfillment Lambda"]:::lambda
        LB["Lex Build Lambda"]:::lambda
        IE["Import/Export Lambda"]:::lambda
        SV["Schema Validation Lambda"]:::lambda
        LH["Custom Lambda Hooks"]:::lambda
    end

    subgraph STORE["Storage Layer"]
        OS["Amazon OpenSearch"]:::storage
        DDB["Amazon DynamoDB"]:::storage
        S3["Amazon S3"]:::storage
        SSM["Parameter Store"]:::storage
    end

    subgraph AIML["AI/ML Services Layer"]
        LEX["Amazon Lex"]:::ai
        BED["Amazon Bedrock"]:::ai
        KEN["Amazon Kendra"]:::ai
        COMP["Amazon Comprehend"]:::ai
        TRANS["Amazon Translate"]:::ai
        SAGE["Amazon SageMaker"]:::ai
    end

    subgraph MON["Monitoring & Logging"]
        CW["CloudWatch"]:::monitoring
        KDF["Kinesis Firehose"]:::monitoring
        OSD["OpenSearch Dashboards"]:::monitoring
    end

    %% Connections
    UI --> APIG
    UI --> WS
    APIG --> CG
    WS --> CG
    CG --> IAM
    APIG --> PROC
    WS --> PROC
    PROC --> STORE
    PROC --> AIML
    AIML --> STORE
    PROC --> MON
    STORE --> MON

    %% Styles
    classDef ui fill:#2374ab
    classDef auth fill:#457b9d
    classDef api fill:#1b4965
    classDef lambda fill:#a8dadc
    classDef storage fill:#ffd60a
    classDef ai fill:#9b5de5
    classDef monitoring fill:#cccccc

    %% Click Events
    click CD "https://github.com/aws-solutions/qnabot-on-aws/blob/main/source/website/js/admin.vue"
    click CC "https://github.com/aws-solutions/qnabot-on-aws/blob/main/source/website/js/client.vue"
    click AX "https://github.com/aws-solutions/qnabot-on-aws/blob/main/source/website/js/components/alexa/index.vue"
    click CN "https://github.com/aws-solutions/qnabot-on-aws/blob/main/source/website/js/components/connect/index.vue"
    click GN "https://github.com/aws-solutions/qnabot-on-aws/blob/main/source/website/js/components/genesys/index.vue"
    click CG "https://github.com/aws-solutions/qnabot-on-aws/blob/main/source/templates/master/cognito/index.js"
    click BF "https://github.com/aws-solutions/qnabot-on-aws/blob/main/source/lambda/fulfillment/index.js"
    click LB "https://github.com/aws-solutions/qnabot-on-aws/blob/main/source/lambda/lex-build/index.js"
    click IE "https://github.com/aws-solutions/qnabot-on-aws/blob/main/source/lambda/import/index.js"
    click SV "https://github.com/aws-solutions/qnabot-on-aws/blob/main/source/lambda/schema/index.js"
    click LH "https://github.com/aws-solutions/qnabot-on-aws/blob/main/source/lambda/js_lambda_hook_sdk/lambda_hook_sdk/hooks.js"
    click OS "https://github.com/aws-solutions/qnabot-on-aws/blob/main/source/templates/master/opensearch/index.js"
    click DDB "https://github.com/aws-solutions/qnabot-on-aws/blob/main/source/templates/master/dynamodb/index.js"
    click LEX "https://github.com/aws-solutions/qnabot-on-aws/blob/main/source/templates/master/lex/index.js"
    click BED "https://github.com/aws-solutions/qnabot-on-aws/blob/main/source/lambda/es-proxy-layer/lib/bedrock/bedrockClient.js"
    click KEN "https://github.com/aws-solutions/qnabot-on-aws/blob/main/source/lambda/es-proxy-layer/lib/kendra.js"
    click TRANS "https://github.com/aws-solutions/qnabot-on-aws/blob/main/source/lambda/translate/index.js"
    click APIG "https://github.com/aws-solutions/qnabot-on-aws/blob/main/source/templates/master/routes/index.js"
    click WS "https://github.com/aws-solutions/qnabot-on-aws/blob/main/source/templates/master/routes/bot/index.js"
    click CW "https://github.com/aws-solutions/qnabot-on-aws/blob/main/source/templates/master/dashboard/index.js"
    click OSD "https://github.com/aws-solutions/qnabot-on-aws/blob/main/source/templates/master/opensearch/opensearch-dashboards/QnABotDashboard.json"
```
