# tabarakmukhtar/recipe-snap architecture

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

- Interactive diagram: https://gitdiagram.com/tabarakmukhtar/recipe-snap
- Repository: https://github.com/tabarakmukhtar/recipe-snap

## Overview

##### Project type and purpose
- Recipe Snap is a modern full-stack web application built on Next.js (App Router) with AI-powered photo-to-recipe capabilities.
- The purpose is to let users snap or upload a photo of ingredients, have an AI identify them, allow edits, then generate complete recipes which can be saved in browser local storage.

##### File structure
- Top level:
- next.config.ts, tsconfig.json, tailwind.config.ts – Next.js, TypeScript, and Tailwind config
- netlify.toml, apphosting.yaml – Deployment configs (Netlify, Google App Hosting)
- src/app – Next.js App Router pages (layout.tsx, page.tsx)
- src/components – React UI components (ShadCN-based under ui/, recipe-specific under recipe/)
- src/ai – AI orchestration code: dev.ts (local Genkit server startup), genkit.ts (Genkit client), flows/ (analyze-photo.ts, generate-recipe.ts)
- src/hooks, src/lib – utility hooks and helper functions
- No traditional database; state/persistence is browser localStorage for recipe history. AI backend is Genkit (locally in dev, cloud-hosted in prod) which in turn calls Gemini API.

##### README for additional insights
- Tech stack: Next.js, React, Tailwind, ShadCN UI, Genkit (generative AI), TypeScript
- Runtime: single command `npm run genkit:dev` launches both Next.js and Genkit in dev
- External dependencies: Gemini API key for AI tasks
- Deployment: Netlify with environment variable for GEMINI_API_KEY

##### Essential details to capture
- Frontend entrypoint and client components
- Next.js App Router and API surface
- Genkit flow modules and their roles (analyze-photo, generate-recipe)
- External Gemini dependency
- Browser localStorage for history
- Deployment config (Netlify) if relevant for hosting context

## Diagram (Mermaid)

```mermaid
graph TB

  %% Browser Layer
  subgraph "Browser (Client)" 
    direction TB
    LU["Layout"]:::frontend
    HD["Header"]:::frontend
    PG["Page (Entry)"]:::frontend
    CSS["globals.css"]:::frontend
    PU["PhotoUploader"]:::frontend
    IE["IngredientEditor"]:::frontend
    RC["RecipeCard"]:::frontend
    HS["HistorySidebar"]:::frontend
    subgraph "UI Library"
      UI["ShadCN UI Components"]:::frontend
    end
    subgraph "Utilities"
      UH1["use-mobile Hook"]:::frontend
      UH2["use-toast Hook"]:::frontend
      UF["utils.ts"]:::frontend
    end
  end

  %% Persistence
  subgraph "Persistence"
    LS["Browser localStorage"]:::persistence
  end

  %% Next.js Server Layer
  subgraph "Next.js Server" 
    direction TB
    NSP["App Router (layout.tsx, page.tsx)"]:::backend
  end

  %% AI Backend Layer
  subgraph "AI Backend (Genkit)"
    direction TB
    DK["dev.ts"]:::ai
    GK["genkit.ts"]:::ai
    AP["analyze-photo.ts"]:::ai
    GR["generate-recipe.ts"]:::ai
  end

  %% External Service
  EB["Gemini API"]:::external

  %% Deployment & Config
  subgraph "Deployment & Config"
    direction TB
    NC["netlify.toml"]:::config
    AH["apphosting.yaml"]:::config
    NCF["next.config.ts"]:::config
    TC["tsconfig.json"]:::config
    TW["tailwind.config.ts"]:::config
  end

  %% Connections: Photo Analysis Flow
  PU -->|"upload photo"| NSP
  NSP -->|"call Genkit Dev Server"| DK
  DK --> GK
  GK --> AP
  AP --> EB
  EB --> AP
  AP --> GK
  GK --> NSP
  NSP -->|"return ingredients"| PU

  %% Connections: Recipe Generation Flow
  IE -->|"edit ingredients"| NSP
  NSP --> DK
  DK --> GK
  GK --> GR
  GR --> EB
  EB --> GR
  GR --> GK
  GK --> NSP
  NSP -->|"return recipe"| RC

  %% Saving & History
  RC -->|"save recipe"| LS
  HS -->|"read history"| LS

  %% Click Events
  click LU "https://github.com/tabarakmukhtar/recipe-snap/blob/master/src/app/layout.tsx"
  click HD "https://github.com/tabarakmukhtar/recipe-snap/blob/master/src/components/layout/Header.tsx"
  click PG "https://github.com/tabarakmukhtar/recipe-snap/blob/master/src/app/page.tsx"
  click CSS "https://github.com/tabarakmukhtar/recipe-snap/blob/master/src/app/globals.css"
  click PU "https://github.com/tabarakmukhtar/recipe-snap/blob/master/src/components/recipe/PhotoUploader.tsx"
  click IE "https://github.com/tabarakmukhtar/recipe-snap/blob/master/src/components/recipe/IngredientEditor.tsx"
  click RC "https://github.com/tabarakmukhtar/recipe-snap/blob/master/src/components/recipe/RecipeCard.tsx"
  click HS "https://github.com/tabarakmukhtar/recipe-snap/blob/master/src/components/recipe/HistorySidebar.tsx"
  click UI "https://github.com/tabarakmukhtar/recipe-snap/tree/master/src/components/ui/"
  click UH1 "https://github.com/tabarakmukhtar/recipe-snap/blob/master/src/hooks/use-mobile.tsx"
  click UH2 "https://github.com/tabarakmukhtar/recipe-snap/blob/master/src/hooks/use-toast.tsx"
  click UF "https://github.com/tabarakmukhtar/recipe-snap/blob/master/src/lib/utils.ts"
  click NSP "https://github.com/tabarakmukhtar/recipe-snap/blob/master/src/app/page.tsx"
  click NSP "https://github.com/tabarakmukhtar/recipe-snap/blob/master/src/app/layout.tsx"
  click DK "https://github.com/tabarakmukhtar/recipe-snap/blob/master/src/ai/dev.ts"
  click GK "https://github.com/tabarakmukhtar/recipe-snap/blob/master/src/ai/genkit.ts"
  click AP "https://github.com/tabarakmukhtar/recipe-snap/blob/master/src/ai/flows/analyze-photo.ts"
  click GR "https://github.com/tabarakmukhtar/recipe-snap/blob/master/src/ai/flows/generate-recipe.ts"
  click NC "https://github.com/tabarakmukhtar/recipe-snap/blob/master/netlify.toml"
  click AH "https://github.com/tabarakmukhtar/recipe-snap/blob/master/apphosting.yaml"
  click NCF "https://github.com/tabarakmukhtar/recipe-snap/blob/master/next.config.ts"
  click TC "https://github.com/tabarakmukhtar/recipe-snap/blob/master/tsconfig.json"
  click TW "https://github.com/tabarakmukhtar/recipe-snap/blob/master/tailwind.config.ts"

  %% Styles
  classDef frontend fill:#cce5ff,stroke:#333,stroke-width:1px
  classDef backend fill:#d4edda,stroke:#333,stroke-width:1px
  classDef ai fill:#ffe5b4,stroke:#333,stroke-width:1px
  classDef external fill:#f8d7da,stroke:#333,stroke-width:1px,stroke-dasharray: 5 5
  classDef persistence fill:#e2d1f9,stroke:#333,stroke-width:1px,stroke-dasharray: 2 2
  classDef config fill:#f0f0f0,stroke:#333,stroke-width:1px,stroke-dasharray: 2 2
```
