# arrongeek/face-landmarks architecture

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

- Interactive diagram: https://gitdiagram.com/arrongeek/face-landmarks
- Repository: https://github.com/arrongeek/face-landmarks

## Overview

This is a browser demo for real-time face-landmark detection with MediaPipe Face Mesh. The main workflow initializes camera and model/backend settings, repeatedly runs face inference on video frames, and draws landmark or face-part overlays while reporting FPS. The UI also exposes camera, model, backend, and runtime-flag controls. The README is empty; the graph follows the sampled source and SOURCE INDEX, so unsampled implementation details are omitted.

Main entry points: [`src/index.js`](https://github.com/arrongeek/face-landmarks/blob/master/src/index.js) (Frame loop), [`src/shared/params.js`](https://github.com/arrongeek/face-landmarks/blob/master/src/shared/params.js) (Model and runtime state), [`src/camera.js`](https://github.com/arrongeek/face-landmarks/blob/master/src/camera.js) (Camera capture), [`src/option_panel.js`](https://github.com/arrongeek/face-landmarks/blob/master/src/option_panel.js) (Camera options)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Demo orchestration"]
  node_app["Frame loop<br/>[index.js]"]
  node_inference["Face inference<br/>[index.js]"]
end

subgraph group_config["Configuration"]
  node_options["Camera options<br/>[option_panel.js]"]
  node_model_options["Model and backend UI<br/>[option_panel.js]"]
  node_state["Model and runtime state<br/>[params.js]"]
end

subgraph group_vision["Face processing"]
  node_camera["Camera capture<br/>[camera.js]"]
  node_backend["Backend setup<br/>[util.js]"]
  node_detector["Detector creation<br/>[params.js]"]
  node_drawing["Landmark rendering<br/>[util.js]"]
  node_mesh["Mesh topology<br/>[triangulation.js]"]
end

subgraph group_display["Display and feedback"]
  node_overlay["Canvas output<br/>[camera.js]"]
  node_stats["FPS panel<br/>[stats_panel.js]"]
  node_customize["Face-part styling<br/>[util.js]"]
end

node_user(("Demo user"))
node_camera_api["Browser camera API"]
node_wasm["WASM assets CDN"]
node_model_library["Face-landmarks library"]

node_user -->|"opens demo"| node_app
node_app -->|"sets up controls"| node_options
node_options -->|"sets up model UI"| node_model_options
node_options -->|"configures camera"| node_state
node_model_options -->|"updates settings"| node_state
node_app -->|"sets up camera"| node_camera
node_camera -->|"requests video"| node_camera_api
node_camera -->|"reads camera settings"| node_state
node_app -->|"sets backend"| node_backend
node_app -->|"creates detector"| node_state
node_state -->|"creates detector"| node_model_library
node_app -->|"runs frame loop"| node_inference
node_inference -->|"reads video frames"| node_camera
node_inference -->|"estimates faces"| node_detector
node_inference -->|"reads render settings"| node_state
node_inference -->|"draws frame and faces"| node_overlay
node_camera -->|"delegates rendering"| node_drawing
node_drawing -->|"uses topology"| node_mesh
node_drawing -->|"applies face styling"| node_customize
node_app -->|"sets up FPS panel"| node_stats
node_app -->|"updates FPS"| node_stats
node_app -->|"loads WASM assets"| node_wasm

click node_app "https://github.com/arrongeek/face-landmarks/blob/master/src/index.js"
click node_camera "https://github.com/arrongeek/face-landmarks/blob/master/src/camera.js"
click node_options "https://github.com/arrongeek/face-landmarks/blob/master/src/option_panel.js"
click node_model_options "https://github.com/arrongeek/face-landmarks/blob/master/src/shared/option_panel.js"
click node_state "https://github.com/arrongeek/face-landmarks/blob/master/src/shared/params.js"
click node_backend "https://github.com/arrongeek/face-landmarks/blob/master/src/shared/util.js"
click node_detector "https://github.com/arrongeek/face-landmarks/blob/master/src/shared/params.js"
click node_inference "https://github.com/arrongeek/face-landmarks/blob/master/src/index.js"
click node_drawing "https://github.com/arrongeek/face-landmarks/blob/master/src/shared/util.js"
click node_mesh "https://github.com/arrongeek/face-landmarks/blob/master/src/shared/triangulation.js"
click node_overlay "https://github.com/arrongeek/face-landmarks/blob/master/src/camera.js"
click node_stats "https://github.com/arrongeek/face-landmarks/blob/master/src/shared/stats_panel.js"
click node_customize "https://github.com/arrongeek/face-landmarks/blob/master/src/shared/util.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_app,node_inference,node_user,node_camera_api toneBlue
class node_options,node_model_options,node_state toneAmber
class node_camera,node_backend,node_detector,node_drawing,node_mesh toneMint
class node_overlay,node_stats,node_customize toneRose
class node_wasm,node_model_library toneIndigo
```

## Components

### Demo orchestration

- [Frame loop](https://github.com/arrongeek/face-landmarks/blob/master/src/index.js): `src/index.js`
- [Face inference](https://github.com/arrongeek/face-landmarks/blob/master/src/index.js): `src/index.js`

### Configuration

- [Camera options](https://github.com/arrongeek/face-landmarks/blob/master/src/option_panel.js): `src/option_panel.js`
- [Model and backend UI](https://github.com/arrongeek/face-landmarks/blob/master/src/shared/option_panel.js): `src/shared/option_panel.js`
- [Model and runtime state](https://github.com/arrongeek/face-landmarks/blob/master/src/shared/params.js): `src/shared/params.js`

### Face processing

- [Camera capture](https://github.com/arrongeek/face-landmarks/blob/master/src/camera.js): `src/camera.js`
- [Backend setup](https://github.com/arrongeek/face-landmarks/blob/master/src/shared/util.js): `src/shared/util.js`
- [Detector creation](https://github.com/arrongeek/face-landmarks/blob/master/src/shared/params.js): `src/shared/params.js`
- [Landmark rendering](https://github.com/arrongeek/face-landmarks/blob/master/src/shared/util.js): `src/shared/util.js`
- [Mesh topology](https://github.com/arrongeek/face-landmarks/blob/master/src/shared/triangulation.js): `src/shared/triangulation.js`

### Display and feedback

- [Canvas output](https://github.com/arrongeek/face-landmarks/blob/master/src/camera.js): `src/camera.js`
- [FPS panel](https://github.com/arrongeek/face-landmarks/blob/master/src/shared/stats_panel.js): `src/shared/stats_panel.js`
- [Face-part styling](https://github.com/arrongeek/face-landmarks/blob/master/src/shared/util.js): `src/shared/util.js`

### Other components

- **Demo user**
- **Browser camera API**
- **WASM assets CDN**
- **Face-landmarks library**

## Connections

- Demo user → Frame loop: opens demo (evidence: `src/index.js`)
- Frame loop → Camera options: sets up controls (evidence: `src/index.js`)
- Camera options → Model and backend UI: sets up model UI (evidence: `src/option_panel.js`)
- Camera options → Model and runtime state: configures camera (evidence: `src/option_panel.js`)
- Model and backend UI → Model and runtime state: updates settings (evidence: `src/shared/option_panel.js`)
- Frame loop → Camera capture: sets up camera (evidence: `src/index.js`)
- Camera capture → Browser camera API: requests video (evidence: `src/camera.js`)
- Camera capture → Model and runtime state: reads camera settings (evidence: `src/camera.js`)
- Frame loop → Backend setup: sets backend (evidence: `src/index.js`)
- Frame loop → Model and runtime state: creates detector (evidence: `src/index.js`)
- Model and runtime state → Face-landmarks library: creates detector (evidence: `src/shared/params.js`)
- Frame loop → Face inference: runs frame loop (evidence: `src/index.js`)
- Face inference → Camera capture: reads video frames (evidence: `src/index.js`)
- Face inference → Detector creation: estimates faces (evidence: `src/index.js`)
- Face inference → Model and runtime state: reads render settings (evidence: `src/index.js`)
- Face inference → Canvas output: draws frame and faces (evidence: `src/index.js`)
- Camera capture → Landmark rendering: delegates rendering (evidence: `src/camera.js`)
- Landmark rendering → Mesh topology: uses topology (evidence: `src/shared/util.js`)
- Landmark rendering → Face-part styling: applies face styling (evidence: `src/shared/util.js`)
- Frame loop → FPS panel: sets up FPS panel (evidence: `src/index.js`)
- Frame loop → FPS panel: updates FPS (evidence: `src/index.js`)
- Frame loop → WASM assets CDN: loads WASM assets (evidence: `src/index.js`)
