How confluentinc/mongodb-cflt-genai-quickstart works
Project type and purpose
• This is a full-stack, cloud-native “GenAI Chatbot Quickstart” designed to help small-business-loan agents.
• It combines a single-page/frontend app (Astro + React + TypeScript), serverless back end (AWS Lambda + API Gateway WebSocket), event streaming (Confluent Cloud + Flink), a vector database (MongoDB Atlas), and AI/ML inference (Anthropic Claude via AWS Bedrock).
Main components
a. Frontend (frontend/)
• Astro pages + React components (Chat, Dashboard, Login, etc.)
• Deployed to S3 + CloudFront (via Terraform’s frontend module)
• Connects to the backend over a WebSocket API
b. API & Compute (AWS)
• API Gateway (WebSocket)
• Lambda functions:
• websocket_lambda – handles open/close/message on WS
• chat_input.py – pushes incoming user messages into Kafka topic “chat-input”
• chat_output.py – consumes enriched responses from “chat-output” topic
• kafkatrigger_lambda.py – auxiliary trigger for Kafka events if needed
• IAM, CloudWatch (logs/metrics), Secrets Manager
c. Event Stream / Processing (Confluent Cloud + Flink)
• Kafka topics: products, chat-input, chat-output
• Flink SQL jobs:
• Document indexing pipeline: ingest raw product data → summarize via Claude → embed via Titan Embed → sink connector → MongoDB Atlas vector store
• Query pipeline: embed end-user’s query → search in MongoDB → produce search results
d. Vector Database (MongoDB Atlas)
• Atlas vector search index (configured in main.tf under mongodbatlas_search_index)
• Stores embeddings & summarized documents for RAG
e. AI/ML Inference (AWS Bedrock)
• Anthropic Claude for summarization & conversational responses
• Amazon Titan Embed for vectorization
f. Infrastructure as Code (Terraform)
• Root modules under infrastructure/: backend, frontend, mongodb, confluent-cloud-cluster
• Variables, providers, outputs, scripts (deploy.sh, destroy.sh)
Relationships & data flows
• Document Indexing Flow:
1. Sample data injected into Kafka “products” topic via Flink SQL
2. Flink job reads “products” → Anthropic Claude summarization → Titan Embed → writes to “products” → Confluent Sink → MongoDB
• Chat Flow:
1. User types message in frontend → WS API Gateway → websocket_lambda
2. chat_input Lambda publishes message to Kafka “chat-input”
3. Flink pipeline reads “chat-input” → embed query → issues vector search to MongoDB → emits search results to “chat-output”
4. chat_output Lambda receives from “chat-output”, calls Claude for response generation → emits enriched chat message back over WS → frontend displays
Architectural patterns & principles
• Event-driven, asynchronous pipelines (Kafka + Flink)
• Serverless compute (Lambda + API Gateway) with auto-scaling
• Retrieval-Augmented Generation (RAG) using vector search + LLMs
• Infrastructure as Code for reproducible deployments
• Clear separation of concerns: UI, API, streaming, storage, AI services
Details to capture
• Frontend build/deploy via terraform module → CloudFront/S3
• API Gateway WebSocket → Lambda handlers
• Kafka topics & Flink SQL jobs (summarization, embedding, search)
• MongoDB Atlas vector search index
• Bedrock model calls (Anthropic Claude + Titan Embed)
• Deployment scripts (deploy.sh/destroy.sh)