# vaibhavsh0120/unlabel architecture

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

- Interactive diagram: https://gitdiagram.com/vaibhavsh0120/unlabel
- Repository: https://github.com/vaibhavsh0120/unlabel

## Overview

Unlabel is a packaged-food label understanding product: users look up or discover a product, inspect sourced facts and missing-data states, and receive claim checks and a composed report. The backend also supports community observations, comparison, research discovery, and optional AI extraction. The supplied tree does not include the Flutter application source, so the graph focuses on evidenced backend behavior and treats the user as the external initiator. Some route and integration wiring is documented or indexed but not shown in full; those links are marked dashed where implementation evidence is limited.

Main entry points: [`backend/app/catalogue/store.py`](https://github.com/vaibhavsh0120/unlabel/blob/main/backend/app/catalogue/store.py) (Product catalogue), [`backend/app/community/service.py`](https://github.com/vaibhavsh0120/unlabel/blob/main/backend/app/community/service.py) (Submission preparation), [`backend/app/main.py`](https://github.com/vaibhavsh0120/unlabel/blob/main/backend/app/main.py) (FastAPI entry), [`backend/app/services/parsing/nutrition.py`](https://github.com/vaibhavsh0120/unlabel/blob/main/backend/app/services/parsing/nutrition.py) (Nutrition normalization)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API and lookup"]
  node_api["FastAPI entry<br/>[main.py]"]
  node_catalogue[("Product catalogue<br/>[store.py]")]
  node_discovery["Catalogue search<br/>[search.py]"]
end

subgraph group_evidence["Product evidence"]
  node_facts["Sourced facts<br/>[facts.py]"]
  node_liveoff["Live OFF provider<br/>[open_food_facts.py]"]
  node_livenutrition["Live nutrition provider<br/>[nutrition.py]"]
end

subgraph group_analysis["Label analysis"]
  node_normalization["Nutrition normalization<br/>[nutrition.py]"]
  node_claimrules["Reviewed claim rules<br/>[knowledge.py]"]
  node_claimengine["Claim assessment<br/>[engine.py]"]
  node_report["Report composition<br/>[service.py]"]
  node_glossary["Ingredient glossary<br/>[glossary.py]"]
  node_comparison["Product comparison<br/>[service.py]"]
end

subgraph group_community["Community data"]
  node_communityapi["Community API<br/>[community.py]"]
  node_communityprep["Submission preparation<br/>[service.py]"]
  node_resolver["Evidence resolver<br/>[resolver.py]"]
  node_communitydb[("Community observations<br/>[store.py]")]
  node_accounts[("Account snapshots<br/>[store.py]")]
end

subgraph group_extensions["Optional capabilities"]
  node_research[("Research catalogue<br/>[store.py]")]
  node_researchapi["Research discovery API<br/>[router.py]"]
  node_aiapi["AI extraction API<br/>[router.py]"]
  node_aigateway["AI provider gateway<br/>[gateway.py]"]
  node_aistaging[("Private AI staging<br/>[store.py]")]
end

node_person(("App user"))

node_person -->|"requests lookup"| node_api
node_api -.->|"reads products"| node_catalogue
node_api -.->|"routes search"| node_discovery
node_catalogue -->|"builds facts"| node_facts
node_catalogue -->|"supports search"| node_discovery
node_person -.->|"requests live data"| node_liveoff
node_person -.->|"requests live data"| node_livenutrition
node_facts -->|"normalizes tables"| node_normalization
node_claimengine -->|"loads rules"| node_claimrules
node_report -->|"assesses claims"| node_claimengine
node_report -->|"adds definitions"| node_glossary
node_comparison -->|"reads facts"| node_catalogue
node_comparison -->|"normalizes inputs"| node_normalization
node_communityapi -.->|"prepares submissions"| node_communityprep
node_communityprep -->|"normalizes rows"| node_normalization
node_communityprep -->|"checks conflicts"| node_resolver
node_communitydb -->|"uses preparation"| node_communityprep
node_accounts -.->|"shares account models"| node_communitydb
node_researchapi -->|"queries index"| node_research
node_aiapi -->|"runs extraction"| node_aigateway
node_aigateway -->|"stores private results"| node_aistaging

click node_api "https://github.com/vaibhavsh0120/unlabel/blob/main/backend/app/main.py"
click node_catalogue "https://github.com/vaibhavsh0120/unlabel/blob/main/backend/app/catalogue/store.py"
click node_discovery "https://github.com/vaibhavsh0120/unlabel/blob/main/backend/app/catalogue/search.py"
click node_facts "https://github.com/vaibhavsh0120/unlabel/blob/main/backend/app/catalogue/facts.py"
click node_liveoff "https://github.com/vaibhavsh0120/unlabel/blob/main/backend/app/providers/products/open_food_facts.py"
click node_livenutrition "https://github.com/vaibhavsh0120/unlabel/blob/main/backend/app/providers/products/nutrition.py"
click node_normalization "https://github.com/vaibhavsh0120/unlabel/blob/main/backend/app/services/parsing/nutrition.py"
click node_claimrules "https://github.com/vaibhavsh0120/unlabel/blob/main/backend/app/claims/knowledge.py"
click node_claimengine "https://github.com/vaibhavsh0120/unlabel/blob/main/backend/app/claims/engine.py"
click node_report "https://github.com/vaibhavsh0120/unlabel/blob/main/backend/app/reports/service.py"
click node_glossary "https://github.com/vaibhavsh0120/unlabel/blob/main/backend/app/reports/glossary.py"
click node_comparison "https://github.com/vaibhavsh0120/unlabel/blob/main/backend/app/comparison/service.py"
click node_communityapi "https://github.com/vaibhavsh0120/unlabel/blob/main/backend/app/api/v1/community.py"
click node_communityprep "https://github.com/vaibhavsh0120/unlabel/blob/main/backend/app/community/service.py"
click node_resolver "https://github.com/vaibhavsh0120/unlabel/blob/main/backend/app/community/resolver.py"
click node_communitydb "https://github.com/vaibhavsh0120/unlabel/blob/main/backend/app/community/store.py"
click node_accounts "https://github.com/vaibhavsh0120/unlabel/blob/main/backend/app/accounts/store.py"
click node_research "https://github.com/vaibhavsh0120/unlabel/blob/main/backend/app/research_catalogue/store.py"
click node_researchapi "https://github.com/vaibhavsh0120/unlabel/blob/main/backend/app/research_catalogue/router.py"
click node_aiapi "https://github.com/vaibhavsh0120/unlabel/blob/main/backend/app/ai/router.py"
click node_aigateway "https://github.com/vaibhavsh0120/unlabel/blob/main/backend/app/ai/gateway.py"
click node_aistaging "https://github.com/vaibhavsh0120/unlabel/blob/main/backend/app/ai/store.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_api,node_catalogue,node_discovery,node_person toneBlue
class node_facts,node_liveoff,node_livenutrition toneAmber
class node_normalization,node_claimrules,node_claimengine,node_report,node_glossary,node_comparison toneMint
class node_communityapi,node_communityprep,node_resolver,node_communitydb,node_accounts toneRose
class node_research,node_researchapi,node_aiapi,node_aigateway,node_aistaging toneIndigo
```

## Components

### API and lookup

- [FastAPI entry](https://github.com/vaibhavsh0120/unlabel/blob/main/backend/app/main.py): `backend/app/main.py`
- [Product catalogue](https://github.com/vaibhavsh0120/unlabel/blob/main/backend/app/catalogue/store.py): `backend/app/catalogue/store.py`
- [Catalogue search](https://github.com/vaibhavsh0120/unlabel/blob/main/backend/app/catalogue/search.py): `backend/app/catalogue/search.py`

### Product evidence

- [Sourced facts](https://github.com/vaibhavsh0120/unlabel/blob/main/backend/app/catalogue/facts.py): `backend/app/catalogue/facts.py`
- [Live OFF provider](https://github.com/vaibhavsh0120/unlabel/blob/main/backend/app/providers/products/open_food_facts.py): `backend/app/providers/products/open_food_facts.py`
- [Live nutrition provider](https://github.com/vaibhavsh0120/unlabel/blob/main/backend/app/providers/products/nutrition.py): `backend/app/providers/products/nutrition.py`

### Label analysis

- [Nutrition normalization](https://github.com/vaibhavsh0120/unlabel/blob/main/backend/app/services/parsing/nutrition.py): `backend/app/services/parsing/nutrition.py`
- [Reviewed claim rules](https://github.com/vaibhavsh0120/unlabel/blob/main/backend/app/claims/knowledge.py): `backend/app/claims/knowledge.py`
- [Claim assessment](https://github.com/vaibhavsh0120/unlabel/blob/main/backend/app/claims/engine.py): `backend/app/claims/engine.py`
- [Report composition](https://github.com/vaibhavsh0120/unlabel/blob/main/backend/app/reports/service.py): `backend/app/reports/service.py`
- [Ingredient glossary](https://github.com/vaibhavsh0120/unlabel/blob/main/backend/app/reports/glossary.py): `backend/app/reports/glossary.py`
- [Product comparison](https://github.com/vaibhavsh0120/unlabel/blob/main/backend/app/comparison/service.py): `backend/app/comparison/service.py`

### Community data

- [Community API](https://github.com/vaibhavsh0120/unlabel/blob/main/backend/app/api/v1/community.py): `backend/app/api/v1/community.py`
- [Submission preparation](https://github.com/vaibhavsh0120/unlabel/blob/main/backend/app/community/service.py): `backend/app/community/service.py`
- [Evidence resolver](https://github.com/vaibhavsh0120/unlabel/blob/main/backend/app/community/resolver.py): `backend/app/community/resolver.py`
- [Community observations](https://github.com/vaibhavsh0120/unlabel/blob/main/backend/app/community/store.py): `backend/app/community/store.py`
- [Account snapshots](https://github.com/vaibhavsh0120/unlabel/blob/main/backend/app/accounts/store.py): `backend/app/accounts/store.py`

### Optional capabilities

- [Research catalogue](https://github.com/vaibhavsh0120/unlabel/blob/main/backend/app/research_catalogue/store.py): `backend/app/research_catalogue/store.py`
- [Research discovery API](https://github.com/vaibhavsh0120/unlabel/blob/main/backend/app/research_catalogue/router.py): `backend/app/research_catalogue/router.py`
- [AI extraction API](https://github.com/vaibhavsh0120/unlabel/blob/main/backend/app/ai/router.py): `backend/app/ai/router.py`
- [AI provider gateway](https://github.com/vaibhavsh0120/unlabel/blob/main/backend/app/ai/gateway.py): `backend/app/ai/gateway.py`
- [Private AI staging](https://github.com/vaibhavsh0120/unlabel/blob/main/backend/app/ai/store.py): `backend/app/ai/store.py`

### Other components

- **App user**

## Connections

- App user → FastAPI entry: requests lookup (evidence: `README.md`)
- FastAPI entry → Product catalogue: reads products (evidence: `backend/app/main.py`)
- FastAPI entry → Catalogue search: routes search (evidence: `backend/app/main.py`)
- Product catalogue → Sourced facts: builds facts (evidence: `backend/app/catalogue/store.py`)
- Product catalogue → Catalogue search: supports search (evidence: `backend/app/catalogue/search.py`)
- App user → Live OFF provider: requests live data (evidence: `README.md`)
- App user → Live nutrition provider: requests live data (evidence: `README.md`)
- Sourced facts → Nutrition normalization: normalizes tables (evidence: `backend/app/catalogue/facts.py`)
- Claim assessment → Reviewed claim rules: loads rules (evidence: `backend/app/claims/engine.py`)
- Report composition → Claim assessment: assesses claims (evidence: `backend/app/reports/service.py`)
- Report composition → Ingredient glossary: adds definitions (evidence: `backend/app/reports/service.py`)
- Product comparison → Product catalogue: reads facts (evidence: `backend/app/comparison/service.py`)
- Product comparison → Nutrition normalization: normalizes inputs (evidence: `backend/app/comparison/service.py`)
- Community API → Submission preparation: prepares submissions
- Submission preparation → Nutrition normalization: normalizes rows (evidence: `backend/app/community/service.py`)
- Submission preparation → Evidence resolver: checks conflicts (evidence: `backend/app/community/service.py`)
- Community observations → Submission preparation: uses preparation (evidence: `backend/app/community/store.py`)
- Account snapshots → Community observations: shares account models (evidence: `backend/app/accounts/store.py`)
- Research discovery API → Research catalogue: queries index (evidence: `backend/app/research_catalogue/router.py`)
- AI extraction API → AI provider gateway: runs extraction (evidence: `backend/app/ai/router.py`)
- AI provider gateway → Private AI staging: stores private results (evidence: `backend/app/ai/gateway.py`)
