# grigor-stoyanov/ascii-webcam architecture

> Architecture diagram of the GitHub repository grigor-stoyanov/ascii-webcam, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-18). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/grigor-stoyanov/ascii-webcam
- Repository: https://github.com/grigor-stoyanov/ascii-webcam

## Overview

ASCII Webcam is a browser-only webcam application that turns a live front-camera feed into colored ASCII art for display or capture. The main workflow acquires camera video, checks for motion, updates face landmarks and a person mask when needed, masks the frame, and renders a mirrored character grid with brightness and 3D face shading. Users can adjust presentation settings, save selfies, toggle FPS, and show camera status. Source excerpts establish the main control flow and several UI dependencies; README documents additional behavior. No server-side processing or persistent application store is indicated.

Main entry points: [`src/config.js`](https://github.com/grigor-stoyanov/ascii-webcam/blob/master/src/config.js) (Defaults and options), [`src/detection/face.js`](https://github.com/grigor-stoyanov/ascii-webcam/blob/master/src/detection/face.js) (Face landmarks), [`src/settings.js`](https://github.com/grigor-stoyanov/ascii-webcam/blob/master/src/settings.js) (Live settings), [`src/rendering/ascii.js`](https://github.com/grigor-stoyanov/ascii-webcam/blob/master/src/rendering/ascii.js) (ASCII drawing)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_capture["Capture and detection"]
  node_mediapipe["MediaPipe runtime<br/>[mediapipe.js]"]
  node_motion["Motion check<br/>[motion.js]"]
  node_face["Face landmarks<br/>[face.js]"]
  node_segmentation["Person segmentation<br/>[segmentation.js]"]
end

subgraph group_render["Masking and rendering"]
  node_mask["Background mask<br/>[mask.js]"]
  node_ascii["ASCII drawing<br/>[ascii.js]"]
  node_brightness["Brightness and depth<br/>[brightness.js]"]
  node_overlay["Face overlay<br/>[faceOverlay.js]"]
end

subgraph group_controls["Controls and feedback"]
  node_config["Defaults and options<br/>[config.js]"]
  node_settings["Live settings<br/>[settings.js]"]
  node_panel["Settings panel<br/>[panel.js]"]
  node_keyboard["Keyboard controls<br/>[keyboard.js]"]
  node_selfie["Selfie capture<br/>[selfie.js]"]
  node_fps["FPS counter<br/>[fps.js]"]
  node_status["Camera status<br/>[status.js]"]
end

node_user(("Viewer"))
node_camera["Device camera"]
node_display["Canvas output"]

node_user -->|"grants access"| node_camera
node_camera -->|"supplies frames"| node_motion
node_motion -->|"triggers detection"| node_face
node_motion -->|"triggers segmentation"| node_segmentation
node_mediapipe -->|"provides runtime"| node_face
node_mediapipe -->|"provides runtime"| node_segmentation
node_segmentation -->|"returns mask"| node_mask
node_mask -->|"masks frame"| node_ascii
node_face -->|"supplies landmarks"| node_ascii
node_ascii -->|"computes levels"| node_brightness
node_face -->|"supplies depth points"| node_brightness
node_ascii -->|"draws characters"| node_display
node_face -->|"supplies landmarks"| node_overlay
node_overlay -->|"draws overlay"| node_display
node_config -->|"sets thresholds"| node_motion
node_config -->|"sets model options"| node_face
node_config -->|"sets model options"| node_segmentation
node_config -->|"sets shading options"| node_brightness
node_config -->|"sets render options"| node_ascii
node_config -->|"sets defaults"| node_settings
node_panel -->|"updates settings"| node_settings
node_keyboard -->|"updates settings"| node_settings
node_settings -->|"notifies changes"| node_panel
node_settings -->|"configures rendering"| node_ascii
node_settings -->|"configures levels"| node_brightness
node_panel -->|"reads shortcuts"| node_keyboard
node_panel -->|"triggers capture"| node_selfie
node_keyboard -->|"triggers capture"| node_selfie
node_keyboard -->|"toggles counter"| node_fps
node_user -->|"adjusts controls"| node_panel
node_user -->|"uses shortcuts"| node_keyboard
node_user -->|"requests selfie"| node_selfie
node_user -->|"toggles FPS"| node_fps
node_status -->|"reports camera state"| node_user

click node_mediapipe "https://github.com/grigor-stoyanov/ascii-webcam/blob/master/src/detection/mediapipe.js"
click node_motion "https://github.com/grigor-stoyanov/ascii-webcam/blob/master/src/detection/motion.js"
click node_face "https://github.com/grigor-stoyanov/ascii-webcam/blob/master/src/detection/face.js"
click node_segmentation "https://github.com/grigor-stoyanov/ascii-webcam/blob/master/src/detection/segmentation.js"
click node_mask "https://github.com/grigor-stoyanov/ascii-webcam/blob/master/src/rendering/mask.js"
click node_ascii "https://github.com/grigor-stoyanov/ascii-webcam/blob/master/src/rendering/ascii.js"
click node_brightness "https://github.com/grigor-stoyanov/ascii-webcam/blob/master/src/rendering/brightness.js"
click node_overlay "https://github.com/grigor-stoyanov/ascii-webcam/blob/master/src/rendering/faceOverlay.js"
click node_config "https://github.com/grigor-stoyanov/ascii-webcam/blob/master/src/config.js"
click node_settings "https://github.com/grigor-stoyanov/ascii-webcam/blob/master/src/settings.js"
click node_panel "https://github.com/grigor-stoyanov/ascii-webcam/blob/master/src/ui/panel.js"
click node_keyboard "https://github.com/grigor-stoyanov/ascii-webcam/blob/master/src/ui/keyboard.js"
click node_selfie "https://github.com/grigor-stoyanov/ascii-webcam/blob/master/src/ui/selfie.js"
click node_fps "https://github.com/grigor-stoyanov/ascii-webcam/blob/master/src/ui/fps.js"
click node_status "https://github.com/grigor-stoyanov/ascii-webcam/blob/master/src/ui/status.js"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_mediapipe,node_motion,node_face,node_segmentation,node_user toneBlue
class node_mask,node_ascii,node_brightness,node_overlay toneAmber
class node_config,node_settings,node_panel,node_keyboard,node_selfie,node_fps,node_status toneMint
class node_camera,node_display toneIndigo
```

## Components

### Capture and detection

- [MediaPipe runtime](https://github.com/grigor-stoyanov/ascii-webcam/blob/master/src/detection/mediapipe.js): `src/detection/mediapipe.js`
- [Motion check](https://github.com/grigor-stoyanov/ascii-webcam/blob/master/src/detection/motion.js): `src/detection/motion.js`
- [Face landmarks](https://github.com/grigor-stoyanov/ascii-webcam/blob/master/src/detection/face.js): `src/detection/face.js`
- [Person segmentation](https://github.com/grigor-stoyanov/ascii-webcam/blob/master/src/detection/segmentation.js): `src/detection/segmentation.js`

### Masking and rendering

- [Background mask](https://github.com/grigor-stoyanov/ascii-webcam/blob/master/src/rendering/mask.js): `src/rendering/mask.js`
- [ASCII drawing](https://github.com/grigor-stoyanov/ascii-webcam/blob/master/src/rendering/ascii.js): `src/rendering/ascii.js`
- [Brightness and depth](https://github.com/grigor-stoyanov/ascii-webcam/blob/master/src/rendering/brightness.js): `src/rendering/brightness.js`
- [Face overlay](https://github.com/grigor-stoyanov/ascii-webcam/blob/master/src/rendering/faceOverlay.js): `src/rendering/faceOverlay.js`

### Controls and feedback

- [Defaults and options](https://github.com/grigor-stoyanov/ascii-webcam/blob/master/src/config.js): `src/config.js`
- [Live settings](https://github.com/grigor-stoyanov/ascii-webcam/blob/master/src/settings.js): `src/settings.js`
- [Settings panel](https://github.com/grigor-stoyanov/ascii-webcam/blob/master/src/ui/panel.js): `src/ui/panel.js`
- [Keyboard controls](https://github.com/grigor-stoyanov/ascii-webcam/blob/master/src/ui/keyboard.js): `src/ui/keyboard.js`
- [Selfie capture](https://github.com/grigor-stoyanov/ascii-webcam/blob/master/src/ui/selfie.js): `src/ui/selfie.js`
- [FPS counter](https://github.com/grigor-stoyanov/ascii-webcam/blob/master/src/ui/fps.js): `src/ui/fps.js`
- [Camera status](https://github.com/grigor-stoyanov/ascii-webcam/blob/master/src/ui/status.js): `src/ui/status.js`

### Other components

- **Viewer**
- **Device camera**
- **Canvas output**

## Connections

- Viewer → Device camera: grants access
- Device camera → Motion check: supplies frames
- Motion check → Face landmarks: triggers detection (evidence: `src/main.js`)
- Motion check → Person segmentation: triggers segmentation (evidence: `src/main.js`)
- MediaPipe runtime → Face landmarks: provides runtime (evidence: `src/detection/face.js`)
- MediaPipe runtime → Person segmentation: provides runtime (evidence: `src/detection/segmentation.js`)
- Person segmentation → Background mask: returns mask (evidence: `src/main.js`)
- Background mask → ASCII drawing: masks frame (evidence: `src/main.js`)
- Face landmarks → ASCII drawing: supplies landmarks (evidence: `src/main.js`)
- ASCII drawing → Brightness and depth: computes levels (evidence: `src/rendering/ascii.js`)
- Face landmarks → Brightness and depth: supplies depth points
- ASCII drawing → Canvas output: draws characters
- Face landmarks → Face overlay: supplies landmarks (evidence: `src/main.js`)
- Face overlay → Canvas output: draws overlay
- Defaults and options → Motion check: sets thresholds (evidence: `src/detection/motion.js`)
- Defaults and options → Face landmarks: sets model options (evidence: `src/detection/face.js`)
- Defaults and options → Person segmentation: sets model options (evidence: `src/detection/segmentation.js`)
- Defaults and options → Brightness and depth: sets shading options (evidence: `src/rendering/brightness.js`)
- Defaults and options → ASCII drawing: sets render options (evidence: `src/rendering/ascii.js`)
- Defaults and options → Live settings: sets defaults (evidence: `src/settings.js`)
- Settings panel → Live settings: updates settings (evidence: `src/ui/panel.js`)
- Keyboard controls → Live settings: updates settings (evidence: `src/ui/keyboard.js`)
- Live settings → Settings panel: notifies changes (evidence: `src/ui/panel.js`)
- Live settings → ASCII drawing: configures rendering (evidence: `src/rendering/ascii.js`)
- Live settings → Brightness and depth: configures levels (evidence: `src/rendering/brightness.js`)
- Settings panel → Keyboard controls: reads shortcuts (evidence: `src/ui/panel.js`)
- Settings panel → Selfie capture: triggers capture (evidence: `src/ui/panel.js`)
- Keyboard controls → Selfie capture: triggers capture (evidence: `src/ui/keyboard.js`)
- Keyboard controls → FPS counter: toggles counter (evidence: `src/ui/keyboard.js`)
- Viewer → Settings panel: adjusts controls (evidence: `README.md`)
- Viewer → Keyboard controls: uses shortcuts (evidence: `README.md`)
- Viewer → Selfie capture: requests selfie (evidence: `README.md`)
- Viewer → FPS counter: toggles FPS (evidence: `README.md`)
- Camera status → Viewer: reports camera state
