# punkkd/affordeat architecture

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

- Interactive diagram: https://gitdiagram.com/punkkd/affordeat
- Repository: https://github.com/punkkd/affordeat

## Overview

AffordEat is a desktop meal-planning and grocery-management app for budget-conscious users. Users enter a plan in the form or as a message; the app applies saved dietary, allergy, and kitchen preferences, requests candidate recipes, filters and ranks them into a budget-aware plan and shopping list, then saves the result. Separate workflows manage pantry items, scan food photos, maintain recipes and preferences, and swap planned meals. Several links reflect documented capabilities; provider internals and unsampled page wiring are not detailed here.

Main entry points: [`meal_plan_service.py`](https://github.com/punkkd/affordeat/blob/main/meal_plan_service.py) (Plan service), [`GUI/main_window.py`](https://github.com/punkkd/affordeat/blob/main/GUI/main_window.py) (App navigation), [`app_context.py`](https://github.com/punkkd/affordeat/blob/main/app_context.py) (App composition), [`GUI/pages/meal_planner_page.py`](https://github.com/punkkd/affordeat/blob/main/GUI/pages/meal_planner_page.py) (Planning pages)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["Desktop experience"]
  node_window["App navigation<br/>[main_window.py]"]
  node_plan_pages["Planning pages"]
  node_results["Plan results"]
  node_profile_page["Profile page<br/>[profile_page.py]"]
  node_pantry_page["Pantry page<br/>[pantry_page.py]"]
  node_scan_page["Scan page<br/>[scan_item_page.py]"]
  node_recipes_page["My Recipes<br/>[my_recipes_page.py]"]
end

subgraph group_planning["Meal planning"]
  node_planner_service["Plan service"]
  node_prompt_parser["Message parser<br/>[prompt_parser.py]"]
  node_request["Plan request"]
  node_logic["Rules and ranking<br/>[logic_manager.py]"]
  node_meal_plan["Plan and meals<br/>[meal_plan.py]"]
end

subgraph group_household["Household data"]
  node_profile["Diet profile<br/>[user_profile.py]"]
  node_allergens["Allergen catalogue"]
  node_kitchen["Kitchen preferences<br/>[appliance_store.py]"]
  node_pantry["Pantry manager<br/>[pantry_manager.py]"]
  node_recipes["Recipe library<br/>[recipe_store.py]"]
end

subgraph group_ai_scan["AI and scanning"]
  node_ai_manager["AI planner<br/>[ai_manager.py]"]
  node_scanner["Photo scanner"]
end

subgraph group_storage["Persistence"]
  node_data_manager["Plan history<br/>[DataManager.py]"]
  node_db[("SQLite database<br/>[DBStorage.py]")]
  node_app_context["App composition<br/>[app_context.py]"]
end

node_user(("Home cook"))

node_user -->|"uses"| node_window
node_window -->|"opens"| node_plan_pages
node_window -->|"opens"| node_profile_page
node_window -->|"opens"| node_pantry_page
node_window -->|"opens"| node_scan_page
node_window -->|"opens"| node_recipes_page
node_plan_pages -.->|"requests plan"| node_planner_service
node_plan_pages -.->|"parses message"| node_prompt_parser
node_prompt_parser -->|"builds request"| node_request
node_planner_service -->|"uses request"| node_request
node_planner_service -->|"applies profile"| node_profile
node_planner_service -->|"applies preferences"| node_kitchen
node_profile_page -->|"searches"| node_allergens
node_planner_service -->|"describes allergies"| node_allergens
node_planner_service -->|"requests candidates"| node_ai_manager
node_ai_manager -->|"candidates"| node_logic
node_planner_service -->|"builds final plan"| node_logic
node_logic -->|"creates plan"| node_meal_plan
node_planner_service -->|"keeps recipes"| node_recipes
node_planner_service -->|"saves plan"| node_data_manager
node_data_manager -->|"reads and writes"| node_db
node_pantry_page -.->|"manages items"| node_pantry
node_scan_page -.->|"submits photo"| node_scanner
node_scanner -->|"matches ingredients"| node_pantry
node_recipes_page -.->|"browses recipes"| node_recipes
node_results -.->|"displays plan"| node_meal_plan
node_app_context -->|"assembles"| node_planner_service
node_app_context -->|"configures"| node_ai_manager
node_app_context -->|"assembles"| node_data_manager

click node_window "https://github.com/punkkd/affordeat/blob/main/GUI/main_window.py"
click node_plan_pages "https://github.com/punkkd/affordeat/blob/main/GUI/pages/meal_planner_page.py"
click node_results "https://github.com/punkkd/affordeat/blob/main/GUI/pages/meal_results_page.py"
click node_profile_page "https://github.com/punkkd/affordeat/blob/main/GUI/pages/profile_page.py"
click node_pantry_page "https://github.com/punkkd/affordeat/blob/main/GUI/pages/pantry_page.py"
click node_scan_page "https://github.com/punkkd/affordeat/blob/main/GUI/pages/scan_item_page.py"
click node_recipes_page "https://github.com/punkkd/affordeat/blob/main/GUI/pages/my_recipes_page.py"
click node_planner_service "https://github.com/punkkd/affordeat/blob/main/meal_plan_service.py"
click node_prompt_parser "https://github.com/punkkd/affordeat/blob/main/IO/PromptParser/prompt_parser.py"
click node_request "https://github.com/punkkd/affordeat/blob/main/Meals/meal_plan_request.py"
click node_ai_manager "https://github.com/punkkd/affordeat/blob/main/AI/ai_manager.py"
click node_logic "https://github.com/punkkd/affordeat/blob/main/Logic/logic_manager.py"
click node_meal_plan "https://github.com/punkkd/affordeat/blob/main/Meals/meal_plan.py"
click node_profile "https://github.com/punkkd/affordeat/blob/main/Profile/user_profile.py"
click node_allergens "https://github.com/punkkd/affordeat/blob/main/Profile/allergen_catalog.py"
click node_kitchen "https://github.com/punkkd/affordeat/blob/main/Kitchen/appliance_store.py"
click node_pantry "https://github.com/punkkd/affordeat/blob/main/Pantry/pantry_manager.py"
click node_scanner "https://github.com/punkkd/affordeat/blob/main/ImageScanner/ingredient_image_scanner.py"
click node_recipes "https://github.com/punkkd/affordeat/blob/main/Recipes/recipe_store.py"
click node_data_manager "https://github.com/punkkd/affordeat/blob/main/Data/DataManager.py"
click node_db "https://github.com/punkkd/affordeat/blob/main/Data/DBStorage.py"
click node_app_context "https://github.com/punkkd/affordeat/blob/main/app_context.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_window,node_plan_pages,node_results,node_profile_page,node_pantry_page,node_scan_page,node_recipes_page toneBlue
class node_planner_service,node_prompt_parser,node_request,node_logic,node_meal_plan toneAmber
class node_profile,node_allergens,node_kitchen,node_pantry,node_recipes toneMint
class node_ai_manager,node_scanner toneRose
class node_data_manager,node_db,node_app_context,node_user toneIndigo
```

## Components

### Desktop experience

- [App navigation](https://github.com/punkkd/affordeat/blob/main/GUI/main_window.py): `GUI/main_window.py`
- [Planning pages](https://github.com/punkkd/affordeat/blob/main/GUI/pages/meal_planner_page.py): `GUI/pages/meal_planner_page.py`
- [Plan results](https://github.com/punkkd/affordeat/blob/main/GUI/pages/meal_results_page.py): `GUI/pages/meal_results_page.py`
- [Profile page](https://github.com/punkkd/affordeat/blob/main/GUI/pages/profile_page.py): `GUI/pages/profile_page.py`
- [Pantry page](https://github.com/punkkd/affordeat/blob/main/GUI/pages/pantry_page.py): `GUI/pages/pantry_page.py`
- [Scan page](https://github.com/punkkd/affordeat/blob/main/GUI/pages/scan_item_page.py): `GUI/pages/scan_item_page.py`
- [My Recipes](https://github.com/punkkd/affordeat/blob/main/GUI/pages/my_recipes_page.py): `GUI/pages/my_recipes_page.py`

### Meal planning

- [Plan service](https://github.com/punkkd/affordeat/blob/main/meal_plan_service.py): `meal_plan_service.py`
- [Message parser](https://github.com/punkkd/affordeat/blob/main/IO/PromptParser/prompt_parser.py): `IO/PromptParser/prompt_parser.py`
- [Plan request](https://github.com/punkkd/affordeat/blob/main/Meals/meal_plan_request.py): `Meals/meal_plan_request.py`
- [Rules and ranking](https://github.com/punkkd/affordeat/blob/main/Logic/logic_manager.py): `Logic/logic_manager.py`
- [Plan and meals](https://github.com/punkkd/affordeat/blob/main/Meals/meal_plan.py): `Meals/meal_plan.py`

### Household data

- [Diet profile](https://github.com/punkkd/affordeat/blob/main/Profile/user_profile.py): `Profile/user_profile.py`
- [Allergen catalogue](https://github.com/punkkd/affordeat/blob/main/Profile/allergen_catalog.py): `Profile/allergen_catalog.py`
- [Kitchen preferences](https://github.com/punkkd/affordeat/blob/main/Kitchen/appliance_store.py): `Kitchen/appliance_store.py`
- [Pantry manager](https://github.com/punkkd/affordeat/blob/main/Pantry/pantry_manager.py): `Pantry/pantry_manager.py`
- [Recipe library](https://github.com/punkkd/affordeat/blob/main/Recipes/recipe_store.py): `Recipes/recipe_store.py`

### AI and scanning

- [AI planner](https://github.com/punkkd/affordeat/blob/main/AI/ai_manager.py): `AI/ai_manager.py`
- [Photo scanner](https://github.com/punkkd/affordeat/blob/main/ImageScanner/ingredient_image_scanner.py): `ImageScanner/ingredient_image_scanner.py`

### Persistence

- [Plan history](https://github.com/punkkd/affordeat/blob/main/Data/DataManager.py): `Data/DataManager.py`
- [SQLite database](https://github.com/punkkd/affordeat/blob/main/Data/DBStorage.py): `Data/DBStorage.py`
- [App composition](https://github.com/punkkd/affordeat/blob/main/app_context.py): `app_context.py`

### Other components

- **Home cook**

## Connections

- Home cook → App navigation: uses (evidence: `README.md`)
- App navigation → Planning pages: opens (evidence: `GUI/main_window.py`)
- App navigation → Profile page: opens (evidence: `GUI/main_window.py`)
- App navigation → Pantry page: opens (evidence: `GUI/main_window.py`)
- App navigation → Scan page: opens (evidence: `GUI/main_window.py`)
- App navigation → My Recipes: opens (evidence: `GUI/main_window.py`)
- Planning pages → Plan service: requests plan
- Planning pages → Message parser: parses message
- Message parser → Plan request: builds request (evidence: `IO/PromptParser/prompt_parser.py`)
- Plan service → Plan request: uses request (evidence: `meal_plan_service.py`)
- Plan service → Diet profile: applies profile (evidence: `meal_plan_service.py`)
- Plan service → Kitchen preferences: applies preferences (evidence: `meal_plan_service.py`)
- Profile page → Allergen catalogue: searches (evidence: `GUI/pages/profile_page.py`)
- Plan service → Allergen catalogue: describes allergies (evidence: `meal_plan_service.py`)
- Plan service → AI planner: requests candidates (evidence: `meal_plan_service.py`)
- AI planner → Rules and ranking: candidates
- Plan service → Rules and ranking: builds final plan (evidence: `meal_plan_service.py`)
- Rules and ranking → Plan and meals: creates plan (evidence: `Logic/logic_manager.py`)
- Plan service → Recipe library: keeps recipes (evidence: `meal_plan_service.py`)
- Plan service → Plan history: saves plan (evidence: `meal_plan_service.py`)
- Plan history → SQLite database: reads and writes (evidence: `Data/DataManager.py`)
- Pantry page → Pantry manager: manages items
- Scan page → Photo scanner: submits photo
- Photo scanner → Pantry manager: matches ingredients (evidence: `ImageScanner/ingredient_image_scanner.py`)
- My Recipes → Recipe library: browses recipes
- Plan results → Plan and meals: displays plan
- App composition → Plan service: assembles (evidence: `app_context.py`)
- App composition → AI planner: configures (evidence: `app_context.py`)
- App composition → Plan history: assembles (evidence: `app_context.py`)
