# josh-test-1120/handgestures architecture

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

- Interactive diagram: https://gitdiagram.com/josh-test-1120/handgestures
- Repository: https://github.com/josh-test-1120/handgestures

## Overview

##### Project Type & Purpose
- This is a full‐stack ML application for recognizing hand gestures.
- Purpose: collect raw sensor data via Arduino, train/evaluate an ML model (in a Jupyter notebook), then expose inference through a Django web frontend for live demos and summaries.

##### Key Architectural Components
a. Sensor Layer
– Component: Arduino running `sensor_collect_arduino_sketch.ino`
– Role: reads hand‐gesture sensor readings and streams them over serial/USB.
b. Ingestion & Storage Layer
– Component: Data‐sample CSV (`backend/data-sample.csv`)
c. Model Training Layer
– Component: Jupyter notebook (`Capstone-ML-Model-Prototype.ipynb`)
– Role: cleans data, engineers features, trains a classifier/regressor, outputs a serialized model artifact.
d. Model Serving Layer
– Component: Python service or Django endpoint wrapping the trained model
– Role: loads the saved model artifact, accepts new sensor input, returns predictions via a REST API.
e. Frontend Web Layer
– Component: Django project under `frontend/handgestures`
– Subcomponents:
- `main_app/views.py` – serves HTML pages and calls the model API for live inference
- `templates/main_app/*.html` – demo and live_demo pages
- `static/main_app/js` – handles real‐time data push/pull (e.g., via AJAX or WebSocket)
– Role: user interface for viewing live predictions, browsing summaries, and contacting the team.
f. Optional Persistence Layer
– Component: SQLite database (`frontend/handgestures/db.sqlite3`)
– Role: stores user inputs, logs of inferences, demo sessions, etc.

##### Relationships & Data Flow (Pipeline Style)
1. Sensor Arduino → serial/USB → CSV (or direct ingestion service)
2. CSV → Notebook → Trained Model artifact
3. Trained Model → Model Serving Service (loaded in memory)
4. Model Serving Service ↔ Django Frontend (REST API calls)
5. Django Frontend → Browser (HTML/JS live demo pages)

##### Architectural Patterns & Principles
- Separation of concerns: hardware vs. data vs. model vs. UI
- Pipeline stages: Data collection → preprocessing → model training → serving → presentation
- MVC in the frontend: Django models/views/templates
- “Single responsibility” for each layer makes it easy to swap out CSV for a message queue or replace the model with a different algorithm.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Data Collection"
        Arduino["Arduino Sensor"]:::green
        CSV["CSV Storage"]:::green
    end

    subgraph "Processing & Training"
        Notebook["ML Training Notebook"]:::blue
        ModelArtifact["Trained Model Artifact"]:::blue
        Requirements["Project Dependencies (requirements.txt)"]:::blue
    end

    subgraph "Model Serving/API"
        APIService["Model Serving API"]:::orange
    end

    subgraph "Frontend/UI"
        DjangoRoot["Django Project Root"]:::purple
        MainAppConfig["Main App Configuration"]:::purple
        Templates["HTML Templates"]:::purple
        StaticCSS["Static CSS"]:::purple
        StaticJS["Static JS"]:::purple
        Browser["Browser UI"]:::purple
        DB["SQLite Database"]:::purple
    end

    Arduino -->|"serial/USB"| CSV
    CSV -->|"load CSV"| Notebook
    Notebook -->|"serialize model"| ModelArtifact
    Notebook --> Requirements
    ModelArtifact -->|"load model"| APIService
    APIService -->|"HTTP JSON"| DjangoRoot
    DjangoRoot --> MainAppConfig
    MainAppConfig --> Templates
    MainAppConfig --> StaticCSS
    MainAppConfig --> StaticJS
    Templates --> Browser
    StaticJS --> Browser
    DjangoRoot --> DB

    click Arduino "https://github.com/josh-test-1120/handgestures/blob/main/backend/sensor_collect_arduino_sketch.ino"
    click CSV "https://github.com/josh-test-1120/handgestures/blob/main/backend/data-sample.csv"
    click Notebook "https://github.com/josh-test-1120/handgestures/blob/main/backend/Capstone-ML-Model-Prototype.ipynb"
    click APIService "https://github.com/josh-test-1120/handgestures/blob/main/frontend/handgestures/apps/main_app/views.py"
    click APIService "https://github.com/josh-test-1120/handgestures/blob/main/frontend/handgestures/apps/main_app/urls.py"
    click DjangoRoot "https://github.com/josh-test-1120/handgestures/blob/main/frontend/handgestures/manage.py"
    click DjangoRoot "https://github.com/josh-test-1120/handgestures/blob/main/frontend/handgestures/handgestures/settings.py"
    click MainAppConfig "https://github.com/josh-test-1120/handgestures/blob/main/frontend/handgestures/apps/main_app/apps.py"
    click Templates "https://github.com/josh-test-1120/handgestures/blob/main/frontend/handgestures/apps/main_app/templates/main_app/*.html"
    click StaticCSS "https://github.com/josh-test-1120/handgestures/blob/main/frontend/handgestures/apps/main_app/static/main_app/css/style.css"
    click StaticJS "https://github.com/josh-test-1120/handgestures/tree/main/frontend/handgestures/apps/main_app/static/main_app/js"
    click DB "https://github.com/josh-test-1120/handgestures/blob/main/frontend/handgestures/db.sqlite3"
    click Requirements "https://github.com/josh-test-1120/handgestures/blob/main/requirements.txt"

    classDef green fill:#a8d5a2,stroke:#2f7d32,color:#000;
    classDef blue fill:#add8e6,stroke:#1e3a5f,color:#000;
    classDef orange fill:#f4a261,stroke:#b3541e,color:#000;
    classDef purple fill:#cba0eb,stroke:#5e237a,color:#000;
```
