How johess123/ollama works
Project type and purpose
• This is a full-stack web application that lets you quickly deploy a local AI chatbot on any webpage, using Flask for the back end, JavaScript for the front end, and a Retrieval-Augmented Generation (RAG) pipeline powered by Ollama, LangChain, and ChromaDB. Its goal is to avoid sending confidential data to external LLM providers while offering easy “one-line” embedding on a webpage.
File structure
• Top-level:
• server.py, server_bot.py: Flask application entry points
• static/: contains bot.js (front-end embedding script)
• templates/: HTML templates (index.html to load the chat widget, bot.html for the chat UI)
• Other files (PDFs, tests) are artifacts/demo files, not core to the runtime
• No microservices—this is a monolithic Flask app with a clear front-end/back-end separation.
• No Docker config yet, but README mentions future Docker packaging.
Extract key architecture notes from the README
• Core components:
• Ollama (on-prem LLM host via Python SDK)
• LangChain (RAG orchestration, memory)
• ChromaDB (vector store for RAG)
• Flask (HTTP server)
• JavaScript snippet for embedding on client pages
• Optional MySQL: README lists it under “deploy Flask, MySQL, ChromaDB,” so you may include it as a relational store for user/session data if used.
Main components & interactions
a. Front-end Web Page
• A user’s browser loads index.html & bot.js
• bot.js establishes a WebSocket or HTTP POST to Flask
b. Flask Back-end (server.py & server_bot.py)
• Receives user messages from bot.js
• Calls the RAG service layer implemented with LangChain
c. RAG Service Layer (LangChain)
• Issues a query to ChromaDB vector database
• Builds context & memory for the conversation
• Sends prompt + context to Ollama LLM via Python SDK
d. ChromaDB (Vector Store)
• Stores embedded documents & their embeddings for similarity search
e. Ollama (Local LLM Host)
• Receives prompt + context over Python SDK
• Returns generated response
f. (Optional) MySQL
• Stores user profiles, session logs, or RAG metadata if implemented
g. Response flows back the same path: Ollama → LangChain → Flask → bot.js → browser UI
Architectural patterns & design principles
• Monolithic MVC-style separation:
• Models: ChromaDB, optional MySQL
• Views: Jinja2 templates (index.html, bot.html) & static JS
• Controllers: Flask routes in server.py/server_bot.py
• RAG pipeline pattern: vector store lookup + LLM generation
• Clear separation between client (JavaScript widget) and server (Flask API)
Essential elements to capture
• Clear component labels (with file/dir references where helpful)
• Optional section showing “future Docker” as a container around all back-end components