# sinha-19/smart-recipe-ai architecture

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

- Interactive diagram: https://gitdiagram.com/sinha-19/smart-recipe-ai
- Repository: https://github.com/sinha-19/smart-recipe-ai

## Overview

##### Project type and purpose
- This is a single-page web application (SPA) built with React 18, TypeScript, and Tailwind CSS.
- Its primary purpose is to let users discover recipes (via the Spoonacular API), save favorites, and plan weekly meals in a responsive, dark-mode-friendly UI.

##### File structure
- Top-level:
- public/index.html – SPA entry point
- src/main.tsx – mounts React App
- src/App.tsx – root component with Router & context providers
- src/components/ – reusable UI building blocks (Header, Footer, RecipeCard, etc.)
- src/pages/ – top-level route components (Home, MealPlanner, SavedRecipes, About)
- src/contexts/ – React Context providers (ThemeContext, RecipeContext)
- src/services/apiService.ts – encapsulates all network calls to Spoonacular
- src/types/ – shared TypeScript definitions
- Build and config: vite.config.ts, tsconfig*.json, postcss.config.js, tailwind.config.js, eslint.config.js

##### README for additional insights
- No backend—state and persistence are client-side via Context (and likely localStorage).

##### Details
- A small side panel for build/deploy: Vite build → static bundle → Vercel (or similar)

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Start user interaction
    User["User"]:::external
    Browser["Browser"]:::external

    User -->|"interacts with"| Browser

    subgraph "Development & Build" 
        direction TB
        ViteConfig["vite.config.ts"]:::config
        TailwindConfig["tailwind.config.js"]:::config
        PostCSS["postcss.config.js"]:::config
        TSConfig["tsconfig.json\n(tsconfig.app.json,\ntsconfig.node.json)"]:::config
        ESLint["eslint.config.js"]:::config
    end

    subgraph "Static Host / Entry Point"
        direction TB
        IndexHTML["public/index.html"]:::ui
    end

    Browser -->|"loads"| IndexHTML
    IndexHTML -->|serves SPA| ViteConfig

    subgraph "SPA Initialization"
        direction TB
        MainTS["src/main.tsx"]:::ui
        AppTS["src/App.tsx"]:::ui
    end

    IndexHTML -->|"script src"| MainTS
    MainTS -->|"renders"| AppTS

    subgraph "Application Layers"
        direction TB

        subgraph "UI Components" 
            direction TB
            Header["Header\nsrc/components/Header.tsx"]:::ui
            Footer["Footer\nsrc/components/Footer.tsx"]:::ui
            RecipeCard["RecipeCard\nsrc/components/RecipeCard.tsx"]:::ui
            IngredientInput["IngredientInput\nsrc/components/IngredientInput.tsx"]:::ui
            Layout["Layout Wrapper\nsrc/components/Layout.tsx"]:::ui
            EmptyState["EmptyState\nsrc/components/EmptyState.tsx"]:::ui
            LoadingState["LoadingState\nsrc/components/LoadingState.tsx"]:::ui
        end

        subgraph "Pages (Routes)"
            direction TB
            Home["Home Page\nsrc/pages/Home.tsx"]:::ui
            MealPlanner["MealPlanner Page\nsrc/pages/MealPlanner.tsx"]:::ui
            SavedRecipes["SavedRecipes Page\nsrc/pages/SavedRecipes.tsx"]:::ui
            About["About Page\nsrc/pages/About.tsx"]:::ui
        end

        subgraph "Context Layer"
            direction TB
            RecipeContext["Recipe Context\nsrc/contexts/RecipeContext.tsx"]:::context
            ThemeContext["Theme Context\nsrc/contexts/ThemeContext.tsx"]:::context
        end

        subgraph "Service Layer"
            direction TB
            APIService["apiService.ts\nsrc/services/apiService.ts"]:::service
        end

        LocalStorage["localStorage"]:::storage
        Spoonacular["Spoonacular API"]:::external
    end

    %% Navigation flow
    AppTS -->|"Router"| Home
    AppTS --> MealPlanner
    AppTS --> SavedRecipes
    AppTS --> About

    %% Layout composition
    Home --> Layout
    MealPlanner --> Layout
    SavedRecipes --> Layout
    About --> Layout

    Layout --> Header
    Layout --> Footer
    Layout --> RecipeCard
    Layout --> IngredientInput
    Layout --> EmptyState
    Layout --> LoadingState

    %% Data flow
    Header -->|"consumes theme"| ThemeContext
    Layout -->|"consumes theme"| ThemeContext
    RecipeCard -->|"gets recipes"| RecipeContext
    IngredientInput -->|"dispatch search"| RecipeContext

    ThemeContext -->|"read/write theme"| LocalStorage
    RecipeContext -->|"read/write data"| LocalStorage

    RecipeContext -->|"fetchRecipes()"| APIService
    APIService -->|"HTTP requests"| Spoonacular
    Spoonacular -->|"responses"| APIService
    APIService -->|"returns data"| RecipeContext

    %% Click events
    click ViteConfig "https://github.com/sinha-19/smart-recipe-ai/blob/master/vite.config.ts"
    click TailwindConfig "https://github.com/sinha-19/smart-recipe-ai/blob/master/tailwind.config.js"
    click PostCSS "https://github.com/sinha-19/smart-recipe-ai/blob/master/postcss.config.js"
    click TSConfig "https://github.com/sinha-19/smart-recipe-ai/blob/master/tsconfig.json"
    click ESLint "https://github.com/sinha-19/smart-recipe-ai/blob/master/eslint.config.js"
    click IndexHTML "https://github.com/sinha-19/smart-recipe-ai/blob/master/public/index.html"
    click MainTS "https://github.com/sinha-19/smart-recipe-ai/blob/master/src/main.tsx"
    click AppTS "https://github.com/sinha-19/smart-recipe-ai/blob/master/src/App.tsx"
    click Header "https://github.com/sinha-19/smart-recipe-ai/blob/master/src/components/Header.tsx"
    click Footer "https://github.com/sinha-19/smart-recipe-ai/blob/master/src/components/Footer.tsx"
    click RecipeCard "https://github.com/sinha-19/smart-recipe-ai/blob/master/src/components/RecipeCard.tsx"
    click IngredientInput "https://github.com/sinha-19/smart-recipe-ai/blob/master/src/components/IngredientInput.tsx"
    click Layout "https://github.com/sinha-19/smart-recipe-ai/blob/master/src/components/Layout.tsx"
    click EmptyState "https://github.com/sinha-19/smart-recipe-ai/blob/master/src/components/EmptyState.tsx"
    click LoadingState "https://github.com/sinha-19/smart-recipe-ai/blob/master/src/components/LoadingState.tsx"
    click Home "https://github.com/sinha-19/smart-recipe-ai/blob/master/src/pages/Home.tsx"
    click MealPlanner "https://github.com/sinha-19/smart-recipe-ai/blob/master/src/pages/MealPlanner.tsx"
    click SavedRecipes "https://github.com/sinha-19/smart-recipe-ai/blob/master/src/pages/SavedRecipes.tsx"
    click About "https://github.com/sinha-19/smart-recipe-ai/blob/master/src/pages/About.tsx"
    click RecipeContext "https://github.com/sinha-19/smart-recipe-ai/blob/master/src/contexts/RecipeContext.tsx"
    click ThemeContext "https://github.com/sinha-19/smart-recipe-ai/blob/master/src/contexts/ThemeContext.tsx"
    click APIService "https://github.com/sinha-19/smart-recipe-ai/blob/master/src/services/apiService.ts"
    
    %% Styles
    classDef ui fill:#cce5ff,stroke:#0066cc,color:#000;
    classDef context fill:#d4edda,stroke:#28a745,color:#000;
    classDef service fill:#fff3cd,stroke:#e0a800,color:#000;
    classDef external fill:#e2e3e5,stroke:#6c757d,color:#000;
    classDef config fill:#f8f9fa,stroke:#343a40,color:#000;
    classDef storage fill:#ffe5b4,stroke:#cc8400,color:#000;
```
