# wickypolineni/vision_ai_js architecture

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

- Interactive diagram: https://gitdiagram.com/wickypolineni/vision_ai_js
- Repository: https://github.com/wickypolineni/vision_ai_js

## Overview

##### Main Components
- User Interface (UI) Layer: Represented by the HTML files (index.html, live/index.html) and styled by CSS files (style.css, live/live.css).
- Application Logic: The JavaScript files (script.js, live/live.js, prompts.js, live/prompts.js) that handle event handling, live mode functionalities, API key management, and interactions with the Google Gemini API.
- External Service: The Google Gemini API, which is integrated to process images in real time and provide analysis (the core “AI behind the scenes”).
- Assets: The images folder (for static assets) and any additional resources the UI uses.
- Deployment/Live Environment Module: The “live” directory indicates a special mode of operation (or a separate build) that might have additional or different behavioral logic.

##### Relationships and Interactions
- Users interact with the UI through a web browser by visiting index.html or the live mode URL.
- The UI sends user inputs (like image snapshots and API key entries) to the client-side JavaScript.
- The JavaScript, acting as the business logic layer, handles these events and communicates with the external Google Gemini API to fetch image analysis or perform live tracking.
- Responses from the API are then processed in JavaScript and rendered back on the UI.
- For live mode, similar interactions occur but are continuously executed for real-time analysis.

##### Architectural Patterns and Principles
- Separation of concerns is evident – HTML for structure, CSS for appearance, and JavaScript for behavior.
- A modular approach is used by separating live mode functionality into its own directory, implying some level of separation (or even a possible micro-frontend approach) within the same project.
- The system leverages an external API (Google Gemini API), meaning a clear boundary exists between local processing and external services.

##### Relevant Technologies
- Frontend: Vanilla JavaScript, HTML, and CSS.
- External Service: Google Gemini API (using keys provided by the user).
- Deployment: Static hosting approach, with separate live and standard modes.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% User node
    User["User Browser"]:::external

    %% Standard Mode Subgraph
    subgraph "Standard Mode"
        %% UI Layer (Standard)
        subgraph "UI Layer (Standard)"
            HTML_std["index.html"]:::static
            CSS_std["style.css"]:::static
        end
        %% Application Logic (Standard)
        subgraph "Application Logic (Standard)"
            JS_std["script.js"]:::logic
            Prompts_std["prompts.js"]:::logic
        end
    end

    %% Live Mode Subgraph
    subgraph "Live Mode"
        %% Deployment module for Live Environment
        Deployment["live"]:::deployment
        %% UI Layer (Live)
        subgraph "UI Layer (Live)"
            HTML_live["live/index.html"]:::static
            CSS_live["live/live.css"]:::static
        end
        %% Application Logic (Live)
        subgraph "Application Logic (Live)"
            JS_live["live/live.js"]:::logic
            Prompts_live["live/prompts.js"]:::logic
        end
    end

    %% Assets and External API
    Assets["images"]:::assets
    Gemini["Google Gemini API"]:::external

    %% Connections for Standard Mode
    User --> HTML_std
    User --> CSS_std
    HTML_std --> JS_std
    CSS_std --> JS_std
    JS_std --> Prompts_std
    JS_std -->|"API_request"| Gemini
    Gemini -->|"API_response"| JS_std
    HTML_std -->|"loads"| Assets

    %% Connections for Live Mode
    User --> HTML_live
    User --> CSS_live
    HTML_live --> JS_live
    CSS_live --> JS_live
    JS_live --> Prompts_live
    JS_live -->|"API_request"| Gemini
    Gemini -->|"API_response"| JS_live
    HTML_live -->|"loads"| Assets

    %% Deployment connections for Live Mode
    Deployment --> HTML_live
    Deployment --> CSS_live
    Deployment --> JS_live
    Deployment --> Prompts_live

    %% Styles
    classDef static fill:#fceabb,stroke:#e3a21a,stroke-width:2px;
    classDef logic fill:#bbdefb,stroke:#1e88e5,stroke-width:2px;
    classDef external fill:#ffccbc,stroke:#e64a19,stroke-width:2px;
    classDef assets fill:#dcedc8,stroke:#7cb342,stroke-width:2px;
    classDef deployment fill:#d1c4e9,stroke:#512da8,stroke-width:2px;

    %% Click Events
    click HTML_std "https://github.com/wickypolineni/vision_ai_js/blob/main/index.html"
    click CSS_std "https://github.com/wickypolineni/vision_ai_js/blob/main/style.css"
    click JS_std "https://github.com/wickypolineni/vision_ai_js/blob/main/script.js"
    click Prompts_std "https://github.com/wickypolineni/vision_ai_js/blob/main/prompts.js"
    click HTML_live "https://github.com/wickypolineni/vision_ai_js/blob/main/live/index.html"
    click CSS_live "https://github.com/wickypolineni/vision_ai_js/blob/main/live/live.css"
    click JS_live "https://github.com/wickypolineni/vision_ai_js/blob/main/live/live.js"
    click Prompts_live "https://github.com/wickypolineni/vision_ai_js/blob/main/live/prompts.js"
    click Assets "https://github.com/wickypolineni/vision_ai_js/tree/main/images"
    click Deployment "https://github.com/wickypolineni/vision_ai_js/tree/main/live"
```
