⬡ Hub
Skip to content

AWS GenAI Use Case 2: Enterprise Intranet Chatbot

An end-to-end architecture for building an internal employee chatbot using Streamlit (for the UI), LangChain (for conversational memory), and Amazon Bedrock (running advanced models like Anthropic Claude, Meta Llama, or Amazon Nova).

Architecture Overview

This is a modern, containerized web application architecture, suitable for an internal corporate tool.

  1. User Interface (Streamlit): A Python-based frontend running in a Docker container. It provides a ChatGPT-like interface where employees can ask questions.
  2. Orchestration (LangChain): The application relies on LangChain to manage "ConversationBufferMemory". Because LLMs are stateless, LangChain automatically injects the last 5 messages into the prompt secretly so the AI remembers the context of the chat.
  3. Compute (AWS AppRunner / ECS Fargate): The Streamlit Docker container is hosted on a fully managed, serverless container service. It automatically scales up when hundreds of employees log in during the morning and scales down to zero at night to save costs.
  4. AI Inference (Amazon Bedrock): The Python code securely calls Bedrock using boto3.

Component Breakdown

1. terraform/ (Infrastructure as Code)

Contains the exact AWS infrastructure required to deploy this Dockerized solution without configuring EC2 servers. - main.tf: Provisions an AWS ECR (Elastic Container Registry) repository to hold the Docker image, and the IAM Roles granting the container permission to call Bedrock.

2. src/ (Application Code)

  • app.py: The main Streamlit Python application containing the vast majority of the logic.
  • Dockerfile: Instructions for packaging the Streamlit app.
  • requirements.txt: Python dependencies (streamlit, langchain, boto3).

3. CI/CD (.github/workflows/deploy.yml)

When code is pushed, GitHub Actions automatically: 1. Logs into AWS ECR. 2. Builds the new Docker image from the Dockerfile. 3. Pushes the image to the registry.

Prerequisites for Local Testing

To run this chatbot on your laptop before deploying to AWS: 1. Ensure you have the AWS CLI installed and configured (aws configure) with credentials that have Bedrock access. 2. Install dependencies: pip install -r src/requirements.txt 3. Run the app: streamlit run src/app.py 4. Access the UI at http://localhost:8501.