How waleed719/fitness-chatbot works
Project type and purpose
• This is a monolithic, single‐page web application built with Python and Streamlit.
• Purpose: provide an interactive AI Fitness Chatbot UI that accepts user questions, looks up predefined FAQs, or forwards questions to Google’s Gemini LLM via an HTTP API, then displays the response.
• It runs as one process (the Streamlit app) and has no internal database—knowledge comes either from a built-in dictionary or from the external LLM service.
File structure
• Top‐level artifacts:
• streamlit_app.py (main application entry point)
• requirements.txt & runtime.txt (dependency list and runtime spec for deployment e.g., Heroku)
• Procfile (Heroku or similar process launcher)
• .devcontainer/devcontainer.json (VS Code dev‐container configuration)
• .gitignore (source control)
• No “frontend” vs “backend” folders—the Streamlit script combines UI rendering and business logic.
• No database or persistence layers to represent.
• Configuration/environment management via python-dotenv (expects a .env file with GEMINI_API_KEY).
README for additional insights
• Confirms the use of:
• Streamlit for UI
• httpx for asynchronous HTTP calls to the Google Gemini API
• python-dotenv for loading secrets
• No mention of other microservices, queues, or caching layers.
• Deployment targets: Streamlit Community Cloud or a generic VM (Heroku example given).
Core components
a. User Client (Web Browser)
b. Streamlit App Server
– UI Component (Streamlit widgets & pages)
– Business Logic Component (input routing, FAQ lookup, LLM orchestration)
– Environment Loader (python-dotenv reading GEMINI_API_KEY)
c. Local FAQ Data Store (in‐memory Python dictionary)
d. External Service: Google Gemini LLM API
e. Deployment Environment (Heroku Dyno or Streamlit Cloud / VM / Container)
Relationships and data flows
1. User enters a question in the browser UI.
2. Streamlit server receives the request and passes it to the business logic layer.
3. Business logic checks the FAQ dictionary:
– If a match → returns static answer.
– Else → issues an HTTP request (via httpx, using the GEMINI_API_KEY) to the Gemini API.
4. Gemini API returns a generated response → business logic processes it → UI renders the answer back to the user.
5. All components run within the same process/container; secrets are injected at startup by python-dotenv.
Architectural patterns & principles
• Monolithic single‐process architecture—no microservices or database tiers.
• Separation of concerns within the script: UI vs business logic vs external API integration.
• Safe defaults: system prompts and disclaimers encoded in the logic.
• Externalization of secrets via .env.
Essential elements
• Clear component labels (e.g., “Streamlit App Server”, “Google Gemini API”).
• A border or grouping to denote the single deployment unit (the Streamlit process/Heroku dyno).