How mayank29madan/recipe_chatbot works
• Frontend/UI:
• Templates: The “templates” folder contains the “chat.html” file, which is the user-facing chat interface.
• Static Assets: The “static” directory contains subdirectories like “images” and “style.css” for look and feel.
• Backend/API:
• Core Application Logic: The “app.py” file likely serves as the main entry point, handling HTTP requests from the frontend.
• Helper Modules: The “src” directory contains modules such as “helper.py” and “prompt.py” to manage business logic, prompt processing for the LLM, and possibly interactions with other services.
• Additional Scripts: Files like “store_index.py” and “template.py” indicate processes for setting up or managing the vector index or other template-related functionalities.
• Database/Vector Store:
• MongoDB Atlas Vector Database: As mentioned in the README, this external service stores preprocessed recipe embeddings (or vectors) for efficient similarity search.
• Data Sources and Research:
• Data Files: The “Data” directory holds CSV files with recipe data, which are probably used to seed or update the vector database.
• Research and Experimentation: The “Research” directory contains notebooks and scripts (e.g., “mongodb_trials.ipynb”, “vector-index.py”) that were used during exploration and the development of the vector-based search functionalities.
• Dependencies and Configuration:
• Setup Scripts: “setup.py” and “requirements.txt” manage dependencies and environment settings.
• License and Git configurations: “.gitignore”, “LICENSE”, etc. ensure a proper development environment.
Relationships and Interactions
• User Interaction:
• A user accesses the chat interface (chat.html) served by the backend (app.py) and static files, sending recipe-related queries.
• Request Handling:
• The backend receives the query through HTTP endpoints (likely defined in app.py) and uses helper modules in the “src” folder to process the incoming message.
• Language Model and Query Processing:
• Using LangChain integrated with the LLaMA2 model, the backend processes the query.
• It may use “prompt.py” to format the prompt for the LLM and “helper.py” to handle additional logic.
• Data Retrieval:
• When necessary, the backend interacts with MongoDB Atlas Vector Database to perform semantic searches over the stored recipe embeddings, which could have been initially generated using data from the CSV files in the “Data” directory.
• The “store_index.py” file likely supports building and maintaining this vector index.
• Response Generation:
• The results from the vector database and LLM processing are then combined and formatted as a response sent back to the chat interface.
• Feedback/Monitoring or Ongoing Improvements:
• “Research” folder artifacts indicate that the development and tuning of these interactions (e.g., vector index performance) were monitored and further refined using Jupyter notebooks and experimental scripts.
Architectural Patterns and Design Principles
• Clearly separated concerns:
• The frontend (UI/UX) is decoupled from the backend logic.
• Business logic and LLM/prompt processing are modularized in the “src” directory.
• External Service Integration:
• The system neatly integrates with external services such as MongoDB Atlas for vector search.
• Use of LangChain abstracts the language model interactions.
• Data-driven Design:
• Data ingestion is externalized into CSV files, and experiments were rigorously documented in the “Research” directory.
Final Advice
• Be incredibly detailed—ensure every key file/folder that contributes to a functional or infrastructural piece of the system is represented.
• Do not hesitate to break down the system into as many components as necessary. The idea is to capture the core flow: receiving a user recipe query, processing it through a language model assisted by LangChain, querying a vector database, and sending the answer back to the user.