# mripradhan/bitebot-recipe-generator architecture

> Architecture diagram of the GitHub repository mripradhan/bitebot-recipe-generator, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-24). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/mripradhan/bitebot-recipe-generator
- Repository: https://github.com/mripradhan/bitebot-recipe-generator

## Overview

##### Project type and purpose
- BiteBot is a monolithic Python web application built on Streamlit.
- Purpose: provide a browser-based UI for users to input ingredients, equipment, cuisine, time, and dietary restrictions, then generate custom recipes via the Groq AI API and optionally fetch nutritional data from API Ninjas.

##### File structure
- Top level:
- bitebot.py – the entire Streamlit UI + business logic in one module
- requirements.txt – Python dependencies (Streamlit, Groq client, python-dotenv, API Ninjas client, etc.)
- .env (user-created) – stores GROQ_API_KEY and optional NINJAS_API_KEY
- README.md / LICENSE – documentation and license
- No subdirectories or local databases—external services are the only “backends.”

##### Key insights from README
- Stack: Python 3.8+, Streamlit for UI, python-dotenv for config, Groq API (LLaMA-3 70B) for recipe generation, API Ninjas for nutrition.
- UX: pastel-themed responsive UI, quick “streamlit run app.py” startup.

##### Main components & their interactions
a. User’s Browser (client)
b. Streamlit Application (bitebot.py)
- UI Layer: input fields, selection widgets, buttons, display panels
- Controller/Logic Layer: reads inputs, calls service functions
c. Configuration Loader
- python-dotenv reads .env → injects GROQ_API_KEY, NINJAS_API_KEY into environment
d. External Services
1. Groq AI API – generates recipe text given ingredients + parameters
2. API Ninjas Nutrition API – returns nutritional analysis for main ingredients
e. (Optional) Logging / Error Handling – simple print/log statements

##### Relationships & data flows
1. Browser → Streamlit UI: user inputs
2. UI → Controller: on button click, pass input data
3. Controller → Config Loader: retrieve API keys
4. Controller → Groq API: submit generation request → receives recipe
5. Controller → API Ninjas: if nutrition enabled → receives nutrition data
6. Controller → UI: render recipe steps + nutrition panel back to browser

##### Architectural patterns & principles
- Monolith with logical separation (View/Controller/Service)
- Single-process, event-driven Streamlit server
- Externalize secrets via dotenv (12-factor config)
- Externalize compute and data to third-party APIs—no own DB/storage

1. Sketch the user’s browser at the left.
– Top: UI Layer (input widgets, display panels)
– Bottom: Controller/Service Layer (functions that orchestrate API calls)
– Groq AI API
– API Ninjas Nutrition API
– Browser → UI Layer
– UI Layer → Controller
– Controller → Config Loader (gets keys)
– Controller → Groq API → Controller
– Controller → API Ninjas → Controller
– Controller → UI Layer → Browser
6. Component: list key technologies (Streamlit, python-dotenv, Groq client, API Ninjas).

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Nodes
    Browser(["User's Browser"]):::external

    subgraph "Streamlit App (bitebot.py)"
        direction TB
        UI["UI Layer\n(Streamlit widgets)"]:::ui
        Controller["Controller/Logic Layer\n(API orchestration)"]:::logic
    end

    ConfigLoader["Config Loader\n(python-dotenv)"]:::config

    GroqAPI["Groq AI API\n(recipe generation)"]:::external
    NinjasAPI["API Ninjas Nutrition API\n(nutrition data)"]:::external

    subgraph "Project Files"
        Requirements["requirements.txt"]:::docs
        README["README.md"]:::docs
        License["LICENSE"]:::docs
    end

    %% Connections
    Browser -->|"user inputs"| UI
    UI -->|"on submit: input data"| Controller
    Controller ---|"load keys"| ConfigLoader
    Controller -->|"recipe request"| GroqAPI
    GroqAPI -->|"recipe response"| Controller
    Controller -->|"nutrition request"| NinjasAPI
    NinjasAPI -->|"nutrition response"| Controller
    Controller -->|"render recipe & nutrition"| UI
    UI -->|"display results"| Browser

    %% Click Events
    click UI "https://github.com/mripradhan/bitebot-recipe-generator/blob/main/bitebot.py"
    click Controller "https://github.com/mripradhan/bitebot-recipe-generator/blob/main/bitebot.py"
    click ConfigLoader "https://github.com/mripradhan/bitebot-recipe-generator/blob/main/bitebot.py"
    click GroqAPI "https://github.com/mripradhan/bitebot-recipe-generator/blob/main/bitebot.py"
    click NinjasAPI "https://github.com/mripradhan/bitebot-recipe-generator/blob/main/bitebot.py"
    click Requirements "https://github.com/mripradhan/bitebot-recipe-generator/blob/main/requirements.txt"
    click README "https://github.com/mripradhan/bitebot-recipe-generator/blob/main/README.md"
    click License "https://github.com/mripradhan/bitebot-recipe-generator/tree/main/LICENSE"

    %% Styles
    classDef ui fill:#c6f5c6,stroke:#4c9f4c,color:#000
    classDef logic fill:#c6d8f5,stroke:#4a7abf,color:#000
    classDef external fill:#f5d6c6,stroke:#bf5714,color:#000
    classDef config fill:#e0e0e0,stroke:#909090,color:#000
    classDef docs fill:#f0e0ff,stroke:#9070bf,color:#000
```
