How aws-samples/aws-genai-llm-chatbot works
Based on our analysis of the file tree and the README, this project is a full-scale AWS cloud solution that implements a GenAI Chatbot with retrieval augmented generation (RAG) capabilities. It uses AWS CDK to provision and manage infrastructure, integrates with multiple LLM providers (including Amazon Bedrock, Amazon SageMaker, third-party APIs), and includes both a robust backend API (with REST and GraphQL endpoints) and a modern React-based frontend. The overall solution is clearly segmented into infrastructure (CDK), backend logic (multiple Lambda functions and API routing), and a user interface.
Main Components
• AWS Infrastructure & Deployment Layer:
• AWS CDK constructs (referenced in files such as “cdk.json”, “lib/aws-genai-llm-chatbot-stack.ts”).
• Deployment configurations (CI/CD workflows under .github/workflows and CLI tools in the “cli” directory).
• Backend API & Business Logic:
• Chatbot API implemented under “lib/chatbot-api” with multiple Lambda functions handling different routes (applications, sessions, health checks, role management, etc.). Include the API handler, routes, resolvers, and integrations (GraphQL and REST endpoints).
• Model Interfaces and Language Model Adapters layered in “lib/model-interfaces” (with separate adapters for Amazon Bedrock, SageMaker, etc.).
• RAG Engines modules (found in “lib/rag-engines”) that support different retrieval engines (Aurora-PGVector, Kendra, OpenSearch, etc.) with functions to create workspaces and workflows.
• Authentication & Security:
• Authentication logic in “lib/authentication” including Lambda functions for updating OIDC secrets, user pool client management, etc.
• Access control tests, configurations, and supporting integration tests.
• Frontend/User Interface:
• A React application (located in “lib/user-interface/react-app”) that serves as the chatbot’s public interface. It handles pages (chat, admin, RAG-related screens) and integrates with backend API clients (API client modules in “lib/user-interface/react-app/src/common/api-client”).
• Shared and Utility Layers:
• Shared libraries, common types, utility functions and python SDK layers (under “lib/shared”), which encapsulate cross-cutting concerns such as file handling, zip bundling, and integration routines.
• Testing and Integration:
• End-to-end tests, integration tests, and various snapshot tests provided under “integtests” and “tests” directories.
Relationships and Interactions
• Directional data flows from the Frontend (React App) to the API Gateway (or directly to Lambda functions via the “chatbot-api”) to process user requests.
• How the API layer invokes various backend Lambda functions that interact with AWS services (e.g., DynamoDB tables, S3 buckets, API Gateway for GraphQL endpoints) and external AI/LLM providers.
• Interactions between the business logic and the RAG engine modules – highlighting how data import functions, workspace management, and search/retrieval workflows are triggered.
• CDK infrastructure layer that provisions these services (including Lambda functions, API endpoints, and IAM policies).
Architectural Patterns and Design Principles
• Modular and layered architecture – separate components for infrastructure management (CDK), API handling (chatbot-api), shuttling between user interface and backend services, and adapter patterns for interfacing with different LLM providers.
• Clear separation of concerns: UI components are isolated from backend logic, while backend components are segregated into authentication, message processing, and RAG engine integrations.
• Use of serverless components (Lambda functions) and microservice-like patterns for scalability and maintainability.
• Emphasis on multi-modal support as hinted by integration with both text and image/video models (Amazon Nova models support).
Relevant Technologies, Frameworks, and Libraries
• AWS CDK (for deployment and infrastructure provisioning).
• AWS Lambda, API Gateway, DynamoDB, S3, and other managed AWS services.
• React (frontend, via Vite configuration, TypeScript and modern web development practices).
• GraphQL (schema located under “lib/chatbot-api/schema”) and RESTful API patterns.
• LangChain-style integrations in “lib/model-interfaces/langchain” for language model interactions.
• Various adapter implementations for different LLM providers (Amazon Bedrock, SageMaker, etc.).
• High-level: Show frontend → API layer → backend services → AWS managed services and external LLM providers.
• Drill-down: For the backend, show separate flows for handling chatbot messaging, RAG processing, authentication flows, and model interfacing.
• Significant components discussed in the file structure (like “lib/chatbot-api”, “lib/model-interfaces”, “lib/rag-engines”, “lib/user-interface”) are represented.
• Optionally, include key deployment paths and CI/CD pipelines (referenced in .github/workflows) to capture the operational aspect.