# aau-giraf/foodplanner architecture

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

- Interactive diagram: https://gitdiagram.com/aau-giraf/foodplanner
- Repository: https://github.com/aau-giraf/foodplanner

## Overview

#### Purpose and Runtime
GIRAF Foodplanner is a Flutter client for meal planning in the GIRAF ecosystem, optimized for iOS but also carrying web and macOS targets. It consumes a separately deployed ASP.NET backend, which persists data in PostgreSQL and stores food images in Minio. Flutter project/runtime metadata is rooted at `foodplanner/pubspec.yaml`, `foodplanner/ios/Runner/AppDelegate.swift`, and `foodplanner/web/index.html`.

#### Application Bootstrap and Navigation
`foodplanner/lib/main.dart` initializes the application. Navigation is centralized through GoRouter route definitions in `foodplanner/lib/routes/index.dart` and `foodplanner/lib/routes/paths.dart`, creating the boundary between app-wide navigation/auth state and feature pages. Landing, login, signup, and unauthorized screens establish entry and access flows.

#### Authentication and Role-Specific Experience
Authentication is represented by `foodplanner/lib/auth/auth_provider.dart` and networked through `foodplanner/lib/services/fetch_auth.dart`. User and role domain types live in `foodplanner/lib/models/user.dart` and `foodplanner/lib/models/user_roles.dart`. Pages divide workflows for guardians, teachers, children, and administrators, including `foodplanner/lib/pages/landing_page_guardian.dart`, `foodplanner/lib/pages/landing_page_teacher.dart`, and `foodplanner/lib/pages/settings/admin_approve_page.dart`.

#### Meal Planning Domain
Meal planning is the primary feature: users create, edit, list, and inspect meal plans via `foodplanner/lib/pages/meal_list_page.dart`, `foodplanner/lib/pages/add_meal_form_page.dart`, and `foodplanner/lib/pages/edit_meal_page.dart`. Core entities are `foodplanner/lib/models/meal.dart`, `foodplanner/lib/models/ingredient.dart`, and `foodplanner/lib/models/packed_ingredient.dart`. Shared meal state/change propagation is handled by `foodplanner/lib/services/meal_notifier.dart`.

#### Data Access and Generated API Boundary
Service classes encapsulate calls from pages/widgets to the backend: `foodplanner/lib/services/meal_services.dart`, `foodplanner/lib/services/ingredient_services.dart`, and `foodplanner/lib/services/user_service.dart`. API base configuration is isolated in `foodplanner/lib/services/api_config.dart`. Generated OpenAPI client configuration is under `foodplanner/lib/api/generator/openapi_config.dart`; generation depends on a running backend and `foodplanner/openapi_generator_config.json`. This is the main client/server contract boundary.

#### Supporting Workflows: Pupils, Classes, Feedback, Images
Pupil and school-class administration uses `foodplanner/lib/services/pupil_service.dart`, `foodplanner/lib/services/school_class_service.dart`, and pages such as `foodplanner/lib/pages/pupil_page.dart`. Feedback chat is accessed through `foodplanner/lib/services/fetch_feedback_messages.dart` and `foodplanner/lib/pages/feedback_chat_page.dart`. Food image retrieval/upload-facing behavior is separated in `foodplanner/lib/services/food_image_service.dart` and `foodplanner/lib/components/image.dart`, crossing to the Minio image service rather than the core relational API.

#### UI Composition and Platform Delivery
Feature pages compose reusable Flutter controls from `foodplanner/lib/components/`, with meal-specific presentation concentrated in `foodplanner/lib/components/meal_box.dart` and `foodplanner/lib/components/meal_list_element.dart`. iOS packaging, signing, and native integration are maintained in `foodplanner/ios/Runner.xcodeproj` and `foodplanner/ios/Runner/Info.plist`; web can be launched through `foodplanner/run_flutter_web.bat`.

