AWS GenAI Use Case 8: Monolithic eCommerce Chatbot (EC2)
A traditional, monolithic deployment architecture for a Generative AI application. While Serverless (Lambda) and Containerized (AppRunner/ECS) architectures are modern best practices, many legacy enterprises still require deploying applications directly onto classic virtual machines (Amazon EC2).
Architecture Overview
This usecase builds a conversational eCommerce assistant that recommends products based on user descriptions.
- VPC & Networking: A secure Virtual Private Cloud containing public and private subnets.
- Compute (Amazon EC2): A single t3.medium Linux instance running a Python/Streamlit web application.
- Application Layer (FastAPI + Streamlit + LangChain): The web server handles HTTP requests and orchestrates GenAI logic.
- AI Inference (Amazon Bedrock): The EC2 instance securely calls Anthropic Claude 3 on Amazon Bedrock to generate product recommendations.
Component Breakdown
1. terraform/ (Infrastructure as Code)
main.tf: Provisions the VPC, Subnets, Internet Gateway, Security Groups, and the EC2 Instance itself. It includes auser_datascript that automatically installs Python, installs libraries, downloads the app code, and starts the server when the EC2 instance boots for the first time.
2. src/ (Application Code)
app.py: A combined FastAPI and Streamlit backend simulating an eCommerce recommendation engine.
3. CI/CD (Jenkinsfile)
Instead of modern GitHub Actions, this usecase features a classic Jenkinsfile. Jenkins runs inside the VPC, SSHs into the EC2 instance, pulls the latest code from Git, and restarts the systemd service.