# henristr/smartfridgepwa architecture

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

- Interactive diagram: https://gitdiagram.com/henristr/smartfridgepwa
- Repository: https://github.com/henristr/smartfridgepwa

## Overview

SmartFridge/KitchAI is a Flask-based fridge and recipe application. The visible workflow is browser requests handled by the Flask app, which uses stored user and product data and can request AI-generated recipes from configured providers; the app also renders its web interface. The app contains authentication, inventory, recipe, and admin behavior, but excerpts do not expose every route or its full call structure. Storage supports SQL and JSON fallback. The README only links to an Android app and documentation, so those capabilities are not mapped here.

Main entry points: [`app.py`](https://github.com/henristr/smartfridgepwa/blob/main/app.py) (Flask application), [`storage.py`](https://github.com/henristr/smartfridgepwa/blob/main/storage.py) (Storage abstraction), [`settings.py`](https://github.com/henristr/smartfridgepwa/blob/main/settings.py) (Runtime configuration), [`templates/index.html`](https://github.com/henristr/smartfridgepwa/blob/main/templates/index.html) (Web interface)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web interface"]
  node_flask["Flask application<br/>[app.py]"]
  node_webpage["Web interface<br/>[index.html]"]
end

subgraph group_application["Application"]
  node_user_inventory_recipes["Users, inventory, recipes<br/>[app.py]"]
  node_ai_recipe_generation["AI recipe generation<br/>[app.py]"]
  node_admin_settings["Admin settings<br/>[app.py]"]
end

subgraph group_persistence["Persistence"]
  node_storage["Storage abstraction<br/>[storage.py]"]
  node_json_fallback["JSON fallback<br/>[storage.py]"]
  node_orm_models["SQL data models<br/>[models.py]"]
  node_sql_database[("SQL database")]
end

subgraph group_integrations["Configuration and AI"]
  node_settings["Runtime configuration<br/>[settings.py]"]
  node_gemini["Gemini API"]
  node_openai["OpenAI API"]
  node_ollama["Ollama endpoint"]
end

node_browser(("Browser user"))

node_browser -->|"sends requests"| node_flask
node_flask -->|"routes requests"| node_user_inventory_recipes
node_flask -->|"generates recipes"| node_ai_recipe_generation
node_flask -->|"handles settings"| node_admin_settings
node_flask -->|"renders page"| node_webpage
node_flask -->|"loads and saves"| node_storage
node_flask -->|"reads configuration"| node_settings
node_ai_recipe_generation -.->|"requests generation"| node_gemini
node_ai_recipe_generation -.->|"requests generation"| node_openai
node_ai_recipe_generation -->|"posts prompt"| node_ollama
node_storage -->|"uses models"| node_orm_models
node_storage -->|"reads and writes"| node_sql_database
node_storage -->|"falls back to"| node_json_fallback
node_storage -->|"reads configuration"| node_settings

click node_flask "https://github.com/henristr/smartfridgepwa/blob/main/app.py"
click node_webpage "https://github.com/henristr/smartfridgepwa/blob/main/templates/index.html"
click node_user_inventory_recipes "https://github.com/henristr/smartfridgepwa/blob/main/app.py"
click node_ai_recipe_generation "https://github.com/henristr/smartfridgepwa/blob/main/app.py"
click node_admin_settings "https://github.com/henristr/smartfridgepwa/blob/main/app.py"
click node_storage "https://github.com/henristr/smartfridgepwa/blob/main/storage.py"
click node_json_fallback "https://github.com/henristr/smartfridgepwa/blob/main/storage.py"
click node_orm_models "https://github.com/henristr/smartfridgepwa/blob/main/models.py"
click node_settings "https://github.com/henristr/smartfridgepwa/blob/main/settings.py"

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_flask,node_webpage,node_browser toneBlue
class node_user_inventory_recipes,node_ai_recipe_generation,node_admin_settings toneAmber
class node_storage,node_json_fallback,node_orm_models,node_sql_database toneMint
class node_settings,node_gemini,node_openai,node_ollama toneRose
```

## Components

### Web interface

- [Flask application](https://github.com/henristr/smartfridgepwa/blob/main/app.py): `app.py`
- [Web interface](https://github.com/henristr/smartfridgepwa/blob/main/templates/index.html): `templates/index.html`

### Application

- [Users, inventory, recipes](https://github.com/henristr/smartfridgepwa/blob/main/app.py): `app.py`
- [AI recipe generation](https://github.com/henristr/smartfridgepwa/blob/main/app.py): `app.py`
- [Admin settings](https://github.com/henristr/smartfridgepwa/blob/main/app.py): `app.py`

### Persistence

- [Storage abstraction](https://github.com/henristr/smartfridgepwa/blob/main/storage.py): `storage.py`
- [JSON fallback](https://github.com/henristr/smartfridgepwa/blob/main/storage.py): `storage.py`
- [SQL data models](https://github.com/henristr/smartfridgepwa/blob/main/models.py): `models.py`
- **SQL database**

### Configuration and AI

- [Runtime configuration](https://github.com/henristr/smartfridgepwa/blob/main/settings.py): `settings.py`
- **Gemini API**
- **OpenAI API**
- **Ollama endpoint**

### Other components

- **Browser user**

## Connections

- Browser user → Flask application: sends requests
- Flask application → Users, inventory, recipes: routes requests (evidence: `app.py`)
- Flask application → AI recipe generation: generates recipes (evidence: `app.py`)
- Flask application → Admin settings: handles settings (evidence: `app.py`)
- Flask application → Web interface: renders page (evidence: `app.py`)
- Flask application → Storage abstraction: loads and saves (evidence: `app.py`)
- Flask application → Runtime configuration: reads configuration (evidence: `app.py`)
- AI recipe generation → Gemini API: requests generation (evidence: `app.py`)
- AI recipe generation → OpenAI API: requests generation (evidence: `app.py`)
- AI recipe generation → Ollama endpoint: posts prompt (evidence: `app.py`)
- Storage abstraction → SQL data models: uses models (evidence: `storage.py`)
- Storage abstraction → SQL database: reads and writes (evidence: `storage.py`)
- Storage abstraction → JSON fallback: falls back to (evidence: `storage.py`)
- Storage abstraction → Runtime configuration: reads configuration (evidence: `storage.py`)
