# phoebelh/culinai architecture

> Architecture diagram of the GitHub repository phoebelh/culinai, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-25). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/phoebelh/culinai
- Repository: https://github.com/phoebelh/culinai

## Overview

CulinAI is a Next.js recipe-generation site: a user uploads a food or fridge photo, the home page submits it for ingredient and recipe generation, then uses the returned recipe title and ingredients to request a generated food image and displays the result. The README describes LLaVa and Stable Diffusion; the sampled API code confirms separate Replicate prediction routes and model versions, but does not identify the first model by name. The map omits uninspected details beyond the documented workflow.

Main entry points: [`pages/index.js`](https://github.com/phoebelh/culinai/blob/main/pages/index.js) (Upload and orchestration), [`pages/api/predictions/index.js`](https://github.com/phoebelh/culinai/blob/main/pages/api/predictions/index.js) (Ingredient prediction create), [`pages/api/predictions/[id].js`](https://github.com/phoebelh/culinai/blob/main/pages/api/predictions/%5Bid%5D.js) (Ingredient prediction status), [`pages/api/image_predictions/index.js`](https://github.com/phoebelh/culinai/blob/main/pages/api/image_predictions/index.js) (Image prediction create)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web experience"]
  node_home["Upload and orchestration<br/>[index.js]"]
  node_recipe_view["Recipe display<br/>[recipe.js]"]
end

subgraph group_recipe["Recipe generation"]
  node_ingredient_create["Ingredient prediction create<br/>[index.js]"]
  node_ingredient_status["Ingredient prediction status<br/>[&#91;id&#93;.js]"]
end

subgraph group_visuals["Recipe visuals"]
  node_image_create["Image prediction create<br/>[index.js]"]
  node_image_status["Image prediction status<br/>[&#91;id&#93;.js]"]
end

node_user(("User"))
node_replicate["Replicate API"]

node_user -->|"uploads photo"| node_home
node_home -->|"submits image and prompt"| node_ingredient_create
node_ingredient_create -->|"creates prediction"| node_replicate
node_replicate -->|"returns prediction"| node_ingredient_create
node_ingredient_create -->|"returns prediction"| node_home
node_home -->|"polls prediction"| node_ingredient_status
node_ingredient_status -->|"gets prediction"| node_replicate
node_replicate -->|"returns status"| node_ingredient_status
node_ingredient_status -->|"returns status"| node_home
node_home -->|"submits image prompt"| node_image_create
node_image_create -->|"creates prediction"| node_replicate
node_replicate -->|"returns prediction"| node_image_create
node_image_create -->|"returns prediction"| node_home
node_home -->|"polls prediction"| node_image_status
node_image_status -->|"gets prediction"| node_replicate
node_replicate -->|"returns status"| node_image_status
node_image_status -->|"returns status"| node_home
node_home -->|"renders recipe and image"| node_recipe_view
node_recipe_view -->|"displays result"| node_user

click node_home "https://github.com/phoebelh/culinai/blob/main/pages/index.js"
click node_recipe_view "https://github.com/phoebelh/culinai/blob/main/pages/recipe.js"
click node_ingredient_create "https://github.com/phoebelh/culinai/blob/main/pages/api/predictions/index.js"
click node_ingredient_status "https://github.com/phoebelh/culinai/blob/main/pages/api/predictions/%5Bid%5D.js"
click node_image_create "https://github.com/phoebelh/culinai/blob/main/pages/api/image_predictions/index.js"
click node_image_status "https://github.com/phoebelh/culinai/blob/main/pages/api/image_predictions/%5Bid%5D.js"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_home,node_recipe_view,node_user toneBlue
class node_ingredient_create,node_ingredient_status toneAmber
class node_image_create,node_image_status,node_replicate toneMint
```

## Components

### Web experience

- [Upload and orchestration](https://github.com/phoebelh/culinai/blob/main/pages/index.js): `pages/index.js`
- [Recipe display](https://github.com/phoebelh/culinai/blob/main/pages/recipe.js): `pages/recipe.js`

### Recipe generation

- [Ingredient prediction create](https://github.com/phoebelh/culinai/blob/main/pages/api/predictions/index.js): `pages/api/predictions/index.js`
- [Ingredient prediction status](https://github.com/phoebelh/culinai/blob/main/pages/api/predictions/%5Bid%5D.js): `pages/api/predictions/[id].js`

### Recipe visuals

- [Image prediction create](https://github.com/phoebelh/culinai/blob/main/pages/api/image_predictions/index.js): `pages/api/image_predictions/index.js`
- [Image prediction status](https://github.com/phoebelh/culinai/blob/main/pages/api/image_predictions/%5Bid%5D.js): `pages/api/image_predictions/[id].js`

### Other components

- **User**
- **Replicate API**

## Connections

- User → Upload and orchestration: uploads photo
- Upload and orchestration → Ingredient prediction create: submits image and prompt
- Ingredient prediction create → Replicate API: creates prediction
- Replicate API → Ingredient prediction create: returns prediction
- Ingredient prediction create → Upload and orchestration: returns prediction
- Upload and orchestration → Ingredient prediction status: polls prediction
- Ingredient prediction status → Replicate API: gets prediction
- Replicate API → Ingredient prediction status: returns status
- Ingredient prediction status → Upload and orchestration: returns status
- Upload and orchestration → Image prediction create: submits image prompt
- Image prediction create → Replicate API: creates prediction
- Replicate API → Image prediction create: returns prediction
- Image prediction create → Upload and orchestration: returns prediction
- Upload and orchestration → Image prediction status: polls prediction
- Image prediction status → Replicate API: gets prediction
- Replicate API → Image prediction status: returns status
- Image prediction status → Upload and orchestration: returns status
- Upload and orchestration → Recipe display: renders recipe and image
- Recipe display → User: displays result
