How entbappy/build-a-complete-medical-chatbot-with-llms-langchain-pinecone-flask-aws works
Main architectural layers and components
a. Data Ingestion & Indexing
• store_index.py reads Medical_book.pdf, converts to embeddings via LangChain/OpenAI, and pushes vectors to Pinecone.
b. Backend/API Layer
• app.py (Flask app) exposes endpoints (e.g., /chat) that receive user messages, call the LangChain prompt logic, query Pinecone, and fetch OpenAI completions.
• src/helper.py & src/prompt.py encapsulate prompt templates and helper functions.
c. Frontend/UI Layer
• templates/chat.html renders the chat interface; static/style.css provides styling.
d. External Services
• OpenAI API for LLM completions
• Pinecone for vector database
e. Infrastructure & CI/CD
• Dockerfile builds a container image of the Flask app + dependencies.
• GitHub Actions workflow (.github/workflows/cicd.yaml) builds the image, pushes to AWS ECR, and triggers deployment on an EC2 self-hosted runner.
Relationships and data flows
• User → HTTP → Flask endpoint
• Flask → Pinecone (vector search)
• Flask → OpenAI (text completion)
• store_index.py → LangChain/OpenAI → Pinecone (initial indexing)
• GitHub Actions → build Docker → push to ECR → EC2 pulls image → Docker run
Architectural patterns & technologies
• Monolithic Flask service with modular helper/prompt packages (MVC-style separation).
• Batch indexing component separate from runtime (store_index script).
• Dockerized deployment with AWS ECR + EC2 (self-hosted runner).
• CI/CD via GitHub Actions.
Capturing essential details without overthinking
• Major modules: store_index.py, app.py, src/, templates/, static/, Dockerfile, GitHub Actions.
• Don’t dive into every helper function—group them logically.
• Reflects the separation of concerns (ingestion vs. runtime vs. UI).
• Illustrates interactions among modules and external services.
• Includes infrastructure and CI/CD elements.
This will ensure the architecture is both accurate and communicative for stakeholders and future contributors.