# sanya1202/flipkart-grid-frontend architecture

> Architecture diagram of the GitHub repository sanya1202/flipkart-grid-frontend, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-11-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/sanya1202/flipkart-grid-frontend
- Repository: https://github.com/sanya1202/flipkart-grid-frontend

## Overview

##### Project type and purpose
- This is a full-stack, image-processing web application (“Smart Vision Quality Control System”) that uses a React/Tailwind front end, a Node.js/Express API gateway, a Python-based ML service (Flask or FastAPI), and MongoDB for persistence. It supports OCR, object classification, freshness assessment, barcode decoding, nutrition/ingredient extraction, and history tracking.

##### File structure
- Top-level:
- `.env`, `.gitignore`, `package.json` / `package-lock.json` → Node/Express configuration
- `Backend/app.js` → main Express server, defines REST endpoints
- `model/` → Python microservice modules (`app.py`, `BarCode.py`, `nutrition.py`) handling ML pipelines (Gemini LLM, YOLO, pyzbar)
- `public/` → static assets & HTML template for React
- `src/` → React source code, organized into components (login, dashboard, scan, history, nutrition, barcode, charts, etc.)
- `tailwind.config.js` → Tailwind CSS setup
- The presence of both `Backend/app.js` and `model/app.py` implies a microservices pattern: Express routes delegate heavy lifting to a separate Python service.

##### README for additional insights
- Front end deployed on Netlify; calls back-end via Axios POST to endpoints like `/predict`, `/decode`, `/add-product`, `/products-history`, etc.
- Back end uses a fine-tuned Gemini LLM (via Google GenAI) and a YOLO-v8 model for barcode detection, plus OCR/pyzbar.
- Two MongoDB collections: products and fruits/vegetables, each with its own Mongoose schema.
- System workflow: user uploads image → Express server → Python ML service → returns JSON → Node persists to MongoDB → UI updates and can query history.

