AWS GenAI Use Case 4: Serverless e-Learning Tutor
An end-to-end serverless architecture that builds an intelligent AI Tutor. It uses Amazon Bedrock Knowledge Bases (a fully managed RAG service) to ingest university course materials and strictly answer student questions based only on the syllabus.
Architecture Overview
Unlike Use Case 3 (which used a manual LangChain+FAISS implementation in a Docker container), this architecture offloads all the heavy lifting to AWS managed services.
- Document Ingestion (S3 to Knowledge Base): Course syllabi and lecture transcripts are dropped into an S3 bucket. Amazon Bedrock Knowledge Bases automatically detects the new files, chunks them, embeds them using Amazon Titan, and syncs them into an OpenSearch Serverless vector database. No LangChain code is required for ingestion!
- User Request (API Gateway): A student on the university's frontend website asks a question. The website sends an HTTP POST request to API Gateway.
- Compute (AWS Lambda): API Gateway triggers a lightweight Lambda function.
- Retrieval & Generation (Bedrock
RetrieveAndGenerateAPI): The Python Lambda function makes a single API call to Bedrock. Bedrock autonomously searches the OpenSearch database, retrieves the transcripts, formats the prompt, asks Claude 3, and returns the final coherent answer to the Lambda. - Response: Lambda returns the HTTP JSON back to the student's website.
Component Breakdown
1. terraform/ (Infrastructure as Code)
Warning: Provisioning a Bedrock Knowledge Base and OpenSearch Serverless cluster via Terraform is highly complex involving intricate IAM roles and data access policies. main.tf sets up the Lambda, API Gateway, and necessary permissions, assuming the Knowledge Base has been configured in the Console (Standard AWS practice for KB).
2. src/ (Application Code)
lambda_handler.py: The serverless computing logic handling theRetrieveAndGeneratecommand.
3. CI/CD (.github/workflows/deploy.yml)
Automates the packaging of the Lambda function and the Terraform infrastructure deployment.