# sarthak23-2008/enigma_innoquads architecture

> Architecture diagram of the GitHub repository sarthak23-2008/enigma_innoquads, 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/sarthak23-2008/enigma_innoquads
- Repository: https://github.com/sarthak23-2008/enigma_innoquads

## Overview

SafeBite is a personalized food-safety and dietary-pattern assistant. Users create a dietary profile, check food through label scanning, search, manual entry or restaurant choices, review results and log foods they ate; rolling trends, goals, alerts and alternatives help interpret that history. The frontend API client connects these journeys to FastAPI routes, which use services, deterministic engines and persisted user data. OCR provider details and most route-to-service wiring were not sampled, so those internal links are shown only where documented capabilities support them.

Main entry points: [`backend/app/main.py`](https://github.com/sarthak23-2008/enigma_innoquads/blob/main/backend/app/main.py) (FastAPI application), [`backend/app/database/session.py`](https://github.com/sarthak23-2008/enigma_innoquads/blob/main/backend/app/database/session.py) (Database access), [`backend/app/api/analysis.py`](https://github.com/sarthak23-2008/enigma_innoquads/blob/main/backend/app/api/analysis.py) (Assessment routes), [`backend/app/services/analysis.py`](https://github.com/sarthak23-2008/enigma_innoquads/blob/main/backend/app/services/analysis.py) (Assessment service)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["User application"]
  node_app["Route application<br/>[App.jsx]"]
  node_check_pages["Food entry"]
  node_review["Label review<br/>[OCRReview.jsx]"]
  node_history_pages["History and trends"]
  node_api_client["API client<br/>[api.js]"]
end

subgraph group_api["API and identity"]
  node_api_main["FastAPI application<br/>[main.py]"]
  node_auth_api["Authentication<br/>[auth.py]"]
  node_profile_api["Profile routes<br/>[profile.py]"]
  node_assessment_api["Assessment routes<br/>[analysis.py]"]
  node_ocr_api["OCR routes<br/>[ocr.py]"]
  node_logs_api["Food logs<br/>[logs.py]"]
  node_insights_api["Insights and goals<br/>[insights.py]"]
  node_db_session["Database access<br/>[session.py]"]
  node_data_store[("Application data<br/>[__init__.py]")]
end

subgraph group_check["Food assessment"]
  node_ocr_service["OCR processing"]
  node_label_parser["Label parser<br/>[label_parser.py]"]
  node_food_catalog["Food catalog<br/>[food_catalog.py]"]
  node_normalizer["Ingredient normalization"]
  node_risk_engine["Ingredient risk engine<br/>[risk_engine.py]"]
  node_alternatives["Food alternatives<br/>[alternatives.py]"]
  node_analysis_service["Assessment service<br/>[analysis.py]"]
end

subgraph group_history["Diet patterns"]
  node_diet_engine["Diet pattern engine"]
  node_reports["Reports and notifications<br/>[reports.py]"]
end

node_user(("Food checker"))

node_user -->|"uses"| node_app
node_app -->|"routes to"| node_check_pages
node_app -->|"routes to"| node_history_pages
node_check_pages -->|"requests"| node_api_client
node_review -->|"submits edits"| node_check_pages
node_history_pages -->|"requests"| node_api_client
node_api_client -->|"HTTP requests"| node_api_main
node_api_main -->|"mounts routes"| node_auth_api
node_api_main -->|"mounts routes"| node_profile_api
node_api_main -->|"mounts routes"| node_assessment_api
node_api_main -->|"mounts routes"| node_ocr_api
node_api_main -->|"mounts routes"| node_logs_api
node_api_main -->|"mounts routes"| node_insights_api
node_ocr_api -->|"processes labels"| node_ocr_service
node_ocr_service -->|"parses text"| node_label_parser
node_assessment_api -->|"delegates assessment"| node_analysis_service
node_analysis_service -->|"normalizes ingredients"| node_normalizer
node_analysis_service -->|"checks risk"| node_risk_engine
node_analysis_service -->|"gets alternatives"| node_alternatives
node_assessment_api -->|"searches foods"| node_food_catalog
node_auth_api -->|"queries users"| node_db_session
node_assessment_api -->|"persists results"| node_db_session
node_logs_api -->|"reads and writes logs"| node_db_session
node_insights_api -->|"loads diet history"| node_db_session
node_db_session -->|"accesses"| node_data_store
node_insights_api -->|"analyzes patterns"| node_diet_engine
node_reports -.->|"summarizes patterns"| node_diet_engine

click node_app "https://github.com/sarthak23-2008/enigma_innoquads/blob/main/frontend/src/App.jsx"
click node_check_pages "https://github.com/sarthak23-2008/enigma_innoquads/tree/main/frontend/src/pages"
click node_review "https://github.com/sarthak23-2008/enigma_innoquads/blob/main/frontend/src/components/OCRReview.jsx"
click node_history_pages "https://github.com/sarthak23-2008/enigma_innoquads/tree/main/frontend/src/pages"
click node_api_client "https://github.com/sarthak23-2008/enigma_innoquads/blob/main/frontend/src/services/api.js"
click node_api_main "https://github.com/sarthak23-2008/enigma_innoquads/blob/main/backend/app/main.py"
click node_auth_api "https://github.com/sarthak23-2008/enigma_innoquads/blob/main/backend/app/api/auth.py"
click node_profile_api "https://github.com/sarthak23-2008/enigma_innoquads/blob/main/backend/app/api/profile.py"
click node_assessment_api "https://github.com/sarthak23-2008/enigma_innoquads/blob/main/backend/app/api/analysis.py"
click node_ocr_api "https://github.com/sarthak23-2008/enigma_innoquads/blob/main/backend/app/api/ocr.py"
click node_logs_api "https://github.com/sarthak23-2008/enigma_innoquads/blob/main/backend/app/api/logs.py"
click node_insights_api "https://github.com/sarthak23-2008/enigma_innoquads/blob/main/backend/app/api/insights.py"
click node_ocr_service "https://github.com/sarthak23-2008/enigma_innoquads/tree/main/backend/app/services/ocr"
click node_label_parser "https://github.com/sarthak23-2008/enigma_innoquads/blob/main/backend/app/services/ocr/label_parser.py"
click node_food_catalog "https://github.com/sarthak23-2008/enigma_innoquads/blob/main/backend/app/data/food_catalog.py"
click node_normalizer "https://github.com/sarthak23-2008/enigma_innoquads/blob/main/backend/app/engines/ingredient_normalizer.py"
click node_risk_engine "https://github.com/sarthak23-2008/enigma_innoquads/blob/main/backend/app/engines/risk_engine.py"
click node_alternatives "https://github.com/sarthak23-2008/enigma_innoquads/blob/main/backend/app/services/alternatives.py"
click node_analysis_service "https://github.com/sarthak23-2008/enigma_innoquads/blob/main/backend/app/services/analysis.py"
click node_db_session "https://github.com/sarthak23-2008/enigma_innoquads/blob/main/backend/app/database/session.py"
click node_data_store "https://github.com/sarthak23-2008/enigma_innoquads/blob/main/backend/app/models/__init__.py"
click node_diet_engine "https://github.com/sarthak23-2008/enigma_innoquads/blob/main/backend/app/engines/diet_pattern_engine.py"
click node_reports "https://github.com/sarthak23-2008/enigma_innoquads/blob/main/backend/app/services/reports.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_check_pages,node_review,node_history_pages,node_api_client toneBlue
class node_api_main,node_auth_api,node_profile_api,node_assessment_api,node_ocr_api,node_logs_api,node_insights_api,node_db_session,node_data_store toneAmber
class node_ocr_service,node_label_parser,node_food_catalog,node_normalizer,node_risk_engine,node_alternatives,node_analysis_service toneMint
class node_diet_engine,node_reports toneRose
class node_user toneIndigo
```

## Components

### User application

- [Route application](https://github.com/sarthak23-2008/enigma_innoquads/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Food entry](https://github.com/sarthak23-2008/enigma_innoquads/tree/main/frontend/src/pages): `frontend/src/pages`
- [Label review](https://github.com/sarthak23-2008/enigma_innoquads/blob/main/frontend/src/components/OCRReview.jsx): `frontend/src/components/OCRReview.jsx`
- [History and trends](https://github.com/sarthak23-2008/enigma_innoquads/tree/main/frontend/src/pages): `frontend/src/pages`
- [API client](https://github.com/sarthak23-2008/enigma_innoquads/blob/main/frontend/src/services/api.js): `frontend/src/services/api.js`

### API and identity

- [FastAPI application](https://github.com/sarthak23-2008/enigma_innoquads/blob/main/backend/app/main.py): `backend/app/main.py`
- [Authentication](https://github.com/sarthak23-2008/enigma_innoquads/blob/main/backend/app/api/auth.py): `backend/app/api/auth.py`
- [Profile routes](https://github.com/sarthak23-2008/enigma_innoquads/blob/main/backend/app/api/profile.py): `backend/app/api/profile.py`
- [Assessment routes](https://github.com/sarthak23-2008/enigma_innoquads/blob/main/backend/app/api/analysis.py): `backend/app/api/analysis.py`
- [OCR routes](https://github.com/sarthak23-2008/enigma_innoquads/blob/main/backend/app/api/ocr.py): `backend/app/api/ocr.py`
- [Food logs](https://github.com/sarthak23-2008/enigma_innoquads/blob/main/backend/app/api/logs.py): `backend/app/api/logs.py`
- [Insights and goals](https://github.com/sarthak23-2008/enigma_innoquads/blob/main/backend/app/api/insights.py): `backend/app/api/insights.py`
- [Database access](https://github.com/sarthak23-2008/enigma_innoquads/blob/main/backend/app/database/session.py): `backend/app/database/session.py`
- [Application data](https://github.com/sarthak23-2008/enigma_innoquads/blob/main/backend/app/models/__init__.py): `backend/app/models/__init__.py`

### Food assessment

- [OCR processing](https://github.com/sarthak23-2008/enigma_innoquads/tree/main/backend/app/services/ocr): `backend/app/services/ocr`
- [Label parser](https://github.com/sarthak23-2008/enigma_innoquads/blob/main/backend/app/services/ocr/label_parser.py): `backend/app/services/ocr/label_parser.py`
- [Food catalog](https://github.com/sarthak23-2008/enigma_innoquads/blob/main/backend/app/data/food_catalog.py): `backend/app/data/food_catalog.py`
- [Ingredient normalization](https://github.com/sarthak23-2008/enigma_innoquads/blob/main/backend/app/engines/ingredient_normalizer.py): `backend/app/engines/ingredient_normalizer.py`
- [Ingredient risk engine](https://github.com/sarthak23-2008/enigma_innoquads/blob/main/backend/app/engines/risk_engine.py): `backend/app/engines/risk_engine.py`
- [Food alternatives](https://github.com/sarthak23-2008/enigma_innoquads/blob/main/backend/app/services/alternatives.py): `backend/app/services/alternatives.py`
- [Assessment service](https://github.com/sarthak23-2008/enigma_innoquads/blob/main/backend/app/services/analysis.py): `backend/app/services/analysis.py`

### Diet patterns

- [Diet pattern engine](https://github.com/sarthak23-2008/enigma_innoquads/blob/main/backend/app/engines/diet_pattern_engine.py): `backend/app/engines/diet_pattern_engine.py`
- [Reports and notifications](https://github.com/sarthak23-2008/enigma_innoquads/blob/main/backend/app/services/reports.py): `backend/app/services/reports.py`

### Other components

- **Food checker**

## Connections

- Food checker → Route application: uses
- Route application → Food entry: routes to
- Route application → History and trends: routes to
- Food entry → API client: requests
- Label review → Food entry: submits edits
- History and trends → API client: requests
- API client → FastAPI application: HTTP requests
- FastAPI application → Authentication: mounts routes
- FastAPI application → Profile routes: mounts routes
- FastAPI application → Assessment routes: mounts routes
- FastAPI application → OCR routes: mounts routes
- FastAPI application → Food logs: mounts routes
- FastAPI application → Insights and goals: mounts routes
- OCR routes → OCR processing: processes labels
- OCR processing → Label parser: parses text
- Assessment routes → Assessment service: delegates assessment
- Assessment service → Ingredient normalization: normalizes ingredients
- Assessment service → Ingredient risk engine: checks risk
- Assessment service → Food alternatives: gets alternatives
- Assessment routes → Food catalog: searches foods
- Authentication → Database access: queries users
- Assessment routes → Database access: persists results
- Food logs → Database access: reads and writes logs
- Insights and goals → Database access: loads diet history
- Database access → Application data: accesses
- Insights and goals → Diet pattern engine: analyzes patterns
- Reports and notifications → Diet pattern engine: summarizes patterns
