# shubhamsharmayo/image-segmentation architecture

> Architecture diagram of the GitHub repository shubhamsharmayo/image-segmentation, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-07-09). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/shubhamsharmayo/image-segmentation
- Repository: https://github.com/shubhamsharmayo/image-segmentation

## Overview

##### Project type and purpose
- This is a full-stack AI-powered web application.
- Frontend: React single-page application (SPA) that provides UI for object detection, video processing, webcam streaming, and handwriting recognition.
- Backend: Flask REST API that orchestrates CV/AI pipelines (Mask R-CNN via OpenCV DNN, PyTesseract OCR).

##### File structure
- Top-level:
- client/ → all React/Tailwind code (components, assets, routing)
- server/ → Flask app (`app.py`), model files (`dnn/`, `coco.names`), (uploads/)
- Patterns: clear separation of concerns (UI vs. API).
- No microservices: a monolithic Flask backend.
- Build & config: `client/package.json`, `vite.config.js`, `tailwind.config.js`, `server/requirements.txt`.

##### README for additional insights
- Tech stack table confirms React + Flask + OpenCV + Tesseract + TensorFlow model.
- Lists API endpoints, so you know which UI screens connect to which backend routes.
- Uploads flow: client sends image/video, backend saves to `/uploads`, processes, returns result.

##### Final advice
- Be exhaustive: map each React component to its API endpoint.
- Model load sequence (e.g., “load frozen_inference_graph_coco.pb on startup”).
- Call out any configuration files (`vite.config.js`, `tailwind.config.js`, `eslintrc`).

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Frontend Layer
    subgraph "Frontend (Browser/React)" 
        direction TB
        main["React Entry Point"]:::frontend
        App["React SPA"]:::frontend
        Landing["LandingPage"]:::frontend
        Navbar["Navbar"]:::frontend
        ObjUI["ObjectDetection UI"]:::frontend
        VideoUI["VideoProcessing UI"]:::frontend
        WebcamUI["WebcamDetection UI"]:::frontend
        HandUI["HandwritingRecognition UI"]:::frontend
        ErrorUI["ErrorMessage UI"]:::frontend
        Config1["tailwind.config.js"]:::frontend
        Config2["vite.config.js"]:::frontend
        Config3["package.json"]:::frontend
    end

    %% Backend Layer
    subgraph "Backend (Flask API)" 
        direction TB
        API["Flask API Server"]:::backend
        Storage["/uploads Storage"]:::storage
        subgraph "AI Processing Modules"
            direction TB
            DNNmod["Mask R-CNN Module"]:::ai
            OCRmod["PyTesseract OCR Module"]:::ai
        end
        Tesseract["Tesseract OCR Engine"]:::external
        ModelPB[".pb Model Weights"]:::external
        ModelConfig[".pbtxt Config"]:::external
        CocoNames["coco.names Labels"]:::external
    end

    %% Data Flow
    main -->|"bootstraps React App"| App
    App -->|"renders UI components"| Landing
    App --> Navbar
    App --> ObjUI
    App --> VideoUI
    App --> WebcamUI
    App --> HandUI
    App --> ErrorUI

    App -->|"POST image/video\n(image/jpeg)"| API
    API -->|"save file"| Storage
    API -->|"load .pb & .pbtxt"| DNNmod
    API -->|"load labels"| CocoNames
    API -->|"run detection"| DNNmod
    API -->|"run OCR"| OCRmod
    OCRmod --> Tesseract
    DNNmod --> API
    OCRmod --> API
    Storage --> API
    API -->|"return JSON + Base64 PNG"| App

    %% Click Events Frontend
    click App "https://github.com/shubhamsharmayo/image-segmentation/blob/main/client/src/App.jsx"
    click main "https://github.com/shubhamsharmayo/image-segmentation/blob/main/client/src/main.jsx"
    click Landing "https://github.com/shubhamsharmayo/image-segmentation/blob/main/client/src/components/LandingPage.jsx"
    click Navbar "https://github.com/shubhamsharmayo/image-segmentation/blob/main/client/src/components/Navbar.jsx"
    click ObjUI "https://github.com/shubhamsharmayo/image-segmentation/blob/main/client/src/components/ObjectDetection.jsx"
    click VideoUI "https://github.com/shubhamsharmayo/image-segmentation/blob/main/client/src/components/VideoProcessing.jsx"
    click WebcamUI "https://github.com/shubhamsharmayo/image-segmentation/blob/main/client/src/components/WebcamDetection.jsx"
    click HandUI "https://github.com/shubhamsharmayo/image-segmentation/blob/main/client/src/components/HandwritingRecognition.jsx"
    click ErrorUI "https://github.com/shubhamsharmayo/image-segmentation/blob/main/client/src/components/ErrorMessage.jsx"
    click Config1 "https://github.com/shubhamsharmayo/image-segmentation/blob/main/client/tailwind.config.js"
    click Config2 "https://github.com/shubhamsharmayo/image-segmentation/blob/main/client/vite.config.js"
    click Config3 "https://github.com/shubhamsharmayo/image-segmentation/blob/main/client/package.json"

    %% Click Events Backend
    click API "https://github.com/shubhamsharmayo/image-segmentation/blob/main/server/app.py"
    click ModelPB "https://github.com/shubhamsharmayo/image-segmentation/blob/main/server/dnn/frozen_inference_graph_coco.pb"
    click ModelConfig "https://github.com/shubhamsharmayo/image-segmentation/blob/main/server/dnn/mask_rcnn_inception_v2_coco_2018_01_28.pbtxt"
    click CocoNames "https://github.com/shubhamsharmayo/image-segmentation/blob/main/server/coco.names"
    click Storage "https://github.com/shubhamsharmayo/image-segmentation/tree/main/server/uploads/"

    %% Styles
    classDef frontend fill:#E3F2FD,stroke:#2196F3
    classDef backend fill:#FFEBEE,stroke:#F44336
    classDef ai fill:#E8F5E9,stroke:#4CAF50
    classDef storage fill:#FFF8E1,stroke:#FFC107
    classDef external fill:#F3E5F5,stroke:#9C27B0
```