Main entry points: [`foodplanner/lib/services/meal_services.dart`](https://github.com/aau-giraf/foodplanner/blob/staging/foodplanner/lib/services/meal_services.dart) (Meal and ingredient services), [`foodplanner/lib/pages/meal_list_page.dart`](https://github.com/aau-giraf/foodplanner/blob/staging/foodplanner/lib/pages/meal_list_page.dart) (Meal planning pages), [`foodplanner/lib/main.dart`](https://github.com/aau-giraf/foodplanner/blob/staging/foodplanner/lib/main.dart) (App bootstrap), [`foodplanner/lib/routes/index.dart`](https://github.com/aau-giraf/foodplanner/blob/staging/foodplanner/lib/routes/index.dart) (Navigation and access)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Flutter client"]
  node_runtime["Flutter runtime<br/>project runtime<br/>[pubspec.yaml]"]
  node_bootstrap["App bootstrap<br/>Flutter entrypoint<br/>[main.dart]"]
  node_navigation["Navigation and access<br/>GoRouter routes<br/>[index.dart]"]
  node_auth["Authentication state<br/>auth provider<br/>[auth_provider.dart]"]
  node_auth_api["Auth transport<br/>network service<br/>[fetch_auth.dart]"]
  node_meal_api["Meal and ingredient services<br/>data services<br/>[meal_services.dart]"]
  node_ui_components["Reusable UI components<br/>Flutter components<br/>[meal_box.dart]"]
  node_api_contract["Generated API contract<br/>OpenAPI client config"]
  node_api_config["API endpoint config<br/>client configuration<br/>[api_config.dart]"]
  node_ios_delivery["iOS delivery<br/>native packaging<br/>[Runner.xcodeproj]"]
end

subgraph group_features["Feature workflows"]
  node_role_pages["Role-specific pages<br/>feature pages"]
  node_meal_pages["Meal planning pages<br/>feature pages"]
  node_meal_state["Meal change state<br/>notifier<br/>[meal_notifier.dart]"]
  node_pupil_api["Pupil and class services<br/>data services<br/>[pupil_service.dart]"]
  node_feedback["Feedback chat<br/>feature workflow"]
  node_image_workflow["Food images<br/>image service and UI"]
end

subgraph group_external["Deployed services"]
  node_backend{{"ASP.NET backend<br/>separately deployed API"}}
  node_postgres[("PostgreSQL<br/>relational database")]
  node_minio[("Minio image storage<br/>object storage")]
end

node_runtime -->|"launches"| node_bootstrap
node_bootstrap -->|"initializes"| node_navigation
node_bootstrap -->|"provides state"| node_auth
node_navigation -->|"routes by access"| node_role_pages
node_navigation -->|"routes to"| node_meal_pages
node_auth -->|"authenticates via"| node_auth_api
node_auth_api -->|"calls"| node_backend
node_meal_pages -->|"reads and updates"| node_meal_state
node_meal_pages -->|"uses"| node_meal_api
node_meal_pages -->|"composes"| node_ui_components
node_meal_api -->|"uses endpoint"| node_api_config
node_meal_api -->|"uses contract"| node_api_contract
node_meal_api -->|"calls"| node_backend
node_pupil_api -->|"calls"| node_backend
node_feedback -->|"loads messages"| node_backend
node_image_workflow -->|"retrieves images"| node_minio
node_backend -->|"persists data"| node_postgres
node_ios_delivery -->|"packages"| node_runtime

click node_runtime "https://github.com/aau-giraf/foodplanner/blob/staging/foodplanner/pubspec.yaml"
click node_bootstrap "https://github.com/aau-giraf/foodplanner/blob/staging/foodplanner/lib/main.dart"
click node_navigation "https://github.com/aau-giraf/foodplanner/blob/staging/foodplanner/lib/routes/index.dart"
click node_auth "https://github.com/aau-giraf/foodplanner/blob/staging/foodplanner/lib/auth/auth_provider.dart"
click node_auth_api "https://github.com/aau-giraf/foodplanner/blob/staging/foodplanner/lib/services/fetch_auth.dart"
click node_role_pages "https://github.com/aau-giraf/foodplanner/blob/staging/foodplanner/lib/pages/landing_page_guardian.dart"
click node_meal_pages "https://github.com/aau-giraf/foodplanner/blob/staging/foodplanner/lib/pages/meal_list_page.dart"
click node_meal_state "https://github.com/aau-giraf/foodplanner/blob/staging/foodplanner/lib/services/meal_notifier.dart"
click node_meal_api "https://github.com/aau-giraf/foodplanner/blob/staging/foodplanner/lib/services/meal_services.dart"
click node_pupil_api "https://github.com/aau-giraf/foodplanner/blob/staging/foodplanner/lib/services/pupil_service.dart"
click node_feedback "https://github.com/aau-giraf/foodplanner/blob/staging/foodplanner/lib/pages/feedback_chat_page.dart"
click node_image_workflow "https://github.com/aau-giraf/foodplanner/blob/staging/foodplanner/lib/services/food_image_service.dart"
click node_ui_components "https://github.com/aau-giraf/foodplanner/blob/staging/foodplanner/lib/components/meal_box.dart"
click node_api_contract "https://github.com/aau-giraf/foodplanner/blob/staging/foodplanner/lib/api/generator/openapi_config.dart"
click node_api_config "https://github.com/aau-giraf/foodplanner/blob/staging/foodplanner/lib/services/api_config.dart"
click node_ios_delivery "https://github.com/aau-giraf/foodplanner/tree/staging/foodplanner/ios/Runner.xcodeproj"

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_runtime,node_bootstrap,node_navigation,node_auth,node_auth_api,node_meal_api,node_ui_components,node_api_contract,node_api_config,node_ios_delivery toneBlue
class node_role_pages,node_meal_pages,node_meal_state,node_pupil_api,node_feedback,node_image_workflow toneAmber
class node_backend,node_postgres,node_minio toneMint
```

## Components

### Flutter client

- [Flutter runtime](https://github.com/aau-giraf/foodplanner/blob/staging/foodplanner/pubspec.yaml): project runtime · iOS-first client with web and macOS targets. · `foodplanner/pubspec.yaml`
- [App bootstrap](https://github.com/aau-giraf/foodplanner/blob/staging/foodplanner/lib/main.dart): Flutter entrypoint · `foodplanner/lib/main.dart`
- [Navigation and access](https://github.com/aau-giraf/foodplanner/blob/staging/foodplanner/lib/routes/index.dart): GoRouter routes · Central route and authentication-state boundary. · `foodplanner/lib/routes/index.dart`
- [Authentication state](https://github.com/aau-giraf/foodplanner/blob/staging/foodplanner/lib/auth/auth_provider.dart): auth provider · `foodplanner/lib/auth/auth_provider.dart`
- [Auth transport](https://github.com/aau-giraf/foodplanner/blob/staging/foodplanner/lib/services/fetch_auth.dart): network service · `foodplanner/lib/services/fetch_auth.dart`
- [Meal and ingredient services](https://github.com/aau-giraf/foodplanner/blob/staging/foodplanner/lib/services/meal_services.dart): data services · `foodplanner/lib/services/meal_services.dart`
- [Reusable UI components](https://github.com/aau-giraf/foodplanner/blob/staging/foodplanner/lib/components/meal_box.dart): Flutter components · Includes meal presentation controls. · `foodplanner/lib/components/meal_box.dart`
- [Generated API contract](https://github.com/aau-giraf/foodplanner/blob/staging/foodplanner/lib/api/generator/openapi_config.dart): OpenAPI client config · Generated against the running backend. · `foodplanner/lib/api/generator/openapi_config.dart`
- [API endpoint config](https://github.com/aau-giraf/foodplanner/blob/staging/foodplanner/lib/services/api_config.dart): client configuration · `foodplanner/lib/services/api_config.dart`
- [iOS delivery](https://github.com/aau-giraf/foodplanner/tree/staging/foodplanner/ios/Runner.xcodeproj): native packaging · `foodplanner/ios/Runner.xcodeproj`

### Feature workflows

- [Role-specific pages](https://github.com/aau-giraf/foodplanner/blob/staging/foodplanner/lib/pages/landing_page_guardian.dart): feature pages · Guardian, teacher, child, and administrator workflows. · `foodplanner/lib/pages/landing_page_guardian.dart`
- [Meal planning pages](https://github.com/aau-giraf/foodplanner/blob/staging/foodplanner/lib/pages/meal_list_page.dart): feature pages · Create, edit, list, and inspect meal plans. · `foodplanner/lib/pages/meal_list_page.dart`
- [Meal change state](https://github.com/aau-giraf/foodplanner/blob/staging/foodplanner/lib/services/meal_notifier.dart): notifier · `foodplanner/lib/services/meal_notifier.dart`
- [Pupil and class services](https://github.com/aau-giraf/foodplanner/blob/staging/foodplanner/lib/services/pupil_service.dart): data services · `foodplanner/lib/services/pupil_service.dart`
- [Feedback chat](https://github.com/aau-giraf/foodplanner/blob/staging/foodplanner/lib/pages/feedback_chat_page.dart): feature workflow · `foodplanner/lib/pages/feedback_chat_page.dart`
- [Food images](https://github.com/aau-giraf/foodplanner/blob/staging/foodplanner/lib/services/food_image_service.dart): image service and UI · Retrieval and upload-facing image behavior. · `foodplanner/lib/services/food_image_service.dart`

### Deployed services

- **ASP.NET backend**: separately deployed API
- **PostgreSQL**: relational database
- **Minio image storage**: object storage

## Connections

- Flutter runtime → App bootstrap: launches
- App bootstrap → Navigation and access: initializes
- App bootstrap → Authentication state: provides state
- Navigation and access → Role-specific pages: routes by access
- Navigation and access → Meal planning pages: routes to
- Authentication state → Auth transport: authenticates via
- Auth transport → ASP.NET backend: calls
- Meal planning pages → Meal change state: reads and updates
- Meal planning pages → Meal and ingredient services: uses
- Meal planning pages → Reusable UI components: composes
- Meal and ingredient services → API endpoint config: uses endpoint
- Meal and ingredient services → Generated API contract: uses contract
- Meal and ingredient services → ASP.NET backend: calls
- Pupil and class services → ASP.NET backend: calls
- Feedback chat → ASP.NET backend: loads messages
- Food images → Minio image storage: retrieves images
- ASP.NET backend → PostgreSQL: persists data
- iOS delivery → Flutter runtime: packages
