# codewithrakshit/parakh-ai architecture

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

- Interactive diagram: https://gitdiagram.com/codewithrakshit/parakh-ai
- Repository: https://github.com/codewithrakshit/parakh-ai

## Overview

Parakh AI audits packaged-product labels: a user submits label images, the backend extracts text and declarations, evaluates applicable rules, and returns an explainable score and report. The frontend also supports history, demo cases, authentication/workspaces, enforcement, and external verification capabilities. The analysis service’s dependency list identifies its principal collaborators; several route and UI implementations were not sampled, so their internal behavior is represented only where documented or indexed.

Main entry points: [`backend/services/analysis_service.py`](https://github.com/codewithrakshit/parakh-ai/blob/main/backend/services/analysis_service.py) (Analysis orchestration), [`backend/main.py`](https://github.com/codewithrakshit/parakh-ai/blob/main/backend/main.py) (FastAPI application), [`backend/compliance/engine.py`](https://github.com/codewithrakshit/parakh-ai/blob/main/backend/compliance/engine.py) (Compliance evaluation), [`frontend/src/App.tsx`](https://github.com/codewithrakshit/parakh-ai/blob/main/frontend/src/App.tsx) (Web application)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["User application"]
  node_app["Web application<br/>[App.tsx]"]
  node_analysis_ui["Label analysis UI<br/>[Analyze.tsx]"]
  node_history_ui["Inspection history<br/>[History.tsx]"]
  node_results_ui["Results dashboard<br/>[Results.tsx]"]
  node_api_client["API client<br/>[api.ts]"]
end

subgraph group_api["API and identity"]
  node_api_server["FastAPI application<br/>[main.py]"]
  node_analysis_routes["Analysis endpoints<br/>[analyze.py]"]
  node_auth["Authentication and accounts<br/>[routes.py]"]
end

subgraph group_analysis["Label analysis"]
  node_analysis_service["Analysis orchestration"]
  node_ocr["OCR engines<br/>[paddle_engine.py]"]
  node_extractor["Declaration extraction<br/>[extractor.py]"]
  node_models["Analysis data models<br/>[schemas.py]"]
end

subgraph group_compliance["Compliance evaluation"]
  node_compliance_api["Compliance endpoints"]
  node_compliance_engine["Compliance evaluation<br/>[engine.py]"]
  node_rule_registry["Rule registry<br/>[registry.py]"]
  node_lm_rules["Legal metrology rules<br/>[legal_metrology.py]"]
  node_fssai_rules["FSSAI rules<br/>[fssai.py]"]
  node_recommendations["Recommendations<br/>[recommendations.py]"]
end

subgraph group_platform["Persistence and integrations"]
  node_database[("SQLite data store<br/>[db.py]")]
  node_report_api["Report endpoints<br/>[report.py]"]
  node_report_service["Audit report generation<br/>[report_service.py]"]
  node_integrations_api["Integration endpoints<br/>[integrations.py]"]
  node_fssai_verify["FSSAI verification<br/>[verifier.py]"]
  node_gs1_verify["GS1 verification<br/>[verifier.py]"]
  node_enforcement_api["Enforcement endpoints<br/>[enforcement.py]"]
  node_penalties["Penalty reference<br/>[penalties.py]"]
end

node_user(("Inspector or merchant"))

node_user -->|"uses"| node_app
node_app -->|"routes to"| node_analysis_ui
node_app -->|"routes to"| node_history_ui
node_app -->|"routes to"| node_results_ui
node_analysis_ui -.->|"submits analysis"| node_api_client
node_api_client -->|"calls REST API"| node_api_server
node_api_server -->|"registers"| node_analysis_routes
node_api_server -->|"registers"| node_compliance_api
node_api_server -->|"registers"| node_auth
node_api_server -->|"registers"| node_report_api
node_api_server -->|"registers"| node_integrations_api
node_api_server -->|"registers"| node_enforcement_api
node_analysis_routes -.->|"dispatches analysis"| node_analysis_service
node_analysis_service -->|"selects engine"| node_ocr
node_analysis_service -->|"extracts declarations"| node_extractor
node_analysis_service -->|"evaluates compliance"| node_compliance_engine
node_analysis_service -->|"persists analysis"| node_database
node_analysis_service -->|"requests verification"| node_fssai_verify
node_analysis_service -->|"requests verification"| node_gs1_verify
node_analysis_service -->|"uses schemas"| node_models
node_compliance_api -->|"checks product"| node_compliance_engine
node_compliance_api -->|"lists rules"| node_rule_registry
node_compliance_engine -->|"loads rules"| node_rule_registry
node_rule_registry -->|"registers evaluators"| node_lm_rules
node_rule_registry -->|"registers evaluators"| node_fssai_rules
node_compliance_engine -->|"evaluates rules"| node_lm_rules
node_compliance_engine -->|"evaluates rules"| node_fssai_rules
node_compliance_engine -.->|"builds recommendations"| node_recommendations
node_report_api -->|"generates report"| node_report_service
node_report_api -->|"reads audit data"| node_database
node_report_api -->|"uses findings"| node_recommendations
node_auth -->|"manages accounts"| node_database
node_auth -->|"uses security data"| node_database
node_integrations_api -.->|"exposes verification"| node_fssai_verify
node_integrations_api -.->|"exposes verification"| node_gs1_verify
node_enforcement_api -.->|"uses penalty data"| node_penalties

click node_app "https://github.com/codewithrakshit/parakh-ai/blob/main/frontend/src/App.tsx"
click node_analysis_ui "https://github.com/codewithrakshit/parakh-ai/blob/main/frontend/src/pages/Analyze.tsx"
click node_history_ui "https://github.com/codewithrakshit/parakh-ai/blob/main/frontend/src/pages/History.tsx"
click node_results_ui "https://github.com/codewithrakshit/parakh-ai/blob/main/frontend/src/pages/Results.tsx"
click node_api_client "https://github.com/codewithrakshit/parakh-ai/blob/main/frontend/src/services/api.ts"
click node_api_server "https://github.com/codewithrakshit/parakh-ai/blob/main/backend/main.py"
click node_analysis_routes "https://github.com/codewithrakshit/parakh-ai/blob/main/backend/api/analyze.py"
click node_auth "https://github.com/codewithrakshit/parakh-ai/blob/main/backend/auth/routes.py"
click node_analysis_service "https://github.com/codewithrakshit/parakh-ai/blob/main/backend/services/analysis_service.py"
click node_ocr "https://github.com/codewithrakshit/parakh-ai/blob/main/backend/ocr/paddle_engine.py"
click node_extractor "https://github.com/codewithrakshit/parakh-ai/blob/main/backend/extraction/extractor.py"
click node_models "https://github.com/codewithrakshit/parakh-ai/blob/main/backend/models/schemas.py"
click node_compliance_api "https://github.com/codewithrakshit/parakh-ai/blob/main/backend/api/compliance_routes.py"
click node_compliance_engine "https://github.com/codewithrakshit/parakh-ai/blob/main/backend/compliance/engine.py"
click node_rule_registry "https://github.com/codewithrakshit/parakh-ai/blob/main/backend/compliance/rules/registry.py"
click node_lm_rules "https://github.com/codewithrakshit/parakh-ai/blob/main/backend/compliance/rules/legal_metrology.py"
click node_fssai_rules "https://github.com/codewithrakshit/parakh-ai/blob/main/backend/compliance/rules/fssai.py"
click node_recommendations "https://github.com/codewithrakshit/parakh-ai/blob/main/backend/compliance/recommendations.py"
click node_database "https://github.com/codewithrakshit/parakh-ai/blob/main/backend/database/db.py"
click node_report_api "https://github.com/codewithrakshit/parakh-ai/blob/main/backend/api/report.py"
click node_report_service "https://github.com/codewithrakshit/parakh-ai/blob/main/backend/services/report_service.py"
click node_integrations_api "https://github.com/codewithrakshit/parakh-ai/blob/main/backend/api/integrations.py"
click node_fssai_verify "https://github.com/codewithrakshit/parakh-ai/blob/main/backend/integrations/fssai/verifier.py"
click node_gs1_verify "https://github.com/codewithrakshit/parakh-ai/blob/main/backend/integrations/gs1/verifier.py"
click node_enforcement_api "https://github.com/codewithrakshit/parakh-ai/blob/main/backend/api/enforcement.py"
click node_penalties "https://github.com/codewithrakshit/parakh-ai/blob/main/backend/enforcement/penalties.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_analysis_ui,node_history_ui,node_results_ui,node_api_client toneBlue
class node_api_server,node_analysis_routes,node_auth toneAmber
class node_analysis_service,node_ocr,node_extractor,node_models toneMint
class node_compliance_api,node_compliance_engine,node_rule_registry,node_lm_rules,node_fssai_rules,node_recommendations toneRose
class node_database,node_report_api,node_report_service,node_integrations_api,node_fssai_verify,node_gs1_verify,node_enforcement_api,node_penalties,node_user toneIndigo
```

## Components

### User application

- [Web application](https://github.com/codewithrakshit/parakh-ai/blob/main/frontend/src/App.tsx): `frontend/src/App.tsx`
- [Label analysis UI](https://github.com/codewithrakshit/parakh-ai/blob/main/frontend/src/pages/Analyze.tsx): `frontend/src/pages/Analyze.tsx`
- [Inspection history](https://github.com/codewithrakshit/parakh-ai/blob/main/frontend/src/pages/History.tsx): `frontend/src/pages/History.tsx`
- [Results dashboard](https://github.com/codewithrakshit/parakh-ai/blob/main/frontend/src/pages/Results.tsx): `frontend/src/pages/Results.tsx`
- [API client](https://github.com/codewithrakshit/parakh-ai/blob/main/frontend/src/services/api.ts): `frontend/src/services/api.ts`

### API and identity

- [FastAPI application](https://github.com/codewithrakshit/parakh-ai/blob/main/backend/main.py): `backend/main.py`
- [Analysis endpoints](https://github.com/codewithrakshit/parakh-ai/blob/main/backend/api/analyze.py): `backend/api/analyze.py`
- [Authentication and accounts](https://github.com/codewithrakshit/parakh-ai/blob/main/backend/auth/routes.py): `backend/auth/routes.py`

### Label analysis

- [Analysis orchestration](https://github.com/codewithrakshit/parakh-ai/blob/main/backend/services/analysis_service.py): `backend/services/analysis_service.py`
- [OCR engines](https://github.com/codewithrakshit/parakh-ai/blob/main/backend/ocr/paddle_engine.py): `backend/ocr/paddle_engine.py`
- [Declaration extraction](https://github.com/codewithrakshit/parakh-ai/blob/main/backend/extraction/extractor.py): `backend/extraction/extractor.py`
- [Analysis data models](https://github.com/codewithrakshit/parakh-ai/blob/main/backend/models/schemas.py): `backend/models/schemas.py`

### Compliance evaluation

- [Compliance endpoints](https://github.com/codewithrakshit/parakh-ai/blob/main/backend/api/compliance_routes.py): `backend/api/compliance_routes.py`
- [Compliance evaluation](https://github.com/codewithrakshit/parakh-ai/blob/main/backend/compliance/engine.py): `backend/compliance/engine.py`
- [Rule registry](https://github.com/codewithrakshit/parakh-ai/blob/main/backend/compliance/rules/registry.py): `backend/compliance/rules/registry.py`
- [Legal metrology rules](https://github.com/codewithrakshit/parakh-ai/blob/main/backend/compliance/rules/legal_metrology.py): `backend/compliance/rules/legal_metrology.py`
- [FSSAI rules](https://github.com/codewithrakshit/parakh-ai/blob/main/backend/compliance/rules/fssai.py): `backend/compliance/rules/fssai.py`
- [Recommendations](https://github.com/codewithrakshit/parakh-ai/blob/main/backend/compliance/recommendations.py): `backend/compliance/recommendations.py`

### Persistence and integrations

- [SQLite data store](https://github.com/codewithrakshit/parakh-ai/blob/main/backend/database/db.py): `backend/database/db.py`
- [Report endpoints](https://github.com/codewithrakshit/parakh-ai/blob/main/backend/api/report.py): `backend/api/report.py`
- [Audit report generation](https://github.com/codewithrakshit/parakh-ai/blob/main/backend/services/report_service.py): `backend/services/report_service.py`
- [Integration endpoints](https://github.com/codewithrakshit/parakh-ai/blob/main/backend/api/integrations.py): `backend/api/integrations.py`
- [FSSAI verification](https://github.com/codewithrakshit/parakh-ai/blob/main/backend/integrations/fssai/verifier.py): `backend/integrations/fssai/verifier.py`
- [GS1 verification](https://github.com/codewithrakshit/parakh-ai/blob/main/backend/integrations/gs1/verifier.py): `backend/integrations/gs1/verifier.py`
- [Enforcement endpoints](https://github.com/codewithrakshit/parakh-ai/blob/main/backend/api/enforcement.py): `backend/api/enforcement.py`
- [Penalty reference](https://github.com/codewithrakshit/parakh-ai/blob/main/backend/enforcement/penalties.py): `backend/enforcement/penalties.py`

### Other components

- **Inspector or merchant**

## Connections

- Inspector or merchant → Web application: uses
- Web application → Label analysis UI: routes to (evidence: `frontend/src/App.tsx`)
- Web application → Inspection history: routes to (evidence: `frontend/src/App.tsx`)
- Web application → Results dashboard: routes to (evidence: `frontend/src/App.tsx`)
- Label analysis UI → API client: submits analysis
- API client → FastAPI application: calls REST API
- FastAPI application → Analysis endpoints: registers (evidence: `backend/main.py`)
- FastAPI application → Compliance endpoints: registers (evidence: `backend/main.py`)
- FastAPI application → Authentication and accounts: registers (evidence: `backend/main.py`)
- FastAPI application → Report endpoints: registers (evidence: `backend/main.py`)
- FastAPI application → Integration endpoints: registers (evidence: `backend/main.py`)
- FastAPI application → Enforcement endpoints: registers (evidence: `backend/main.py`)
- Analysis endpoints → Analysis orchestration: dispatches analysis
- Analysis orchestration → OCR engines: selects engine (evidence: `backend/services/analysis_service.py`)
- Analysis orchestration → Declaration extraction: extracts declarations (evidence: `backend/services/analysis_service.py`)
- Analysis orchestration → Compliance evaluation: evaluates compliance (evidence: `backend/services/analysis_service.py`)
- Analysis orchestration → SQLite data store: persists analysis (evidence: `backend/services/analysis_service.py`)
- Analysis orchestration → FSSAI verification: requests verification (evidence: `backend/services/analysis_service.py`)
- Analysis orchestration → GS1 verification: requests verification (evidence: `backend/services/analysis_service.py`)
- Analysis orchestration → Analysis data models: uses schemas (evidence: `backend/services/analysis_service.py`)
- Compliance endpoints → Compliance evaluation: checks product (evidence: `backend/api/compliance_routes.py`)
- Compliance endpoints → Rule registry: lists rules (evidence: `backend/api/compliance_routes.py`)
- Compliance evaluation → Rule registry: loads rules (evidence: `backend/compliance/engine.py`)
- Rule registry → Legal metrology rules: registers evaluators (evidence: `backend/compliance/rules/registry.py`)
- Rule registry → FSSAI rules: registers evaluators (evidence: `backend/compliance/rules/registry.py`)
- Compliance evaluation → Legal metrology rules: evaluates rules (evidence: `backend/compliance/engine.py`)
- Compliance evaluation → FSSAI rules: evaluates rules (evidence: `backend/compliance/engine.py`)
- Compliance evaluation → Recommendations: builds recommendations (evidence: `backend/compliance/engine.py`)
- Report endpoints → Audit report generation: generates report (evidence: `backend/api/report.py`)
- Report endpoints → SQLite data store: reads audit data (evidence: `backend/api/report.py`)
- Report endpoints → Recommendations: uses findings (evidence: `backend/api/report.py`)
- Authentication and accounts → SQLite data store: manages accounts (evidence: `backend/auth/routes.py`)
- Authentication and accounts → SQLite data store: uses security data (evidence: `backend/auth/routes.py`)
- Integration endpoints → FSSAI verification: exposes verification
- Integration endpoints → GS1 verification: exposes verification
- Enforcement endpoints → Penalty reference: uses penalty data