##### Elements
- Clear labels: e.g., “React UI (Netlify)”, “Express API (/predict, /decode, /history)”, “ML Service (Flask/FastAPI)”, “MongoDB Atlas”
- Blue rectangles for front-end
- Green for back-end services
- Orange for ML service
- Notes on important internal modules (e.g., YOLO-v8, OCR, LLM pipeline)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Layer
    subgraph "Frontend Layer"
        direction TB
        User["User Browser"]:::frontend
        Netlify["Netlify CDN\n(Static Hosting)"]:::frontend
        ReactEntry["React Entry\n(src/index.js)"]:::frontend
        GlobalStyles["Global Styles\n(src/index.css,\n tailwind.config.js)"]:::frontend
        AppShell["Main App Shell\n(src/App.js,\n src/App.css)"]:::frontend
        Login["Login Component\n(src/components/login.js)"]:::frontend
        Dashboard["Home / Dashboard\n(src/components/home.js,\n src/components/dashboard.js)"]:::frontend
        ScanComp["Scan Component\n(src/components/scan.js,\n src/components/scanning.css)"]:::frontend
        Effect["OCR / Prediction State\n(src/components/effect.js,\n src/components/effect2.js)"]:::frontend
        BarcodeUI["Barcode UI & Table\n(src/components/barcode.js,\n src/components/barcodetable.js)"]:::frontend
        NutritionUI["Nutrition UI & Table\n(src/components/nutrition.js,\n src/components/nutritiontable.js)"]:::frontend
        HistoryUI["History Pages\n(src/components/history.js,\n src/components/history2.js,\n src/components/producthistory.js,\n src/components/fruithistory.js)"]:::frontend
        Charts["Charting Components\n(src/components/bargraph.js,\n src/components/bargraph2.js,\n src/components/linegraph.js,\n src/components/pichart.js)"]:::frontend
        Loader["Loading Indicators\n(src/components/Loader.css,\n src/components/Loader2.css)"]:::frontend
        Testing["React Testing\n(src/App.test.js,\n src/setupTests.js,\n src/reportWebVitals.js)"]:::frontend
    end

    %% Backend Layer
    subgraph "Backend Layer"
        direction TB
        Express["Express API Gateway\n(Backend/app.js)"]:::backend
        Config["Node.js Config\n(package.json,\n package-lock.json,\n .env,\n .gitignore)"]:::backend
    end

    %% ML Service
    subgraph "Python ML Service"
        direction TB
        MLApp["ML Service\n(model/app.py)"]:::ml
        BarCodeMod["Barcode Decoding\n(model/BarCode.py)"]:::ml
        NutritionMod["Nutrition Extraction\n(model/nutrition.py)"]:::ml
    end

    %% Infrastructure
    subgraph "Infrastructure"
        direction TB
        Gemini["Gemini LLM\n(Google GenAI API)"]:::external
        Mongo["MongoDB Atlas\n(Products & Fruits)"]:::database
    end

    %% Connections
    User --> Netlify
    Netlify --> ReactEntry
    ReactEntry --> GlobalStyles
    ReactEntry --> AppShell
    AppShell --> Login
    AppShell --> Dashboard
    AppShell --> ScanComp
    ScanComp --> Effect
    Effect --> BarcodeUI
    Effect --> NutritionUI
    AppShell --> HistoryUI
    HistoryUI --> Charts
    AppShell --> Loader

    AppShell -->|POST /predict| Express
    AppShell -->|POST /decode| Express
    AppShell -->|GET /products-history| Express
    AppShell -->|GET /fruits-history| Express

    Express --> Config
    Express --> MLApp
    Express --> Mongo

    MLApp --> BarCodeMod
    MLApp --> NutritionMod
    MLApp --> Gemini

    %% Click Events - Frontend
    click Netlify "https://github.com/sanya1202/flipkart-grid-frontend/blob/master/public/index.html"
    click ReactEntry "https://github.com/sanya1202/flipkart-grid-frontend/blob/master/src/index.js"
    click GlobalStyles "https://github.com/sanya1202/flipkart-grid-frontend/blob/master/src/index.css"
    click GlobalStyles "https://github.com/sanya1202/flipkart-grid-frontend/blob/master/tailwind.config.js"
    click AppShell "https://github.com/sanya1202/flipkart-grid-frontend/blob/master/src/App.js"
    click AppShell "https://github.com/sanya1202/flipkart-grid-frontend/blob/master/src/App.css"
    click Login "https://github.com/sanya1202/flipkart-grid-frontend/blob/master/src/components/login.js"
    click Dashboard "https://github.com/sanya1202/flipkart-grid-frontend/blob/master/src/components/home.js"
    click Dashboard "https://github.com/sanya1202/flipkart-grid-frontend/blob/master/src/components/dashboard.js"
    click ScanComp "https://github.com/sanya1202/flipkart-grid-frontend/blob/master/src/components/scan.js"
    click ScanComp "https://github.com/sanya1202/flipkart-grid-frontend/blob/master/src/components/scanning.css"
    click Effect "https://github.com/sanya1202/flipkart-grid-frontend/blob/master/src/components/effect.js"
    click Effect "https://github.com/sanya1202/flipkart-grid-frontend/blob/master/src/components/effect2.js"
    click BarcodeUI "https://github.com/sanya1202/flipkart-grid-frontend/blob/master/src/components/barcode.js"
    click BarcodeUI "https://github.com/sanya1202/flipkart-grid-frontend/blob/master/src/components/barcodetable.js"
    click NutritionUI "https://github.com/sanya1202/flipkart-grid-frontend/blob/master/src/components/nutrition.js"
    click NutritionUI "https://github.com/sanya1202/flipkart-grid-frontend/blob/master/src/components/nutritiontable.js"
    click HistoryUI "https://github.com/sanya1202/flipkart-grid-frontend/blob/master/src/components/history.js"
    click HistoryUI "https://github.com/sanya1202/flipkart-grid-frontend/blob/master/src/components/history2.js"
    click HistoryUI "https://github.com/sanya1202/flipkart-grid-frontend/blob/master/src/components/producthistory.js"
    click HistoryUI "https://github.com/sanya1202/flipkart-grid-frontend/blob/master/src/components/fruithistory.js"
    click Charts "https://github.com/sanya1202/flipkart-grid-frontend/blob/master/src/components/bargraph.js"
    click Charts "https://github.com/sanya1202/flipkart-grid-frontend/blob/master/src/components/bargraph2.js"
    click Charts "https://github.com/sanya1202/flipkart-grid-frontend/blob/master/src/components/linegraph.js"
    click Charts "https://github.com/sanya1202/flipkart-grid-frontend/blob/master/src/components/pichart.js"
    click Loader "https://github.com/sanya1202/flipkart-grid-frontend/blob/master/src/components/Loader.css"
    click Loader "https://github.com/sanya1202/flipkart-grid-frontend/blob/master/src/components/Loader2.css"
    click Testing "https://github.com/sanya1202/flipkart-grid-frontend/blob/master/src/App.test.js"
    click Testing "https://github.com/sanya1202/flipkart-grid-frontend/blob/master/src/setupTests.js"
    click Testing "https://github.com/sanya1202/flipkart-grid-frontend/blob/master/src/reportWebVitals.js"

    %% Click Events - Backend & ML
    click Express "https://github.com/sanya1202/flipkart-grid-frontend/blob/master/Backend/app.js"
    click Config "https://github.com/sanya1202/flipkart-grid-frontend/blob/master/package.json"
    click Config "https://github.com/sanya1202/flipkart-grid-frontend/blob/master/.env"
    click Config "https://github.com/sanya1202/flipkart-grid-frontend/blob/master/.gitignore"
    click MLApp "https://github.com/sanya1202/flipkart-grid-frontend/blob/master/model/app.py"
    click BarCodeMod "https://github.com/sanya1202/flipkart-grid-frontend/blob/master/model/BarCode.py"
    click NutritionMod "https://github.com/sanya1202/flipkart-grid-frontend/blob/master/model/nutrition.py"

    %% Styles
    classDef frontend fill:#CCE5FF,stroke:#333,stroke-width:1px
    classDef backend fill:#D5F5E3,stroke:#333,stroke-width:1px
    classDef ml fill:#FFE5CC,stroke:#333,stroke-width:1px
    classDef database fill:#FFF2CC,stroke:#333,stroke-width:1px
    classDef external fill:#E0E0E0,stroke:#333,stroke-width:1px
```
