# leitrim/humanface architecture

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

- Interactive diagram: https://gitdiagram.com/leitrim/humanface
- Repository: https://github.com/leitrim/humanface

## Overview

Human is a cross-platform TensorFlow.js vision library. A caller supplies an image, video, canvas, or tensor to the Human API; it prepares the input, loads and runs enabled vision models, and returns structured detections and optional visualizations. The README documents face analysis and recognition, body and hand tracking, gestures, segmentation, object detection, and image enhancement. The graph reflects sampled source and explicit README capabilities; links to unsampled subsystems are limited to documented or indexed relationships.

Main entry points: [`src/human.ts`](https://github.com/leitrim/humanface/blob/main/src/human.ts) (Human API), [`src/tfjs/backend.ts`](https://github.com/leitrim/humanface/blob/main/src/tfjs/backend.ts) (TensorFlow backends), [`src/tfjs/load.ts`](https://github.com/leitrim/humanface/blob/main/src/tfjs/load.ts) (Model loading), [`src/image/image.ts`](https://github.com/leitrim/humanface/blob/main/src/image/image.ts) (Image processing)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API and orchestration"]
  node_human["Human API<br/>[human.ts]"]
  node_config["Configuration<br/>[config.ts]"]
  node_public["Public exports<br/>[exports.ts]"]
end

subgraph group_runtime["Input and runtime"]
  node_image["Image processing<br/>[image.ts]"]
  node_enhance["Image enhancement<br/>[enhance.ts]"]
  node_webcam["Webcam handling<br/>[webcam.ts]"]
  node_env["Environment detection<br/>[env.ts]"]
  node_backend["TensorFlow backends<br/>[backend.ts]"]
  node_model_load["Model loading<br/>[load.ts]"]
  node_models["Model registry<br/>[models.ts]"]
end

subgraph group_vision["Vision models"]
  node_face["Face analysis<br/>[face.ts]"]
  node_facemesh["Face mesh<br/>[facemesh.ts]"]
  node_face_coords["Face mesh coordinates<br/>[facemeshcoords.ts]"]
  node_body["Body pose<br/>[blazepose.ts]"]
  node_hand["Hand tracking"]
  node_fingerpose["Finger gestures<br/>[fingerpose.ts]"]
  node_gesture["Gesture analysis<br/>[gesture.ts]"]
  node_object["Object detection<br/>[centernet.ts]"]
  node_segmentation["Body segmentation<br/>[rvm.ts]"]
end

subgraph group_results["Results and presentation"]
  node_result["Detection results<br/>[result.ts]"]
  node_draw_options["Drawing options<br/>[options.ts]"]
  node_draw["Result drawing<br/>[draw.ts]"]
end

node_caller(("Application caller"))
node_tfjs["TensorFlow.js"]

node_caller -->|"submits input"| node_human
node_human -->|"uses options"| node_config
node_human -->|"processes input"| node_image
node_image -->|"applies enhancement"| node_enhance
node_human -->|"checks backend"| node_backend
node_backend -->|"checks capabilities"| node_env
node_backend -->|"configures runtime"| node_tfjs
node_human -->|"loads models"| node_model_load
node_model_load -->|"loads graph models"| node_tfjs
node_model_load -->|"uses model definitions"| node_models
node_human -->|"runs face analysis"| node_face
node_face -->|"runs face mesh"| node_facemesh
node_facemesh -->|"uses coordinates"| node_face_coords
node_human -->|"runs pose model"| node_body
node_human -->|"runs hand tracking"| node_hand
node_hand -->|"estimates finger pose"| node_fingerpose
node_human -->|"runs object detection"| node_object
node_human -->|"runs segmentation"| node_segmentation
node_human -->|"analyzes gestures"| node_gesture
node_gesture -->|"classifies fingers"| node_fingerpose
node_human -->|"returns detections"| node_result
node_human -->|"draws results"| node_draw
node_draw -->|"uses options"| node_draw_options
node_human -.->|"supports webcam input"| node_webcam
node_human -->|"exposes API types"| node_public

click node_human "https://github.com/leitrim/humanface/blob/main/src/human.ts"
click node_config "https://github.com/leitrim/humanface/blob/main/src/config.ts"
click node_public "https://github.com/leitrim/humanface/blob/main/src/exports.ts"
click node_image "https://github.com/leitrim/humanface/blob/main/src/image/image.ts"
click node_enhance "https://github.com/leitrim/humanface/blob/main/src/image/enhance.ts"
click node_webcam "https://github.com/leitrim/humanface/blob/main/src/util/webcam.ts"
click node_env "https://github.com/leitrim/humanface/blob/main/src/util/env.ts"
click node_backend "https://github.com/leitrim/humanface/blob/main/src/tfjs/backend.ts"
click node_model_load "https://github.com/leitrim/humanface/blob/main/src/tfjs/load.ts"
click node_models "https://github.com/leitrim/humanface/blob/main/src/models.ts"
click node_face "https://github.com/leitrim/humanface/blob/main/src/face/face.ts"
click node_facemesh "https://github.com/leitrim/humanface/blob/main/src/face/facemesh.ts"
click node_face_coords "https://github.com/leitrim/humanface/blob/main/src/face/facemeshcoords.ts"
click node_body "https://github.com/leitrim/humanface/blob/main/src/body/blazepose.ts"
click node_hand "https://github.com/leitrim/humanface/blob/main/src/hand/handposepipeline.ts"
click node_fingerpose "https://github.com/leitrim/humanface/blob/main/src/hand/fingerpose.ts"
click node_gesture "https://github.com/leitrim/humanface/blob/main/src/gesture/gesture.ts"
click node_object "https://github.com/leitrim/humanface/blob/main/src/object/centernet.ts"
click node_segmentation "https://github.com/leitrim/humanface/blob/main/src/segmentation/rvm.ts"
click node_result "https://github.com/leitrim/humanface/blob/main/src/result.ts"
click node_draw_options "https://github.com/leitrim/humanface/blob/main/src/draw/options.ts"
click node_draw "https://github.com/leitrim/humanface/blob/main/src/draw/draw.ts"

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_human,node_config,node_public toneBlue
class node_image,node_enhance,node_webcam,node_env,node_backend,node_model_load,node_models toneAmber
class node_face,node_facemesh,node_face_coords,node_body,node_hand,node_fingerpose,node_gesture,node_object,node_segmentation toneMint
class node_result,node_draw_options,node_draw toneRose
class node_caller,node_tfjs toneIndigo
```

## Components

### API and orchestration

- [Human API](https://github.com/leitrim/humanface/blob/main/src/human.ts): `src/human.ts`
- [Configuration](https://github.com/leitrim/humanface/blob/main/src/config.ts): `src/config.ts`
- [Public exports](https://github.com/leitrim/humanface/blob/main/src/exports.ts): `src/exports.ts`

### Input and runtime

- [Image processing](https://github.com/leitrim/humanface/blob/main/src/image/image.ts): `src/image/image.ts`
- [Image enhancement](https://github.com/leitrim/humanface/blob/main/src/image/enhance.ts): `src/image/enhance.ts`
- [Webcam handling](https://github.com/leitrim/humanface/blob/main/src/util/webcam.ts): `src/util/webcam.ts`
- [Environment detection](https://github.com/leitrim/humanface/blob/main/src/util/env.ts): `src/util/env.ts`
- [TensorFlow backends](https://github.com/leitrim/humanface/blob/main/src/tfjs/backend.ts): `src/tfjs/backend.ts`
- [Model loading](https://github.com/leitrim/humanface/blob/main/src/tfjs/load.ts): `src/tfjs/load.ts`
- [Model registry](https://github.com/leitrim/humanface/blob/main/src/models.ts): `src/models.ts`

### Vision models

- [Face analysis](https://github.com/leitrim/humanface/blob/main/src/face/face.ts): `src/face/face.ts`
- [Face mesh](https://github.com/leitrim/humanface/blob/main/src/face/facemesh.ts): `src/face/facemesh.ts`
- [Face mesh coordinates](https://github.com/leitrim/humanface/blob/main/src/face/facemeshcoords.ts): `src/face/facemeshcoords.ts`
- [Body pose](https://github.com/leitrim/humanface/blob/main/src/body/blazepose.ts): `src/body/blazepose.ts`
- [Hand tracking](https://github.com/leitrim/humanface/blob/main/src/hand/handposepipeline.ts): `src/hand/handposepipeline.ts`
- [Finger gestures](https://github.com/leitrim/humanface/blob/main/src/hand/fingerpose.ts): `src/hand/fingerpose.ts`
- [Gesture analysis](https://github.com/leitrim/humanface/blob/main/src/gesture/gesture.ts): `src/gesture/gesture.ts`
- [Object detection](https://github.com/leitrim/humanface/blob/main/src/object/centernet.ts): `src/object/centernet.ts`
- [Body segmentation](https://github.com/leitrim/humanface/blob/main/src/segmentation/rvm.ts): `src/segmentation/rvm.ts`

### Results and presentation

- [Detection results](https://github.com/leitrim/humanface/blob/main/src/result.ts): `src/result.ts`
- [Drawing options](https://github.com/leitrim/humanface/blob/main/src/draw/options.ts): `src/draw/options.ts`
- [Result drawing](https://github.com/leitrim/humanface/blob/main/src/draw/draw.ts): `src/draw/draw.ts`

### Other components

- **Application caller**
- **TensorFlow.js**

## Connections

- Application caller → Human API: submits input (evidence: `README.md`)
- Human API → Configuration: uses options (evidence: `src/human.ts`)
- Human API → Image processing: processes input (evidence: `src/human.ts`)
- Image processing → Image enhancement: applies enhancement (evidence: `src/image/image.ts`)
- Human API → TensorFlow backends: checks backend (evidence: `src/human.ts`)
- TensorFlow backends → Environment detection: checks capabilities (evidence: `src/tfjs/backend.ts`)
- TensorFlow backends → TensorFlow.js: configures runtime (evidence: `src/tfjs/backend.ts`)
- Human API → Model loading: loads models (evidence: `src/human.ts`)
- Model loading → TensorFlow.js: loads graph models (evidence: `src/tfjs/load.ts`)
- Model loading → Model registry: uses model definitions (evidence: `src/tfjs/load.ts`)
- Human API → Face analysis: runs face analysis (evidence: `src/human.ts`)
- Face analysis → Face mesh: runs face mesh (evidence: `src/face/face.ts`)
- Face mesh → Face mesh coordinates: uses coordinates (evidence: `src/face/facemesh.ts`)
- Human API → Body pose: runs pose model (evidence: `src/human.ts`)
- Human API → Hand tracking: runs hand tracking (evidence: `src/human.ts`)
- Hand tracking → Finger gestures: estimates finger pose (evidence: `src/hand/handposepipeline.ts`)
- Human API → Object detection: runs object detection (evidence: `src/human.ts`)
- Human API → Body segmentation: runs segmentation (evidence: `src/human.ts`)
- Human API → Gesture analysis: analyzes gestures (evidence: `src/human.ts`)
- Gesture analysis → Finger gestures: classifies fingers (evidence: `src/gesture/gesture.ts`)
- Human API → Detection results: returns detections (evidence: `src/human.ts`)
- Human API → Result drawing: draws results (evidence: `src/human.ts`)
- Result drawing → Drawing options: uses options
- Human API → Webcam handling: supports webcam input (evidence: `README.md`)
- Human API → Public exports: exposes API types (evidence: `src/human.ts`)
