# praveenr-codecrafter/random-dish-generator architecture

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

- Interactive diagram: https://gitdiagram.com/praveenr-codecrafter/random-dish-generator
- Repository: https://github.com/praveenr-codecrafter/random-dish-generator

## Overview

##### Project type and purpose
- This is a single‐page, client-side web application built with React and Vite.
- Purpose: allow end users to select a cuisine (and optionally a main ingredient), then call the Google Generative AI API to generate a random dish (name, ingredients, instructions, nutrition, time, servings).

##### File structure
- Top-level:
- package.json, vite.config.js → build & dev tooling
- index.html, public/ → static assets & HTML shell
- src/ → all React source code
- Inside src/:
- components/ → UI building blocks (Header, CuisineSelector, MainIngredient, GenerateButton, DishDisplay, ErrorMessage)
- utils/openaiService.js → service layer that wraps the external AI API call
- App.jsx, main.jsx → entry & root component wiring
- assets/, styles (App.css, index.css) → styling (Tailwind + CSS)

##### README for additional insights
- Communicates with Google Generative AI via an environment‐backed API key
- Describes the UI flow and how errors and loading states are handled

##### Detail
- Loading/error states in the flow between GenerateButton and DishDisplay/ErrorMessage

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "Client Browser"
        direction TB
        subgraph "UI Components"
            direction TB
            HEX["Header Component"]:::ui
            CSEL["CuisineSelector Component"]:::ui
            MING["MainIngredient Component"]:::ui
            GBTN["GenerateButton Component"]:::ui
            DDISP["DishDisplay Component"]:::ui
            ERR["ErrorMessage Component"]:::ui
        end
        subgraph "Service Layer"
            direction TB
            SVC["openaiService.js"]:::service
        end
    end

    subgraph "Hosting & Build"
        direction TB
        HTML["App Shell (index.html)"]:::infra
        MAIN["React Entry Point (main.jsx)"]:::infra
        APP["Root App Component (App.jsx)"]:::infra
        CSS1["Global Style (App.css)"]:::infra
        CSS2["Global Style (index.css)"]:::infra
        ASSETS["Static Assets Directory"]:::infra
        VITE["Vite Config"]:::infra
        PKG["package.json"]:::infra
        PKGL["package-lock.json"]:::infra
        GIT[".gitignore"]:::infra
        ESL["eslint.config.js"]:::infra
        README["README.md"]:::infra
    end

    GAIA["Google Generative AI API"]:::external

    HEX -->|renders| APP
    CSEL -->|selects cuisine| APP
    MING -->|inputs ingredient| APP
    GBTN -->|click Generate| SVC
    SVC -->|"HTTPS Request"| GAIA
    GAIA -->|"JSON Response"| SVC
    SVC -->|"Promise Resolved"| APP
    APP -->|updates view| DDISP
    APP -->|shows error| ERR

    HTML --> MAIN
    MAIN --> APP
    APP -.-> CSS1
    APP -.-> CSS2
    APP -.-> ASSETS

    click HTML "https://github.com/praveenr-codecrafter/random-dish-generator/blob/main/index.html"
    click MAIN "https://github.com/praveenr-codecrafter/random-dish-generator/blob/main/src/main.jsx"
    click APP "https://github.com/praveenr-codecrafter/random-dish-generator/blob/main/src/App.jsx"
    click HEX "https://github.com/praveenr-codecrafter/random-dish-generator/blob/main/src/components/Header.jsx"
    click CSEL "https://github.com/praveenr-codecrafter/random-dish-generator/blob/main/src/components/CuisineSelector.jsx"
    click MING "https://github.com/praveenr-codecrafter/random-dish-generator/blob/main/src/components/MainIngredient.jsx"
    click GBTN "https://github.com/praveenr-codecrafter/random-dish-generator/blob/main/src/components/GenerateButton.jsx"
    click DDISP "https://github.com/praveenr-codecrafter/random-dish-generator/blob/main/src/components/DishDisplay.jsx"
    click ERR "https://github.com/praveenr-codecrafter/random-dish-generator/blob/main/src/components/ErrorMessage.jsx"
    click SVC "https://github.com/praveenr-codecrafter/random-dish-generator/blob/main/src/utils/openaiService.js"
    click CSS1 "https://github.com/praveenr-codecrafter/random-dish-generator/blob/main/src/App.css"
    click CSS2 "https://github.com/praveenr-codecrafter/random-dish-generator/blob/main/src/index.css"
    click ASSETS "https://github.com/praveenr-codecrafter/random-dish-generator/tree/main/src/assets"
    click VITE "https://github.com/praveenr-codecrafter/random-dish-generator/blob/main/vite.config.js"
    click PKG "https://github.com/praveenr-codecrafter/random-dish-generator/blob/main/package.json"
    click PKGL "https://github.com/praveenr-codecrafter/random-dish-generator/blob/main/package-lock.json"
    click GIT "https://github.com/praveenr-codecrafter/random-dish-generator/blob/main/.gitignore"
    click ESL "https://github.com/praveenr-codecrafter/random-dish-generator/blob/main/eslint.config.js"
    click README "https://github.com/praveenr-codecrafter/random-dish-generator/blob/main/README.md"

    classDef ui fill:#cfe2f3,stroke:#6fa8dc,color:#073763
    classDef service fill:#d9ead3,stroke:#6aa84f,color:#274e13
    classDef external fill:#f4cccc,stroke:#e06666,color:#990000
    classDef infra fill:#e7e6e6,stroke:#888a85,color:#333333
```
