How aws-samples/bedrock-chat works
Project type and purpose
• This is a full-stack, serverless generative AI chat platform (“Bedrock Chat”) built on AWS managed services.
• Purpose: provide multilingual chat, custom bots with retrieval-augmented generation (RAG), bot sharing/store, API publication, and agent-based task automation, all powered by Amazon Bedrock.
File structure
• Top-level directories:
• backend/ – FastAPI app, agents, repositories, use-cases, Lambda handlers, tests
• frontend/ – React + TypeScript UI, components, features, i18n, Vite/Tailwind, Ladle stories
• cdk/ – AWS CDK stacks and constructs for provisioning all AWS resources
• scripts/ – utility scripts (doc translation, cross-region inference)
• Infra configuration: cdk.json, parameter.ts, GitHub workflows, Dockerfiles, run.sh, bin.sh
• Patterns:
• Frontend-Backend separation
• Serverless microservices with Lambda, API Gateway, DynamoDB, EventBridge Pipes + Step Functions
• RAG pipeline orchestration
• Infrastructure as code using CDK
README for additional insights
• Lists AWS services and how they fit (DynamoDB, Lambda + API Gateway + Web Adapter, CloudFront + S3, Cognito, WAF, Bedrock, Bedrock KB, EventBridge Pipes, Step Functions, OpenSearch Serverless, Athena)
• Includes a high-level architecture image
Components
a. Main components
• User Client / Browser (React SPA)
• Amazon CloudFront + S3 (hosting the frontend)
• Amazon Cognito (authentication & user pools)
• Amazon API Gateway (REST API front door)
• AWS Lambda (FastAPI backend, SQS consumer, embedding statemachine Lambdas)
• Amazon DynamoDB (conversation history, metadata)
• Amazon S3 (storing documents, KB exports)
• Amazon EventBridge Pipes (DynamoDB stream → state machine trigger)
• AWS Step Functions (orchestrate embedding pipeline)
• Amazon Bedrock (LLM inference)
• Amazon Bedrock Knowledge Bases (RAG embedding store)
• Amazon OpenSearch Serverless (vector & full-text search)
• Amazon Athena (analytics over S3 logs/data)
• AWS WAF (IP-restriction on CloudFront)
• AWS CDK (IaC) / CodeBuild pipelines (deployment)
b. Relationships & data flows
1. User logs in via CloudFront → Cognito (OAuth flow)
2. Authenticated React app calls API Gateway (passes JWT)
3. API Gateway invokes Lambda (FastAPI)
– Chat endpoints call Bedrock inference + vector_search + repositories on DynamoDB
– Bot store / publication endpoints manage metadata in DynamoDB / OpenSearch
4. Conversation writes to DynamoDB → DynamoDB stream → EventBridge Pipes → Step Functions → Lambda functions → embed docs into Bedrock KB & OpenSearch
5. Frontend assets are served from S3/CloudFront behind WAF
6. CDK scripts deploy all the above via CodeBuild / CloudFormation
c. Architectural patterns & principles
• Serverless microservices: stateless Lambdas behind API Gateway
• RAG pipeline: event-driven via DB streams + state machine
• Separation of concerns: UI, API layer, compute, data storage, search, orchestration
• Infrastructure as code: CDK constructs organized per service domain
• Multi-region / cross-region inference configurable
d. Technologies / frameworks
• React + Vite + TypeScript + Tailwind (frontend)
• FastAPI + aws-lambda-web-adapter + Python (backend)
• boto3, Amazon Bedrock SDK for LLM & KB
• DynamoDB, S3, OpenSearch Serverless, Athena
• Cognito, API Gateway, Lambda, EventBridge Pipes, Step Functions, WAF
• AWS CDK (TypeScript)