# mrnidhi/sensitive_data_classification architecture

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

- Interactive diagram: https://gitdiagram.com/mrnidhi/sensitive_data_classification
- Repository: https://github.com/mrnidhi/sensitive_data_classification

## Overview

##### Project type and purpose
- This is a machine-learning–driven, client-side inference web application.
- Purpose: classify images (and optionally text) as “sensitive” or “non-sensitive” to prevent data leaks.

##### File structure
- Top level
- README.md, Sensitive_Data_Classification.ipynb (training notebook)
- dataset/ (raw training & validation data, split into sensitive/nonsensitive)
- training_set/ (possibly processed or archive of training data)
- webapp/ (static frontend & hosting config)
- webapp/
- .firebaserc, firebase.json (Firebase Hosting configuration)
- public/
– index.html, style.css, script.js (UI assets)
– assets/images (UI mockups, examples)
– models/
· image_model/… (TF.js–converted CNN artifacts)
· text_model/… (TF.js text classification artifacts + word_index.json)
- No backend code—entire inference runs in the browser; Firebase is used only for static hosting.

##### Insights from the README
- CNN chosen for image classification.
- Workflow: collect images → train CNN in Python notebook → convert model to TF.js → deploy model files → client uses TF.js to infer.
- UI screenshot (Web UI) and methodology flowchart illustrate a clear, two-phase pipeline: Training and Inference.

##### Main components
a. Data & Training Pipeline
- Raw Dataset (dataset/training + dataset/validation)
- Jupyter/Python Training Environment (Sensitive_Data_Classification.ipynb)
- Model Converter (tensorflowjs converter)
→ Outputs: image_model and text_model artifacts
b. Deployment & Inference Pipeline
- Firebase Hosting (serves static files under webapp/)
- Static Web Application (index.html, script.js, style.css)
- TF.js Library (loaded by script.js)
- Model Artifacts (public/models/image_model + public/models/text_model)
- Client Browser (user uploads image / text, TF.js runs inference locally)
c. (Optional) Future Integration
- Firebase Cloud Storage or Firestore for analytics/logging (not yet implemented)
- Authentication & Access Control (e.g., Firebase Auth)

##### Relationships & data flow
- Training: Dataset → Notebook → Model Converter → Model Artifacts
- Deployment: Model Artifacts + Static UI → Firebase Hosting
- Inference: Browser ← Firebase (serves UI & model files) → TF.js → User’s Data
- Output: Classification result displayed in UI

##### Architectural patterns & principles
- Client-side inference: no server compute required at runtime
- Static hosting: simple CI/CD pipeline (push to Git → Firebase deploy)
- Separation of concerns:
- Training pipeline (Python/Jupyter)
- Inference pipeline (JavaScript/TF.js)
- Scalability: CDN distribution of static assets (Firebase Hosting)

##### Technologies & frameworks
- Python, Jupyter Notebook, TensorFlow/Keras (training)
- tensorflowjs-converter (model conversion)
- HTML5, CSS3, JavaScript (frontend)
- TensorFlow.js (inference library)
- Firebase Hosting (static deployment)

##### Final checklist
- Components: raw data, training notebook, converter, models, hosting, client app
- Labels: exact directory names (e.g., “public/models/image_model”)
- Annotations: note technologies (e.g., “TensorFlow.js loads model.json”)

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Training Layer"
        TrainingData[(Raw Training Dataset)]:::data
        ValidationData[(Raw Validation Dataset)]:::data
        Notebook["Jupyter Notebook"]:::compute
        ArchivedData[(Archived Training Data)]:::data
        Converter["Model Converter"]:::compute
        ImageModel[(Image Model Artifacts)]:::data
        TextModel[(Text Model Artifacts)]:::data

        TrainingData --> Notebook
        ValidationData --> Notebook
        Notebook --> ArchivedData
        Notebook --> Converter
        Converter --> ImageModel
        Converter --> TextModel
    end

    subgraph "Deployment Layer"
        subgraph "Firebase Hosting"
            FirebaseHosting["Firebase Hosting"]:::service
        end
        subgraph "Hosting Config"
            FirebaseRC[".firebaserc"]:::config
            FirebaseJSON["firebase.json"]:::config
        end
        subgraph "Web UI Assets"
            Index["index.html"]:::frontend
            CSS["style.css"]:::frontend
            Script["script.js"]:::frontend
            Images[(Assets Images)]:::frontend
        end

        ImageModel --> FirebaseHosting
        TextModel --> FirebaseHosting
        Index --> FirebaseHosting
        CSS --> FirebaseHosting
        Script --> FirebaseHosting
        Images --> FirebaseHosting
        FirebaseRC --> FirebaseHosting
        FirebaseJSON --> FirebaseHosting
    end

    subgraph "Client Layer"
        Browser["Client Browser"]:::client
        UI["Web App UI"]:::frontend
        TFJS["TensorFlow.js Library"]:::library

        Browser --> UI
        UI --> TFJS
        TFJS --> ImageModel
        TFJS --> TextModel
        FirebaseHosting --> Browser
        UI -->|"Display Classification Result"| Browser
    end

    click TrainingData "https://github.com/mrnidhi/sensitive_data_classification/tree/main/dataset/training"
    click ValidationData "https://github.com/mrnidhi/sensitive_data_classification/tree/main/dataset/validation"
    click Notebook "https://github.com/mrnidhi/sensitive_data_classification/blob/main/Sensitive_Data_Classification.ipynb"
    click ArchivedData "https://github.com/mrnidhi/sensitive_data_classification/tree/main/training_set/"
    click FirebaseRC "https://github.com/mrnidhi/sensitive_data_classification/blob/main/webapp/.firebaserc"
    click FirebaseJSON "https://github.com/mrnidhi/sensitive_data_classification/blob/main/webapp/firebase.json"
    click Index "https://github.com/mrnidhi/sensitive_data_classification/blob/main/webapp/public/index.html"
    click CSS "https://github.com/mrnidhi/sensitive_data_classification/blob/main/webapp/public/assets/style.css"
    click Script "https://github.com/mrnidhi/sensitive_data_classification/blob/main/webapp/public/assets/script.js"
    click Images "https://github.com/mrnidhi/sensitive_data_classification/tree/main/webapp/public/assets/images"
    click ImageModel "https://github.com/mrnidhi/sensitive_data_classification/tree/main/webapp/public/models/image_model/"
    click TextModel "https://github.com/mrnidhi/sensitive_data_classification/tree/main/webapp/public/models/text_model/"

    classDef data fill:#c2f0c2,stroke:#333,stroke-width:1px
    classDef compute fill:#f9cb9c,stroke:#333,stroke-width:1px
    classDef service fill:#9fc5e8,stroke:#333,stroke-width:1px
    classDef config fill:#d9d9d9,stroke:#333,stroke-width:1px
    classDef frontend fill:#fff2cc,stroke:#333,stroke-width:1px
    classDef client fill:#f4cccc,stroke:#333,stroke-width:1px
    classDef library fill:#d0e0e3,stroke:#333,stroke-width:1px
```
