# ngxson/smolvlm-realtime-webcam architecture

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

- Interactive diagram: https://gitdiagram.com/ngxson/smolvlm-realtime-webcam
- Repository: https://github.com/ngxson/smolvlm-realtime-webcam

## Overview

##### Project type and purpose
- This is a lightweight, browser-based demo application (essentially a single-page front-end) that connects to a separate “llama.cpp” server running the SmolVLM 500M model for real-time object detection. The front-end captures camera frames, sends them as requests to the llama.cpp-based inference server, and then displays the server’s responses (object detection results) in real time.

##### File structure
- Top level:
- LICENSE (license text)
- README.md (setup and usage instructions)
- index.html (the entire front-end code)
- No backend in this repo; instead the front-end relies on an external llama.cpp server the user spins up.

##### README for additional insights
- The README tells us that you must:
1. Install and run `llama-server` (a llama.cpp HTTP/gRPC server) with the SmolVLM-500M model.
2. Open `index.html` in a browser.
3. Use built-in JS to access your camera, call the llama-server endpoint, and render results.

##### Elements
- Browser UI (index.html + JS)
- Camera (getUserMedia)
- Inference Service (llama-server + SmolVLM-500M)
- Compute Layer (GPU/CPU runtime)
1. “Video frames” from Camera → Browser
2. “POST /infer” frame data + prompt → Inference Service
3. “Detection Results” JSON/text ← Inference Service
4. “Render overlays” in Browser ← Detection Results
- Blue for front-end/browser components
- Green for inference service components
- Orange for hardware/compute resources

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "Developer Workstation"
        direction TB
        subgraph "Frontend (Browser)"
            direction TB
            CAM["Camera (getUserMedia)"]:::frontend
            UI["Browser UI (index.html + JS)"]:::frontend
            DOC["Project Documentation (README.md)"]:::docs
            LIC["License Information (LICENSE)"]:::docs
        end
        subgraph "Inference Server"
            direction TB
            SRV["llama-server"]:::backend
            MODEL["SmolVLM-500M Model (GGUF)"]:::backend
            HW["Compute Layer (CPU/GPU Runtime)"]:::hardware
        end
    end

    CAM -->|"Video frames"| UI
    UI -->|"POST /infer (frame data + prompt)"| SRV
    SRV -->|"Detection Results (JSON/text)"| UI
    UI -->|"Render overlays (Canvas API)"| UI

    SRV -->|"Loads model"| MODEL
    SRV -->|"Executes inference on"| HW

    click UI "https://github.com/ngxson/smolvlm-realtime-webcam/blob/main/index.html"
    click DOC "https://github.com/ngxson/smolvlm-realtime-webcam/blob/main/README.md"
    click LIC "https://github.com/ngxson/smolvlm-realtime-webcam/tree/main/LICENSE"

    classDef frontend fill:#ADD8E6,stroke:#333,stroke-width:1px
    classDef backend fill:#90EE90,stroke:#333,stroke-width:1px
    classDef hardware fill:#FFD580,stroke:#333,stroke-width:1px
    classDef docs fill:#D3D3D3,stroke:#333,stroke-width:1px
```
