# shubham0207k/food-calorie-app architecture

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

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

## Overview

FoodVision AI recognizes food images, returns predictions, and can enrich results with nutrition data. Its broader documented architecture centers on a reusable Food Knowledge Base, populated by import workflows and checked by an auditor; USDA matching supports nutrition lookup and data mapping. The sampled Flask entry point and service excerpts substantiate parts of the runtime path, while the tree and README identify other major subsystems. Some route and importer internals were not sampled, so uncertain links are omitted or marked unverified.

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

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Recognition and nutrition"]
  node_flask["Flask application<br/>[main.py]"]
  node_recognizer["Food-101 recognition<br/>[food101_service.py]"]
  node_normalizer["Prediction normalization"]
  node_nutrition["Nutrition lookup"]
  node_jsondb["JSON data access<br/>[json_db.py]"]
end

subgraph group_knowledge["Food knowledge base"]
  node_fkb[("Food Knowledge Base")]
  node_importers["Food import workflows"]
  node_food101import["Food-101 importer<br/>[import_food101.py]"]
  node_fruitimport["Fruit importer<br/>[import_fruits.py]"]
  node_vegetableimport["Vegetable importer"]
  node_source_loader["Import source loading<br/>[source_loader.py]"]
  node_validator["Food schema validation<br/>[validator.py]"]
  node_writer["Collection writer<br/>[writer.py]"]
end

subgraph group_usda["USDA integration"]
  node_usda_matcher["USDA food matching<br/>[matcher.py]"]
  node_usda_client["USDA search client<br/>[usda_client.py]"]
  node_confidence["Match confidence<br/>[confidence.py]"]
end

subgraph group_quality["Knowledge-base quality"]
  node_audit["Knowledge-base audit<br/>[audit.py]"]
  node_manifest["Manifest checks"]
  node_schema["Collection schema checks<br/>[schema_checker.py]"]
  node_duplicates["Duplicate checks"]
  node_statistics["Audit statistics<br/>[statistics.py]"]
  node_audit_report["Audit reports<br/>[report.py]"]
end

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

node_user -->|"uses"| node_flask
node_flask -.->|"predicts with"| node_recognizer
node_flask -.->|"normalizes"| node_normalizer
node_flask -->|"looks up"| node_nutrition
node_flask -.->|"reads and writes"| node_jsondb
node_nutrition -->|"matches food"| node_usda_matcher
node_nutrition -->|"searches"| node_usda_client
node_usda_matcher -->|"searches candidates"| node_usda_client
node_usda_matcher -->|"scores match"| node_confidence
node_usda_client -->|"queries"| node_usda
node_food101import -->|"loads source"| node_source_loader
node_food101import -->|"validates records"| node_validator
node_food101import -->|"writes collections"| node_writer
node_fruitimport -->|"loads source"| node_source_loader
node_fruitimport -->|"validates records"| node_validator
node_fruitimport -->|"writes collections"| node_writer
node_vegetableimport -->|"loads source"| node_source_loader
node_vegetableimport -->|"validates records"| node_validator
node_vegetableimport -->|"writes collections"| node_writer
node_food101import -->|"populates"| node_fkb
node_fruitimport -.->|"populates"| node_fkb
node_vegetableimport -.->|"populates"| node_fkb
node_nutrition -.->|"reads food records"| node_fkb
node_audit -->|"checks manifest"| node_manifest
node_audit -->|"checks schema"| node_schema
node_audit -->|"checks duplicates"| node_duplicates
node_audit -->|"computes statistics"| node_statistics
node_audit -.->|"produces report"| node_audit_report
node_schema -->|"validates with"| node_validator

