# abhayb97/draw_tool architecture

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

- Interactive diagram: https://gitdiagram.com/abhayb97/draw_tool
- Repository: https://github.com/abhayb97/draw_tool

## Overview

##### File structure
- Top‐level files:
- index.html – the single‐page entry point
- style.css – presentation layer
- README.md – documentation
- vercel.json – deployment configuration for Vercel
- No backend or server-side code—everything lives in the browser.
- OpenCV.js is brought in as a client‐side library (likely via a <script> tag or CDN).

##### README for additional insights
- Core feature: photo → line drawing conversion using the Canvas API and OpenCV.js.
- No mention of any server‐side APIs or databases.
- Hosted on Vercel, suggesting a CI/CD pipeline that picks up the static assets from the git repo.

##### Main components and their interactions
a. Components:
- User’s Web Browser (client)
- index.html + style.css + main.js (frontend code)
- OpenCV.js library (client‐side image processing)
- Canvas API (browser rendering surface)
- Vercel Hosting Platform (serving static files)
- Optional CDN (for OpenCV.js or other static assets)
b. Data flows:
1. User selects or uploads an image in the browser.
2. JavaScript reads the image into a Canvas element.
3. OpenCV.js functions process the Canvas pixel data to detect edges, apply thresholds, and generate a sketch.
4. Processed image is rendered back onto the Canvas.
5. User clicks “Download,” and JS serializes the Canvas to a PNG and initiates a download.
c. Architectural patterns / design principles:
- Single‐Page Application (SPA) style, though very lightweight.
- Client‐side processing: no external API calls beyond loading assets.
- Static hosting with continuous deployment on Vercel.
d. Key technologies:
- HTML5 (structure), CSS3 (styling)
- JavaScript + Canvas API (UI logic, rendering)
- OpenCV.js (edge detection, image processing)
- Vercel (static file serving, deployment)

##### Diagramming recommendations
- “Load assets” (Vercel → Browser)
- “Image upload” (User → Browser)
- “Process image” (Browser → OpenCV.js → Canvas)
- “Render/download” (Canvas → User)
- Blue for User/Browser components
- Green for frontend code modules
- Orange for third-party libraries
- Purple for hosting/CDN services

##### Detailed capture of essential architectural elements
- index.html / style.css / main.js
- Canvas element
- OpenCV.js module
- Outside the boundary:
- Vercel (serves static files over HTTPS)
- CDN (if hosting OpenCV.js)
- User interactions at the top: “Upload Image” and “Download Sketch.”
- That no server-side or database component exists.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "User Interaction"
        User["User"]:::user
    end

    subgraph "Browser (Client)"
        HTML["index.html"]:::frontend
        CSS["style.css"]:::frontend
        JS["main.js"]:::frontend
        Canvas["Canvas API"]:::frontend
        OpenCV["OpenCV.js"]:::thirdparty
    end

    subgraph "Hosting & CDN"
        Vercel["Vercel Hosting"]:::hosting
        CDN["CDN for OpenCV.js"]:::hosting
    end

    subgraph "Project Repository"
        README["README.md"]:::hosting
    end

    User -->|"Select/Upload Image"| HTML
    Vercel -->|"Serves HTML/CSS/JS over HTTPS"| HTML
    Vercel -->|"Serves HTML/CSS/JS over HTTPS"| CSS
    Vercel -->|"Serves HTML/CSS/JS over HTTPS"| JS
    CDN -->|"Serves OpenCV.js Library"| OpenCV

    HTML -->|"Initializes UI & Loads Scripts"| JS
    JS -->|"Draw & Manipulate"| Canvas
    JS -->|"Call Edge Detection"| OpenCV
    OpenCV -->|"Processed Pixels"| Canvas
    Canvas -->|"Render Sketch"| HTML
    Canvas -->|"PNG Export & Download"| User

    %% Click Events
    click HTML "https://github.com/abhayb97/draw_tool/blob/main/index.html"
    click CSS "https://github.com/abhayb97/draw_tool/blob/main/style.css"
    click Vercel "https://github.com/abhayb97/draw_tool/blob/main/vercel.json"
    click README "https://github.com/abhayb97/draw_tool/blob/main/README.md"

    %% Styles
    classDef user fill:#AED6F1,stroke:#1B4F72,color:#1B2631;
    classDef frontend fill:#ABEBC6,stroke:#196F3D,color:#1B2631;
    classDef thirdparty fill:#F9E79F,stroke:#B9770E,color:#1B2631;
    classDef hosting fill:#D7BDE2,stroke:#6C3483,color:#1B2631;
```
