AWS GenAI Use Case 9: Microservices eCommerce Chatbot (EKS)
The final architecture pattern. We take the exact same eCommerce application from Use Case 8 and rebuild it for massive, global scale using Amazon Elastic Kubernetes Service (EKS).
Architecture Overview
Instead of a single server doing everything, the monolithic application is broken down into interconnected Microservices.
- Frontend Service (Streamlit): A lightweight container that only handles the UI. If 10,000 users log in to browse, Kubernetes spins up 50 copies of this container automatically.
- Backend AI Service (FastAPI): A heavy, compute-intensive container that holds the LangChain logic and communicates with Amazon Bedrock. If only 100 users actually click the "Recommend" button, Kubernetes only spins up 2 copies of this container, saving massive amounts of money.
- Internal Routing (Kubernetes ClusterIP): The frontend service communicates with the backend AI service strictly over the internal, secured cluster network.
- AWS Application Load Balancer (Ingress): Routes public internet traffic securely to the Frontend Service.
Component Breakdown
1. terraform/ (Infrastructure as Code)
Warning: Creating a full EKS cluster via Terraform takes 15-20 minutes to physically provision and is incredibly complex.
- main.tf: Provisions the EKS Cluster, the Node Groups (EC2 worker machines), and the IAM OIDC provider so Kubernetes Pods can securely call Amazon Bedrock.
2. kubernetes/ (Manifests)
Instead of a user_data bash script, EKS requires declarative YAML manifests.
- deployment-frontend.yaml: Instructions to deploy the Streamlit UI.
- deployment-backend-ai.yaml: Instructions to deploy the FastAPI Langchain server.
3. src/ (Microservice Code)
frontend/: The Streamlit application that makes HTTP calls to the backend.backend/: The FastAPI server containing the prompt engineering logic.
4. CI/CD (.github/workflows/deploy.yml)
When code is pushed, actions build both Docker images, push them to ECR, and run kubectl apply to update the cluster.