click node_flask "https://github.com/shubham0207k/food-calorie-app/blob/main/main.py"
click node_recognizer "https://github.com/shubham0207k/food-calorie-app/blob/main/app/services/food101_service.py"
click node_normalizer "https://github.com/shubham0207k/food-calorie-app/blob/main/app/services/prediction_service.py"
click node_nutrition "https://github.com/shubham0207k/food-calorie-app/blob/main/app/services/nutrition_service.py"
click node_jsondb "https://github.com/shubham0207k/food-calorie-app/blob/main/app/services/json_db.py"
click node_importers "https://github.com/shubham0207k/food-calorie-app/tree/main/data/importer"
click node_food101import "https://github.com/shubham0207k/food-calorie-app/blob/main/data/importer/import_food101.py"
click node_fruitimport "https://github.com/shubham0207k/food-calorie-app/blob/main/data/importer/import_fruits.py"
click node_vegetableimport "https://github.com/shubham0207k/food-calorie-app/blob/main/data/importer/import_vegetables.py"
click node_source_loader "https://github.com/shubham0207k/food-calorie-app/blob/main/data/importer/source_loader.py"
click node_validator "https://github.com/shubham0207k/food-calorie-app/blob/main/data/importer/validator.py"
click node_writer "https://github.com/shubham0207k/food-calorie-app/blob/main/data/importer/writer.py"
click node_usda_matcher "https://github.com/shubham0207k/food-calorie-app/blob/main/data/usda/matcher.py"
click node_usda_client "https://github.com/shubham0207k/food-calorie-app/blob/main/data/usda/usda_client.py"
click node_confidence "https://github.com/shubham0207k/food-calorie-app/blob/main/data/usda/confidence.py"
click node_audit "https://github.com/shubham0207k/food-calorie-app/blob/main/data/auditor/audit.py"
click node_manifest "https://github.com/shubham0207k/food-calorie-app/blob/main/data/auditor/manifest_checker.py"
click node_schema "https://github.com/shubham0207k/food-calorie-app/blob/main/data/auditor/schema_checker.py"
click node_duplicates "https://github.com/shubham0207k/food-calorie-app/blob/main/data/auditor/duplicate_checker.py"
click node_statistics "https://github.com/shubham0207k/food-calorie-app/blob/main/data/auditor/statistics.py"
click node_audit_report "https://github.com/shubham0207k/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_recognizer,node_normalizer,node_nutrition,node_jsondb,node_user toneBlue
class node_fkb,node_importers,node_food101import,node_fruitimport,node_vegetableimport,node_source_loader,node_validator,node_writer toneAmber
class node_usda_matcher,node_usda_client,node_confidence toneMint
class node_audit,node_manifest,node_schema,node_duplicates,node_statistics,node_audit_report toneRose
class node_usda toneIndigo
```

## Components

### Recognition and nutrition

- [Flask application](https://github.com/shubham0207k/food-calorie-app/blob/main/main.py): `main.py`
- [Food-101 recognition](https://github.com/shubham0207k/food-calorie-app/blob/main/app/services/food101_service.py): `app/services/food101_service.py`
- [Prediction normalization](https://github.com/shubham0207k/food-calorie-app/blob/main/app/services/prediction_service.py): `app/services/prediction_service.py`
- [Nutrition lookup](https://github.com/shubham0207k/food-calorie-app/blob/main/app/services/nutrition_service.py): `app/services/nutrition_service.py`
- [JSON data access](https://github.com/shubham0207k/food-calorie-app/blob/main/app/services/json_db.py): `app/services/json_db.py`

### Food knowledge base

- **Food Knowledge Base**
- [Food import workflows](https://github.com/shubham0207k/food-calorie-app/tree/main/data/importer): `data/importer`
- [Food-101 importer](https://github.com/shubham0207k/food-calorie-app/blob/main/data/importer/import_food101.py): `data/importer/import_food101.py`
- [Fruit importer](https://github.com/shubham0207k/food-calorie-app/blob/main/data/importer/import_fruits.py): `data/importer/import_fruits.py`
- [Vegetable importer](https://github.com/shubham0207k/food-calorie-app/blob/main/data/importer/import_vegetables.py): `data/importer/import_vegetables.py`
- [Import source loading](https://github.com/shubham0207k/food-calorie-app/blob/main/data/importer/source_loader.py): `data/importer/source_loader.py`
- [Food schema validation](https://github.com/shubham0207k/food-calorie-app/blob/main/data/importer/validator.py): `data/importer/validator.py`
- [Collection writer](https://github.com/shubham0207k/food-calorie-app/blob/main/data/importer/writer.py): `data/importer/writer.py`

### USDA integration

- [USDA food matching](https://github.com/shubham0207k/food-calorie-app/blob/main/data/usda/matcher.py): `data/usda/matcher.py`
- [USDA search client](https://github.com/shubham0207k/food-calorie-app/blob/main/data/usda/usda_client.py): `data/usda/usda_client.py`
- [Match confidence](https://github.com/shubham0207k/food-calorie-app/blob/main/data/usda/confidence.py): `data/usda/confidence.py`

### Knowledge-base quality

- [Knowledge-base audit](https://github.com/shubham0207k/food-calorie-app/blob/main/data/auditor/audit.py): `data/auditor/audit.py`
- [Manifest checks](https://github.com/shubham0207k/food-calorie-app/blob/main/data/auditor/manifest_checker.py): `data/auditor/manifest_checker.py`
- [Collection schema checks](https://github.com/shubham0207k/food-calorie-app/blob/main/data/auditor/schema_checker.py): `data/auditor/schema_checker.py`
- [Duplicate checks](https://github.com/shubham0207k/food-calorie-app/blob/main/data/auditor/duplicate_checker.py): `data/auditor/duplicate_checker.py`
- [Audit statistics](https://github.com/shubham0207k/food-calorie-app/blob/main/data/auditor/statistics.py): `data/auditor/statistics.py`
- [Audit reports](https://github.com/shubham0207k/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 (evidence: `README.md`)
- Flask application → Food-101 recognition: predicts with (evidence: `main.py`)
- Flask application → Prediction normalization: normalizes (evidence: `main.py`)
- Flask application → Nutrition lookup: looks up (evidence: `main.py`)
- Flask application → JSON data access: reads and writes (evidence: `main.py`)
- Nutrition lookup → USDA food matching: matches food (evidence: `app/services/nutrition_service.py`)
- Nutrition lookup → USDA search client: searches (evidence: `app/services/nutrition_service.py`)
- USDA food matching → USDA search client: searches candidates (evidence: `data/usda/matcher.py`)
- USDA food matching → Match confidence: scores match (evidence: `data/usda/matcher.py`)
- USDA search client → USDA FoodData Central: queries (evidence: `data/usda/usda_client.py`)
- Food-101 importer → Import source loading: loads source (evidence: `data/importer/import_food101.py`)
- Food-101 importer → Food schema validation: validates records (evidence: `data/importer/import_food101.py`)
- Food-101 importer → Collection writer: writes collections (evidence: `data/importer/import_food101.py`)
- Fruit importer → Import source loading: loads source (evidence: `data/importer/import_fruits.py`)
- Fruit importer → Food schema validation: validates records (evidence: `data/importer/import_fruits.py`)
- Fruit importer → Collection writer: writes collections (evidence: `data/importer/import_fruits.py`)
- Vegetable importer → Import source loading: loads source (evidence: `data/importer/import_vegetables.py`)
- Vegetable importer → Food schema validation: validates records (evidence: `data/importer/import_vegetables.py`)
- Vegetable importer → Collection writer: writes collections (evidence: `data/importer/import_vegetables.py`)
- Food-101 importer → Food Knowledge Base: populates (evidence: `data/importer/import_food101.py`)
- Fruit importer → Food Knowledge Base: populates
- Vegetable importer → Food Knowledge Base: populates
- Nutrition lookup → Food Knowledge Base: reads food records
- Knowledge-base audit → Manifest checks: checks manifest (evidence: `data/auditor/audit.py`)
- Knowledge-base audit → Collection schema checks: checks schema (evidence: `data/auditor/audit.py`)
- Knowledge-base audit → Duplicate checks: checks duplicates (evidence: `data/auditor/audit.py`)
- Knowledge-base audit → Audit statistics: computes statistics (evidence: `data/auditor/audit.py`)
- Knowledge-base audit → Audit reports: produces report
- Collection schema checks → Food schema validation: validates with (evidence: `data/auditor/schema_checker.py`)
