How aws-samples/rag-with-amazon-bedrock-and-pgvector works
This repository is an AWS-hosted RAG sample: users authenticate and ask questions in a Streamlit app, which retrieves relevant PGVector content and generates answers with Amazon Bedrock. A separate ingestion workflow turns knowledge-base PDFs into indexed vectors. The README documents the ingestion stages and AWS hosting/authentication; sampled code confirms key app, queue, and database-update behavior, but not every infrastructure connection.
Main entry points: app.py Vector index updater · pgvec_chat_bedrock.py Bedrock chat chain · lambda_function.py PDF text extraction · base-infra-stack.ts HTTPS load balancer
Components 22
Question answering
- Streamlit RAG app
rag-app/app.py - Bedrock chat chain
rag-app/pgvec_chat_bedrock.py - PGVector on RDS
lib/rds-stack.ts
Document ingestion
- PDF knowledge bucket
lib/base-infra-stack.ts - PDF text extraction
lambda/pdf-processor/lambda_function.py - Processed text bucket
lib/base-infra-stack.ts - Indexing event trigger
lambda/pgvector-trigger/app.py - Indexing queue
lib/base-infra-stack.ts - Vector index updater
lambda/pgvector-update/app.py
AWS platform
- HTTPS load balancer
lib/base-infra-stack.ts - Cognito authentication
lib/base-infra-stack.ts - Cognito client trigger
lambda/app-client-create-trigger/app.py - Callback URL setup
lambda/call-back-url-init/app.py - Callback URL updater
lambda/call-back-url-update/app.py
Database provisioning
- DDL source bucket
lib/ddl-source-rds-stack.ts - RDS create trigger
lambda/rds-ddl-trigger/app.py - RDS DDL queue
lib/base-infra-stack.ts - DDL automation
lambda/rds-ddl-init/app.py - DDL change handler
lambda/rds-ddl-change/app.py
Other components
- User
- Amazon Bedrock
- OpenAI embeddings
Connections 23
- User → HTTPS load balancer: HTTPS request
- HTTPS load balancer → Cognito authentication: authenticates
- HTTPS load balancer → Streamlit RAG app: routes traffic
- Streamlit RAG app → Bedrock chat chain: runs chain
- Bedrock chat chain → PGVector on RDS: retrieves context
- Bedrock chat chain → Amazon Bedrock: generates answer
- User → PDF knowledge bucket: uploads PDFs
- PDF knowledge bucket → PDF text extraction: object event
- PDF text extraction → PDF knowledge bucket: reads PDF
- PDF text extraction → Processed text bucket: writes extracted text
- Processed text bucket → Indexing event trigger: object event
- Indexing event trigger → Indexing queue: queues file reference
- Indexing queue → Vector index updater: dispatches message
- Vector index updater → Processed text bucket: loads text
- Vector index updater → OpenAI embeddings: creates embeddings
- Vector index updater → PGVector on RDS: adds documents
- RDS create trigger → RDS DDL queue: queues database details
- RDS DDL queue → DDL automation: dispatches message
- DDL automation → DDL source bucket: reads SQL source
- DDL automation → DDL change handler: applies database changes
- Cognito client trigger → RDS DDL queue: queues client details
- Callback URL setup → Cognito authentication: configures callback
- Callback URL updater → Cognito authentication: updates callback