# xphoenixx05/food-calorie-app architecture

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

- Interactive diagram: https://gitdiagram.com/xphoenixx05/food-calorie-app
- Repository: https://github.com/xphoenixx05/food-calorie-app

## Overview

FoodVision AI combines a Flask food-recognition and nutrition application with tooling for building and checking a reusable Food Knowledge Base. In the principal user flow, an image reaches the application, the Food-101 model predicts food classes, and nutrition lookup supplies the response. Separately, data-import tools validate and write food collections, while audit and USDA-matching tools support knowledge-base quality and nutrition mapping. README capabilities such as search, analytics, and recommendations are described as future-facing; their runtime implementations are not evident in the supplied tree. Some route and service wiring is therefore omitted.

Main entry points: [`data/auditor/audit.py`](https://github.com/xphoenixx05/food-calorie-app/blob/main/data/auditor/audit.py) (Knowledge-base auditor), [`main.py`](https://github.com/xphoenixx05/food-calorie-app/blob/main/main.py) (Flask application), [`data/importer/import_food101.py`](https://github.com/xphoenixx05/food-calorie-app/blob/main/data/importer/import_food101.py) (Food-101 importer), [`data/importer/importer.py`](https://github.com/xphoenixx05/food-calorie-app/blob/main/data/importer/importer.py) (Import coordinator)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_application["Food application"]
  node_flask["Flask application<br/>[main.py]"]
  node_auth["Authentication routes<br/>[auth.py]"]
  node_user_routes["User routes<br/>[user.py]"]
  node_admin_routes["Admin routes<br/>[admin.py]"]
  node_api_routes["API routes<br/>[api.py]"]
  node_prediction_routes["Prediction routes<br/>[prediction.py]"]
  node_json_db["JSON data access<br/>[json_db.py]"]
end

subgraph group_recognition["Food recognition"]
  node_food101["Food-101 inference<br/>[food101_service.py]"]
  node_prediction_service["Name normalization"]
  node_siglip["SigLIP model<br/>[siglip_service.py]"]
end

subgraph group_nutrition["Nutrition lookup"]
  node_nutrition_service["Nutrition resolution"]
  node_usda_adapter["USDA adapter<br/>[usda_service.py]"]
  node_usda_client["USDA search client<br/>[usda_client.py]"]
end

subgraph group_knowledge["Knowledge base"]
  node_fkb[("Food Knowledge Base")]
  node_importer["Import coordinator<br/>[importer.py]"]
  node_food101_import["Food-101 importer<br/>[import_food101.py]"]
  node_source_loader["Source loading<br/>[source_loader.py]"]
  node_collection_writer["Collection writer<br/>[writer.py]"]
  node_usda_match["USDA food matching<br/>[match_foods.py]"]
end

subgraph group_quality["Data quality"]
  node_auditor["Knowledge-base auditor<br/>[audit.py]"]
  node_schema_checker["Schema checks<br/>[schema_checker.py]"]
  node_duplicate_checker["Duplicate checks"]
  node_audit_report["Audit reporting<br/>[report.py]"]
end

node_user(("End user"))
node_usda_service_external{{"USDA FoodData Central"}}

node_user -->|"uses"| node_flask
node_flask -->|"predicts with"| node_food101
node_flask -->|"looks up nutrition"| node_nutrition_service
node_flask -->|"initializes database"| node_json_db
node_usda_adapter -->|"delegates lookup"| node_nutrition_service
node_usda_client -->|"searches"| node_usda_service_external
node_food101_import -->|"loads source"| node_source_loader
node_food101_import -->|"writes collections"| node_collection_writer
node_food101_import -->|"updates collections"| node_fkb
node_importer -->|"loads sources"| node_source_loader
node_importer -->|"writes collections"| node_collection_writer
node_usda_match -->|"searches USDA"| node_usda_client
node_usda_match -->|"maps foods"| node_fkb
node_auditor -->|"checks schema"| node_schema_checker
node_auditor -->|"checks duplicates"| node_duplicate_checker
node_auditor -->|"reports results"| node_audit_report
node_auditor -->|"audits collections"| node_fkb

click node_flask "https://github.com/xphoenixx05/food-calorie-app/blob/main/main.py"
click node_auth "https://github.com/xphoenixx05/food-calorie-app/blob/main/app/routes/auth.py"
click node_user_routes "https://github.com/xphoenixx05/food-calorie-app/blob/main/app/routes/user.py"
click node_admin_routes "https://github.com/xphoenixx05/food-calorie-app/blob/main/app/routes/admin.py"
click node_api_routes "https://github.com/xphoenixx05/food-calorie-app/blob/main/app/routes/api.py"
click node_prediction_routes "https://github.com/xphoenixx05/food-calorie-app/blob/main/app/routes/prediction.py"
click node_json_db "https://github.com/xphoenixx05/food-calorie-app/blob/main/app/services/json_db.py"
click node_food101 "https://github.com/xphoenixx05/food-calorie-app/blob/main/app/services/food101_service.py"
click node_prediction_service "https://github.com/xphoenixx05/food-calorie-app/blob/main/app/services/prediction_service.py"
click node_siglip "https://github.com/xphoenixx05/food-calorie-app/blob/main/app/services/siglip_service.py"
click node_nutrition_service "https://github.com/xphoenixx05/food-calorie-app/blob/main/app/services/nutrition_service.py"
click node_usda_adapter "https://github.com/xphoenixx05/food-calorie-app/blob/main/app/services/usda_service.py"
click node_usda_client "https://github.com/xphoenixx05/food-calorie-app/blob/main/data/usda/usda_client.py"
click node_importer "https://github.com/xphoenixx05/food-calorie-app/blob/main/data/importer/importer.py"
click node_food101_import "https://github.com/xphoenixx05/food-calorie-app/blob/main/data/importer/import_food101.py"
click node_source_loader "https://github.com/xphoenixx05/food-calorie-app/blob/main/data/importer/source_loader.py"
click node_collection_writer "https://github.com/xphoenixx05/food-calorie-app/blob/main/data/importer/writer.py"
click node_usda_match "https://github.com/xphoenixx05/food-calorie-app/blob/main/data/usda/match_foods.py"
click node_auditor "https://github.com/xphoenixx05/food-calorie-app/blob/main/data/auditor/audit.py"
click node_schema_checker "https://github.com/xphoenixx05/food-calorie-app/blob/main/data/auditor/schema_checker.py"
click node_duplicate_checker "https://github.com/xphoenixx05/food-calorie-app/blob/main/data/auditor/duplicate_checker.py"
click node_audit_report "https://github.com/xphoenixx05/food-calorie-app/blob/main/data/auditor/report.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_auth,node_user_routes,node_admin_routes,node_api_routes,node_prediction_routes,node_json_db,node_user toneBlue
class node_food101,node_prediction_service,node_siglip toneAmber
class node_nutrition_service,node_usda_adapter,node_usda_client toneMint
class node_fkb,node_importer,node_food101_import,node_source_loader,node_collection_writer,node_usda_match toneRose
class node_auditor,node_schema_checker,node_duplicate_checker,node_audit_report,node_usda_service_external toneIndigo
```

## Components

### Food application

- [Flask application](https://github.com/xphoenixx05/food-calorie-app/blob/main/main.py): `main.py`
- [Authentication routes](https://github.com/xphoenixx05/food-calorie-app/blob/main/app/routes/auth.py): `app/routes/auth.py`
- [User routes](https://github.com/xphoenixx05/food-calorie-app/blob/main/app/routes/user.py): `app/routes/user.py`
- [Admin routes](https://github.com/xphoenixx05/food-calorie-app/blob/main/app/routes/admin.py): `app/routes/admin.py`
- [API routes](https://github.com/xphoenixx05/food-calorie-app/blob/main/app/routes/api.py): `app/routes/api.py`
- [Prediction routes](https://github.com/xphoenixx05/food-calorie-app/blob/main/app/routes/prediction.py): `app/routes/prediction.py`
- [JSON data access](https://github.com/xphoenixx05/food-calorie-app/blob/main/app/services/json_db.py): `app/services/json_db.py`

### Food recognition

- [Food-101 inference](https://github.com/xphoenixx05/food-calorie-app/blob/main/app/services/food101_service.py): `app/services/food101_service.py`
- [Name normalization](https://github.com/xphoenixx05/food-calorie-app/blob/main/app/services/prediction_service.py): `app/services/prediction_service.py`
- [SigLIP model](https://github.com/xphoenixx05/food-calorie-app/blob/main/app/services/siglip_service.py): `app/services/siglip_service.py`

### Nutrition lookup

- [Nutrition resolution](https://github.com/xphoenixx05/food-calorie-app/blob/main/app/services/nutrition_service.py): `app/services/nutrition_service.py`
- [USDA adapter](https://github.com/xphoenixx05/food-calorie-app/blob/main/app/services/usda_service.py): `app/services/usda_service.py`
- [USDA search client](https://github.com/xphoenixx05/food-calorie-app/blob/main/data/usda/usda_client.py): `data/usda/usda_client.py`

### Knowledge base

- **Food Knowledge Base**
- [Import coordinator](https://github.com/xphoenixx05/food-calorie-app/blob/main/data/importer/importer.py): `data/importer/importer.py`
- [Food-101 importer](https://github.com/xphoenixx05/food-calorie-app/blob/main/data/importer/import_food101.py): `data/importer/import_food101.py`
- [Source loading](https://github.com/xphoenixx05/food-calorie-app/blob/main/data/importer/source_loader.py): `data/importer/source_loader.py`
- [Collection writer](https://github.com/xphoenixx05/food-calorie-app/blob/main/data/importer/writer.py): `data/importer/writer.py`
- [USDA food matching](https://github.com/xphoenixx05/food-calorie-app/blob/main/data/usda/match_foods.py): `data/usda/match_foods.py`

### Data quality

- [Knowledge-base auditor](https://github.com/xphoenixx05/food-calorie-app/blob/main/data/auditor/audit.py): `data/auditor/audit.py`
- [Schema checks](https://github.com/xphoenixx05/food-calorie-app/blob/main/data/auditor/schema_checker.py): `data/auditor/schema_checker.py`
- [Duplicate checks](https://github.com/xphoenixx05/food-calorie-app/blob/main/data/auditor/duplicate_checker.py): `data/auditor/duplicate_checker.py`
- [Audit reporting](https://github.com/xphoenixx05/food-calorie-app/blob/main/data/auditor/report.py): `data/auditor/report.py`

### Other components

- **End user**
- **USDA FoodData Central**

## Connections

- End user → Flask application: uses
- Flask application → Food-101 inference: predicts with
- Flask application → Nutrition resolution: looks up nutrition
- Flask application → JSON data access: initializes database
- USDA adapter → Nutrition resolution: delegates lookup
- USDA search client → USDA FoodData Central: searches
- Food-101 importer → Source loading: loads source
- Food-101 importer → Collection writer: writes collections
- Food-101 importer → Food Knowledge Base: updates collections
- Import coordinator → Source loading: loads sources
- Import coordinator → Collection writer: writes collections
- USDA food matching → USDA search client: searches USDA
- USDA food matching → Food Knowledge Base: maps foods
- Knowledge-base auditor → Schema checks: checks schema
- Knowledge-base auditor → Duplicate checks: checks duplicates
- Knowledge-base auditor → Audit reporting: reports results
- Knowledge-base auditor → Food Knowledge Base: audits collections
