# karthik1804-ui/food-label-verification-system architecture

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

- Interactive diagram: https://gitdiagram.com/karthik1804-ui/food-label-verification-system
- Repository: https://github.com/karthik1804-ui/food-label-verification-system

## Overview

This is a consumer food-label verification system with two intentionally separate analyses: barcode-based product identity and ingredient-based dietary/safety evaluation. Users scan a barcode or submit label text/image; the frontend sends analysis requests to Flask, which combines product lookup, parsing, scoring, personalized checks, and audit evaluation, then presents results and supports history, profiles, and review. The README documents major capabilities not fully shown in excerpts; those subsystems are included, with unverified connections omitted or marked dashed.

Main entry points: [`backend/app.py`](https://github.com/karthik1804-ui/food-label-verification-system/blob/main/backend/app.py) (API controller), [`frontend/src/api.js`](https://github.com/karthik1804-ui/food-label-verification-system/blob/main/frontend/src/api.js) (API client), [`frontend/src/App.js`](https://github.com/karthik1804-ui/food-label-verification-system/blob/main/frontend/src/App.js) (Workflow UI), [`backend/services/auth_service.py`](https://github.com/karthik1804-ui/food-label-verification-system/blob/main/backend/services/auth_service.py) (Authentication and profiles)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Consumer interface"]
  node_app["Workflow UI<br/>[App.js]"]
  node_api["API client<br/>[api.js]"]
  node_scanner["Product scanning"]
  node_results["Analysis results"]
  node_icons["UI icons<br/>[Icons.jsx]"]
end

subgraph group_identity["Product identity"]
  node_barcode_decode["Image barcode decode<br/>[barcode_decoder.py]"]
  node_barcode_lookup["EAN validation and lookup<br/>[barcode.py]"]
end

subgraph group_analysis["Label analysis"]
  node_flask["API controller<br/>[app.py]"]
  node_ocr["Image preprocessing and OCR gate<br/>[ocr_service.py]"]
  node_parser["Ingredient taxonomy parser<br/>[parser.py]"]
  node_safety["Safety scoring<br/>[scoring_engine.py]"]
  node_personal["Dietary preference evaluation"]
  node_counterfactual["Reformulation suggestions<br/>[counterfactual.py]"]
  node_regulatory["Regulatory checks"]
end

subgraph group_accounts["Accounts and records"]
  node_auth_ui["Account interface<br/>[AuthCard.jsx]"]
  node_auth["Authentication and profiles<br/>[auth_service.py]"]
  node_history_ui["Scan history"]
  node_personal_scoring["History and personal scoring"]
  node_entities["User and profile entities<br/>[user.py]"]
  node_profile_entity["Dietary profile entity<br/>[profile.py]"]
  node_analysis_entity["Analysis record entity<br/>[analysis.py]"]
  node_database[("SQLite database<br/>[database.py]")]
end

subgraph group_review["Human review"]
  node_audit_engine["Confidence audit<br/>[audit.py]"]
  node_audit_ui["Audit queue"]
end

node_consumer(("Consumer"))

node_consumer -->|"uses"| node_app
node_app -->|"renders"| node_scanner
node_app -->|"renders"| node_results
node_app -->|"submits analysis"| node_api
node_app -->|"preprocesses image"| node_api
node_app -->|"renders"| node_icons
node_scanner -->|"uses"| node_icons
node_results -->|"uses"| node_icons
node_api -->|"sends HTTP requests"| node_flask
node_flask -->|"validates and looks up"| node_barcode_lookup
node_flask -->|"parses ingredients"| node_parser
node_flask -->|"scores product"| node_safety
node_flask -->|"checks preferences"| node_personal
node_flask -->|"requests suggestions"| node_counterfactual
node_flask -->|"evaluates confidence"| node_audit_engine
node_flask -->|"preprocesses image"| node_ocr
node_flask -->|"decodes image barcode"| node_barcode_decode
node_barcode_decode -->|"uses validation"| node_barcode_lookup
node_flask -->|"checks regulations"| node_regulatory
node_flask -->|"persists scan"| node_personal_scoring
node_auth_ui -->|"registers and logs in"| node_api
node_api -.->|"requests authentication"| node_auth
node_auth -->|"uses SQLite"| node_database
node_auth -.->|"uses user model"| node_entities
node_auth -.->|"uses profile model"| node_profile_entity
node_history_ui -->|"requests history"| node_api
node_api -.->|"requests history"| node_personal_scoring
node_personal_scoring -->|"uses SQLite"| node_database
node_personal_scoring -.->|"uses analysis records"| node_analysis_entity
node_audit_ui -->|"submits review actions"| node_api
node_api -.->|"requests audit operations"| node_audit_engine
node_audit_engine -.->|"persists audit queue"| node_database

click node_app "https://github.com/karthik1804-ui/food-label-verification-system/blob/main/frontend/src/App.js"
click node_api "https://github.com/karthik1804-ui/food-label-verification-system/blob/main/frontend/src/api.js"
click node_scanner "https://github.com/karthik1804-ui/food-label-verification-system/blob/main/frontend/src/components/ProductScanningView.jsx"
click node_results "https://github.com/karthik1804-ui/food-label-verification-system/blob/main/frontend/src/components/AnalysisResultsView.jsx"
click node_icons "https://github.com/karthik1804-ui/food-label-verification-system/blob/main/frontend/src/components/Icons.jsx"
click node_flask "https://github.com/karthik1804-ui/food-label-verification-system/blob/main/backend/app.py"
click node_barcode_decode "https://github.com/karthik1804-ui/food-label-verification-system/blob/main/backend/services/barcode_decoder.py"
click node_barcode_lookup "https://github.com/karthik1804-ui/food-label-verification-system/blob/main/backend/services/barcode.py"
click node_ocr "https://github.com/karthik1804-ui/food-label-verification-system/blob/main/backend/services/ocr_service.py"
click node_parser "https://github.com/karthik1804-ui/food-label-verification-system/blob/main/backend/services/parser.py"
click node_safety "https://github.com/karthik1804-ui/food-label-verification-system/blob/main/backend/services/scoring_engine.py"
click node_personal "https://github.com/karthik1804-ui/food-label-verification-system/blob/main/backend/services/preference_engine.py"
click node_counterfactual "https://github.com/karthik1804-ui/food-label-verification-system/blob/main/backend/services/counterfactual.py"
click node_regulatory "https://github.com/karthik1804-ui/food-label-verification-system/blob/main/backend/services/regulatory_checker.py"
click node_audit_engine "https://github.com/karthik1804-ui/food-label-verification-system/blob/main/backend/services/audit.py"
click node_audit_ui "https://github.com/karthik1804-ui/food-label-verification-system/blob/main/frontend/src/components/AuditQueueModal.jsx"
click node_auth_ui "https://github.com/karthik1804-ui/food-label-verification-system/blob/main/frontend/src/components/AuthCard.jsx"
click node_auth "https://github.com/karthik1804-ui/food-label-verification-system/blob/main/backend/services/auth_service.py"
click node_history_ui "https://github.com/karthik1804-ui/food-label-verification-system/blob/main/frontend/src/components/AnalysisHistoryView.jsx"
click node_personal_scoring "https://github.com/karthik1804-ui/food-label-verification-system/blob/main/backend/services/personal_scoring.py"
click node_entities "https://github.com/karthik1804-ui/food-label-verification-system/blob/main/backend/models/user.py"
click node_profile_entity "https://github.com/karthik1804-ui/food-label-verification-system/blob/main/backend/models/profile.py"
click node_analysis_entity "https://github.com/karthik1804-ui/food-label-verification-system/blob/main/backend/models/analysis.py"
click node_database "https://github.com/karthik1804-ui/food-label-verification-system/blob/main/backend/models/database.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_app,node_api,node_scanner,node_results,node_icons toneBlue
class node_barcode_decode,node_barcode_lookup toneAmber
class node_flask,node_ocr,node_parser,node_safety,node_personal,node_counterfactual,node_regulatory toneMint
class node_auth_ui,node_auth,node_history_ui,node_personal_scoring,node_entities,node_profile_entity,node_analysis_entity,node_database toneRose
class node_audit_engine,node_audit_ui,node_consumer toneIndigo
```

## Components

### Consumer interface

- [Workflow UI](https://github.com/karthik1804-ui/food-label-verification-system/blob/main/frontend/src/App.js): `frontend/src/App.js`
- [API client](https://github.com/karthik1804-ui/food-label-verification-system/blob/main/frontend/src/api.js): `frontend/src/api.js`
- [Product scanning](https://github.com/karthik1804-ui/food-label-verification-system/blob/main/frontend/src/components/ProductScanningView.jsx): `frontend/src/components/ProductScanningView.jsx`
- [Analysis results](https://github.com/karthik1804-ui/food-label-verification-system/blob/main/frontend/src/components/AnalysisResultsView.jsx): `frontend/src/components/AnalysisResultsView.jsx`
- [UI icons](https://github.com/karthik1804-ui/food-label-verification-system/blob/main/frontend/src/components/Icons.jsx): `frontend/src/components/Icons.jsx`

### Product identity

- [Image barcode decode](https://github.com/karthik1804-ui/food-label-verification-system/blob/main/backend/services/barcode_decoder.py): `backend/services/barcode_decoder.py`
- [EAN validation and lookup](https://github.com/karthik1804-ui/food-label-verification-system/blob/main/backend/services/barcode.py): `backend/services/barcode.py`

### Label analysis

- [API controller](https://github.com/karthik1804-ui/food-label-verification-system/blob/main/backend/app.py): `backend/app.py`
- [Image preprocessing and OCR gate](https://github.com/karthik1804-ui/food-label-verification-system/blob/main/backend/services/ocr_service.py): `backend/services/ocr_service.py`
- [Ingredient taxonomy parser](https://github.com/karthik1804-ui/food-label-verification-system/blob/main/backend/services/parser.py): `backend/services/parser.py`
- [Safety scoring](https://github.com/karthik1804-ui/food-label-verification-system/blob/main/backend/services/scoring_engine.py): `backend/services/scoring_engine.py`
- [Dietary preference evaluation](https://github.com/karthik1804-ui/food-label-verification-system/blob/main/backend/services/preference_engine.py): `backend/services/preference_engine.py`
- [Reformulation suggestions](https://github.com/karthik1804-ui/food-label-verification-system/blob/main/backend/services/counterfactual.py): `backend/services/counterfactual.py`
- [Regulatory checks](https://github.com/karthik1804-ui/food-label-verification-system/blob/main/backend/services/regulatory_checker.py): `backend/services/regulatory_checker.py`

### Accounts and records

- [Account interface](https://github.com/karthik1804-ui/food-label-verification-system/blob/main/frontend/src/components/AuthCard.jsx): `frontend/src/components/AuthCard.jsx`
- [Authentication and profiles](https://github.com/karthik1804-ui/food-label-verification-system/blob/main/backend/services/auth_service.py): `backend/services/auth_service.py`
- [Scan history](https://github.com/karthik1804-ui/food-label-verification-system/blob/main/frontend/src/components/AnalysisHistoryView.jsx): `frontend/src/components/AnalysisHistoryView.jsx`
- [History and personal scoring](https://github.com/karthik1804-ui/food-label-verification-system/blob/main/backend/services/personal_scoring.py): `backend/services/personal_scoring.py`
- [User and profile entities](https://github.com/karthik1804-ui/food-label-verification-system/blob/main/backend/models/user.py): `backend/models/user.py`
- [Dietary profile entity](https://github.com/karthik1804-ui/food-label-verification-system/blob/main/backend/models/profile.py): `backend/models/profile.py`
- [Analysis record entity](https://github.com/karthik1804-ui/food-label-verification-system/blob/main/backend/models/analysis.py): `backend/models/analysis.py`
- [SQLite database](https://github.com/karthik1804-ui/food-label-verification-system/blob/main/backend/models/database.py): `backend/models/database.py`

### Human review

- [Confidence audit](https://github.com/karthik1804-ui/food-label-verification-system/blob/main/backend/services/audit.py): `backend/services/audit.py`
- [Audit queue](https://github.com/karthik1804-ui/food-label-verification-system/blob/main/frontend/src/components/AuditQueueModal.jsx): `frontend/src/components/AuditQueueModal.jsx`

### Other components

- **Consumer**

## Connections

- Consumer → Workflow UI: uses
- Workflow UI → Product scanning: renders (evidence: `frontend/src/App.js`)
- Workflow UI → Analysis results: renders (evidence: `frontend/src/App.js`)
- Workflow UI → API client: submits analysis (evidence: `frontend/src/App.js`)
- Workflow UI → API client: preprocesses image (evidence: `frontend/src/App.js`)
- Workflow UI → UI icons: renders (evidence: `frontend/src/App.js`)
- Product scanning → UI icons: uses (evidence: `frontend/src/components/ProductScanningView.jsx`)
- Analysis results → UI icons: uses (evidence: `frontend/src/components/AnalysisResultsView.jsx`)
- API client → API controller: sends HTTP requests (evidence: `frontend/src/api.js`)
- API controller → EAN validation and lookup: validates and looks up (evidence: `backend/app.py`)
- API controller → Ingredient taxonomy parser: parses ingredients (evidence: `backend/app.py`)
- API controller → Safety scoring: scores product (evidence: `backend/app.py`)
- API controller → Dietary preference evaluation: checks preferences (evidence: `backend/app.py`)
- API controller → Reformulation suggestions: requests suggestions (evidence: `backend/app.py`)
- API controller → Confidence audit: evaluates confidence (evidence: `backend/app.py`)
- API controller → Image preprocessing and OCR gate: preprocesses image (evidence: `backend/app.py`)
- API controller → Image barcode decode: decodes image barcode (evidence: `backend/app.py`)
- Image barcode decode → EAN validation and lookup: uses validation (evidence: `backend/services/barcode_decoder.py`)
- API controller → Regulatory checks: checks regulations (evidence: `backend/app.py`)
- API controller → History and personal scoring: persists scan (evidence: `backend/app.py`)
- Account interface → API client: registers and logs in (evidence: `frontend/src/components/AuthCard.jsx`)
- API client → Authentication and profiles: requests authentication
- Authentication and profiles → SQLite database: uses SQLite (evidence: `backend/services/auth_service.py`)
- Authentication and profiles → User and profile entities: uses user model
- Authentication and profiles → Dietary profile entity: uses profile model
- Scan history → API client: requests history (evidence: `frontend/src/components/AnalysisHistoryView.jsx`)
- API client → History and personal scoring: requests history
- History and personal scoring → SQLite database: uses SQLite (evidence: `backend/services/personal_scoring.py`)
- History and personal scoring → Analysis record entity: uses analysis records (evidence: `backend/models/analysis.py`)
- Audit queue → API client: submits review actions (evidence: `frontend/src/components/AuditQueueModal.jsx`)
- API client → Confidence audit: requests audit operations
- Confidence audit → SQLite database: persists audit queue
