# vidyutchakrabarti/dermascan-ai architecture

> Architecture diagram of the GitHub repository vidyutchakrabarti/dermascan-ai, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-17). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/vidyutchakrabarti/dermascan-ai
- Repository: https://github.com/vidyutchakrabarti/dermascan-ai

## Overview

##### Project type and purpose
- This is a full-stack, multi-modal diagnostic application.
- Frontend: React + Vite SPA for image upload and result visualization.
- Backend: Flask API serving predictions by combining CNN (ResNet50), segmentation (U-Net), and NLP (Random Forest) pipelines.
- Purpose: Classify dermatoscopic images using deep learning and NLP.

##### File structure
- Top level contains React/Vite configuration (index.html, vite.config.js, package.json, src/, public/).
- No backend code in this tree; assume a separate `backend/` (Flask) folder alongside this repo.
- No database folder—data flows from model artifacts and HAM10000 dataset.
- Deployment config: vercel.json indicates hosting on Vercel.

##### Extract additional insights from the README
- Models:
- ResNet50 for image classification
- U-Net for lesion segmentation
- Random Forest for text metadata analysis
- Data source: HAM10000
- Workflow: image → segmentation → CNN → NLP → merge → response

##### Main components
a. Frontend (React + Vite)
b. Backend API (Flask)
c. ML pipelines
- Segmentation service (U-Net)
- Classification service (ResNet50)
- NLP service (Random Forest)
d. Data source (HAM10000)
e. Artifact storage (model weights)
f. Result aggregator & response

##### Relationships and interactions
- User browser → Frontend UI
- Frontend → HTTP POST /predict → Flask API
- Flask API fan-out:
- Send image to U-Net service → binary mask
- Send image to ResNet50 service → class scores
- Send metadata to Random Forest service → text scores
- Flask API merges outputs → final diagnosis
- Flask API → respond JSON → Frontend
- Frontend renders results

##### Architectural patterns and principles
- Micro-services style for each ML component
- API gateway (Flask) as orchestration layer
- Separation of concerns: UI vs. model inference vs. data
- Stateless services (models load weights on startup)
- Modular design for easy extension (swap models, add services)

##### Relevant technologies & frameworks
- Frontend: React, Vite, JSX, CSS modules
- Backend: Python Flask, Gunicorn (or similar)
- ML: TensorFlow/PyTorch (for ResNet50 & U-Net), scikit-learn (Random Forest)
- Dataset management: local files or object storage
- Deployment: Vercel (frontend), Docker or cloud VM for backend

## Diagram (Mermaid)

```mermaid
flowchart TD
    User["User Browser"]:::user

    subgraph "Frontend Layer"
        direction TB
        Index["index.html"]:::frontend
        Pkg["package.json"]:::frontend
        Vite["vite.config.js"]:::frontend
        Public["public/"]:::frontend
        subgraph "src/"
            direction TB
            Main["src/main.jsx"]:::frontend
            App["src/App.jsx"]:::frontend
            Pred["src/pages/PredictionPage.jsx"]:::frontend
            Nav["src/components/Navbar.jsx"]:::frontend
            Foot["src/components/Footer.jsx"]:::frontend
            Scroll["src/components/ScrollToTop.jsx"]:::frontend
            How["src/components/HowItWorks.jsx"]:::frontend
        end
        Deploy["vercel.json"]:::frontend
    end

    User --> Pred
    Pred -->|"POST /predict"| API

    subgraph "Backend Layer"
        direction TB
        API["Flask API"]:::backend
        Agg["Result Aggregator"]:::aggregator
        API --> Agg
    end

    subgraph "ML Services"
        direction TB
        Seg["Segmentation (U-Net)"]:::ml
        Class["Classification (ResNet50)"]:::ml
        NLP["NLP (Random Forest)"]:::ml
    end

    API -->|"image→mask"| Seg
    API -->|"image→scores"| Class
    API -->|"metadata→scores"| NLP

    Seg --> API
    Class --> API
    NLP --> API

    API --> Pred

    subgraph "Data Storage"
        DS["Model Weights & HAM10000 Data"]:::data
    end

    DS -.-> Seg
    DS -.-> Class
    DS -.-> NLP

    classDef user fill:#cfe2f3,stroke:#000;
    classDef frontend fill:#a3c4f3,stroke:#000;
    classDef backend fill:#9be7a4,stroke:#000;
    classDef ml fill:#f7a278,stroke:#000;
    classDef data fill:#cccccc,stroke:#000;
    classDef aggregator fill:#d1b3f9,stroke:#000;

    click Index "https://github.com/vidyutchakrabarti/dermascan-ai/blob/main/index.html"
    click Vite "https://github.com/vidyutchakrabarti/dermascan-ai/blob/main/vite.config.js"
    click Pkg "https://github.com/vidyutchakrabarti/dermascan-ai/blob/main/package.json"
    click Public "https://github.com/vidyutchakrabarti/dermascan-ai/tree/main/public/"
    click Main "https://github.com/vidyutchakrabarti/dermascan-ai/blob/main/src/main.jsx"
    click App "https://github.com/vidyutchakrabarti/dermascan-ai/blob/main/src/App.jsx"
    click Pred "https://github.com/vidyutchakrabarti/dermascan-ai/blob/main/src/pages/PredictionPage.jsx"
    click Nav "https://github.com/vidyutchakrabarti/dermascan-ai/blob/main/src/components/Navbar.jsx"
    click Foot "https://github.com/vidyutchakrabarti/dermascan-ai/blob/main/src/components/Footer.jsx"
    click Scroll "https://github.com/vidyutchakrabarti/dermascan-ai/blob/main/src/components/ScrollToTop.jsx"
    click How "https://github.com/vidyutchakrabarti/dermascan-ai/blob/main/src/components/HowItWorks.jsx"
    click Deploy "https://github.com/vidyutchakrabarti/dermascan-ai/blob/main/vercel.json"
```
