# harrythentrepreneur/omni architecture

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

- Interactive diagram: https://gitdiagram.com/harrythentrepreneur/omni
- Repository: https://github.com/harrythentrepreneur/omni

## Overview

#### Purpose and entry points
Omni is a camera-based “animated objects” system with two products: the browser Tracker at `/`, and a webcam-to-image Mirror at `/mirror`. The Next.js App Router shell begins in `app/layout.tsx`; main route selection is in `app/page.tsx`, `app/mirror/page.tsx`, and the newer Tracker variant in `app/v2/page.tsx`. Landing and gallery are separate presentation routes.

#### Tracker client and vision loop
`components/tracker.tsx` is the primary orchestration component: it captures camera frames, renders detections, accepts object taps, manages up to three active characters, and coordinates generation and speech. `components/tracker-v2.tsx` is a parallel implementation. Browser-local inference is encapsulated by `lib/yolo.ts` (with WebSocket-oriented alternative `lib/yolo-ws.ts`) and shipped ONNX assets in `public/models/yolo26n-seg.onnx` and `public/models/yolo26n.onnx`.

The critical boundary is client-side vision: raw camera imagery and continuous detection stay in the browser through ONNX Runtime Web (WebGPU/WASM), avoiding backend calls in the tracking loop.

#### Object identity, placement, and character rendering
Detection association and visual stability are handled through IoU, EMA smoothing, and anchor calculations in `lib/iou.ts`, consumed by the tracker. A selected detection becomes a persistent character/session record, supported by `lib/session-cards.ts`. `components/face-voice.tsx` renders the attached eyes/mouth animation; `components/speech-bubble.tsx` presents dialogue. Visual media is local under `public/facevoice/`.

An assessment service determines whether/where a face should be placed, creating a deliberate boundary between geometric local tracking and semantic placement judgment: `app/api/assess/route.ts`, `app/api/describe/route.ts`.

#### Character-generation and conversation services
The client invokes Next server endpoints/actions for object semantics and language. Initial object description/persona/opening-line generation flows through `app/actions.ts` and APIs including `app/api/generate-line/route.ts` and `app/api/describe/route.ts`. Subsequent conversational turns are served by `app/api/converse/route.ts`.

OpenAI provides vision/persona generation and fallback capabilities; Cerebras serves low-latency text conversations; Zhipu GLM handles visual placement/assessment. These keys remain server-side via environment configuration, while browser code receives only generated character data and responses.

#### Speech pipeline
Speech input is handled by `app/api/speak/route.ts`, with transcription-related logic in `lib/whisper.ts`. Text-to-speech has a streaming path at `app/api/tts/stream/route.ts`, supported by `lib/tts.ts`, plus `app/api/tts/stream/route.ts` for browser playback-oriented chunking. Fish.audio is the primary voice service, with OpenAI TTS fallback; character voice selection is tied to persona/session data. Bundled sample voices live in `public/voices/`.

#### Mirror subsystem
Mirror is an optional, separately deployed runtime: React UI in `components/mirror.tsx` and route `app/mirror/page.tsx`; Python FastAPI/WebSocket image processing in `server/main.py`, `server/app.py`, and `server/yolo_ws.py`. It receives webcam data, uses OpenCV and dlib facial landmarks, and composites eyes/mouth onto a selected base image. Its Python dependencies and model assets are operationally distinct from the Next.js tracker.

#### Mobile and alternate backends
`react-native-executorch/` is a related Expo/React Native implementation, with its app entry at `react-native-executorch/app/index.tsx`, native detector abstraction in `react-native-executorch/lib/detector.ts`, and optional Python server under `react-native-executorch/server/`. `server-v2/server.py` is another standalone server variant. These are separate execution targets, not required for the browser Tracker.

Main entry points: [`components/tracker.tsx`](https://github.com/harrythentrepreneur/omni/blob/main/components/tracker.tsx) (Tracker orchestrator), [`app/layout.tsx`](https://github.com/harrythentrepreneur/omni/blob/main/app/layout.tsx) (App shell & routes), [`lib/yolo.ts`](https://github.com/harrythentrepreneur/omni/blob/main/lib/yolo.ts) (Local object detection), [`components/tracker-v2.tsx`](https://github.com/harrythentrepreneur/omni/blob/main/components/tracker-v2.tsx) (Tracker v2)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Browser Tracker"]
  node_app_shell["App shell &amp; routes<br/>Next.js App Router<br/>[layout.tsx]"]
  node_tracker["Tracker orchestrator<br/>React client<br/>[tracker.tsx]"]
  node_tracker_v2["Tracker v2<br/>React client<br/>[tracker-v2.tsx]"]
  node_local_vision{{"Local object detection<br/>ONNX Runtime Web<br/>[yolo.ts]"}}
  node_onnx_models["YOLO model assets<br/>ONNX assets<br/>[yolo26n-seg.onnx]"]
  node_tracking_geometry["Detection stability<br/>IoU / EMA tracking<br/>[iou.ts]"]
  node_character_sessions["Character sessions<br/>session state<br/>[session-cards.ts]"]
  node_face_voice["Face and voice overlay<br/>React renderer<br/>[face-voice.tsx]"]
  node_dialogue_ui["Speech bubbles<br/>React UI<br/>[speech-bubble.tsx]"]
end

subgraph group_server["Next Server"]
  node_generation["Character generation<br/>server actions / API<br/>[actions.ts]"]
  node_assessment["Placement assessment<br/>API route<br/>[route.ts]"]
  node_conversation["Conversation service<br/>API route<br/>[route.ts]"]
  node_speech_input["Speech transcription<br/>API route<br/>[route.ts]"]
  node_speech_output["Streaming TTS<br/>API route<br/>[route.ts]"]
  node_ai_providers{{"AI providers"}}
  node_voice_provider{{"Voice providers<br/>Fish.audio / OpenAI TTS"}}
end

subgraph group_mirror["Mirror Runtime"]
  node_mirror_ui["Mirror UI<br/>React client<br/>[mirror.tsx]"]
  node_mirror_processor{{"Mirror processor<br/>FastAPI / WebSocket<br/>[main.py]"}}
end

subgraph group_mobile["Mobile Variant"]
  node_mobile_app["Expo mobile app<br/>React Native entry<br/>[index.tsx]"]
  node_mobile_detector["Native detector<br/>detector abstraction<br/>[detector.ts]"]
end

node_app_shell -->|"/"| node_tracker
node_app_shell -->|"/v2"| node_tracker_v2
node_app_shell -->|"/mirror"| node_mirror_ui
node_tracker -->|"camera frames"| node_local_vision
node_tracker_v2 -->|"camera frames"| node_local_vision
node_local_vision -->|"loads"| node_onnx_models
node_tracker -->|"detections"| node_tracking_geometry
node_tracking_geometry -->|"selected object"| node_character_sessions
node_character_sessions -->|"anchor and persona"| node_face_voice
node_tracker -->|"dialogue"| node_dialogue_ui
node_tracker -->|"object semantics"| node_generation
node_tracker -->|"placement request"| node_assessment
node_tracker -->|"conversation turn"| node_conversation
node_tracker -->|"recorded speech"| node_speech_input
node_tracker -->|"speak response"| node_speech_output
node_generation -->|"vision and persona"| node_ai_providers
node_assessment -->|"visual assessment"| node_ai_providers
node_conversation -->|"low-latency text"| node_ai_providers
node_speech_output -->|"voice synthesis"| node_voice_provider
node_mirror_ui -->|"webcam WebSocket"| node_mirror_processor
node_mobile_app -->|"camera inference"| node_mobile_detector

click node_app_shell "https://github.com/harrythentrepreneur/omni/blob/main/app/layout.tsx"
click node_tracker "https://github.com/harrythentrepreneur/omni/blob/main/components/tracker.tsx"
click node_tracker_v2 "https://github.com/harrythentrepreneur/omni/blob/main/components/tracker-v2.tsx"
click node_local_vision "https://github.com/harrythentrepreneur/omni/blob/main/lib/yolo.ts"
click node_onnx_models "https://github.com/harrythentrepreneur/omni/blob/main/public/models/yolo26n-seg.onnx"
click node_tracking_geometry "https://github.com/harrythentrepreneur/omni/blob/main/lib/iou.ts"
click node_character_sessions "https://github.com/harrythentrepreneur/omni/blob/main/lib/session-cards.ts"
click node_face_voice "https://github.com/harrythentrepreneur/omni/blob/main/components/face-voice.tsx"
click node_dialogue_ui "https://github.com/harrythentrepreneur/omni/blob/main/components/speech-bubble.tsx"
click node_generation "https://github.com/harrythentrepreneur/omni/blob/main/app/actions.ts"
click node_assessment "https://github.com/harrythentrepreneur/omni/blob/main/app/api/assess/route.ts"
click node_conversation "https://github.com/harrythentrepreneur/omni/blob/main/app/api/converse/route.ts"
click node_speech_input "https://github.com/harrythentrepreneur/omni/blob/main/app/api/speak/route.ts"
click node_speech_output "https://github.com/harrythentrepreneur/omni/blob/main/app/api/tts/stream/route.ts"
click node_mirror_ui "https://github.com/harrythentrepreneur/omni/blob/main/components/mirror.tsx"
click node_mirror_processor "https://github.com/harrythentrepreneur/omni/blob/main/server/main.py"
click node_mobile_app "https://github.com/harrythentrepreneur/omni/blob/main/react-native-executorch/app/index.tsx"
click node_mobile_detector "https://github.com/harrythentrepreneur/omni/blob/main/react-native-executorch/lib/detector.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_app_shell,node_tracker,node_tracker_v2,node_local_vision,node_onnx_models,node_tracking_geometry,node_character_sessions,node_face_voice,node_dialogue_ui toneBlue
class node_generation,node_assessment,node_conversation,node_speech_input,node_speech_output,node_ai_providers,node_voice_provider toneAmber
class node_mirror_ui,node_mirror_processor toneMint
class node_mobile_app,node_mobile_detector toneRose
```

## Components

### Browser Tracker

Next.js client routes and browser-local vision.

- [App shell & routes](https://github.com/harrythentrepreneur/omni/blob/main/app/layout.tsx): Next.js App Router · Hosts Tracker, Mirror, and v2 routes. · `app/layout.tsx`
- [Tracker orchestrator](https://github.com/harrythentrepreneur/omni/blob/main/components/tracker.tsx): React client · Captures frames, manages characters, and coordinates generation and speech. · `components/tracker.tsx`
- [Tracker v2](https://github.com/harrythentrepreneur/omni/blob/main/components/tracker-v2.tsx): React client · Parallel tracker implementation. · `components/tracker-v2.tsx`
- [Local object detection](https://github.com/harrythentrepreneur/omni/blob/main/lib/yolo.ts): ONNX Runtime Web · Runs WebGPU/WASM inference entirely in the browser. · `lib/yolo.ts`
- [YOLO model assets](https://github.com/harrythentrepreneur/omni/blob/main/public/models/yolo26n-seg.onnx): ONNX assets · `public/models/yolo26n-seg.onnx`
- [Detection stability](https://github.com/harrythentrepreneur/omni/blob/main/lib/iou.ts): IoU / EMA tracking · Associates detections and computes stable anchors. · `lib/iou.ts`
- [Character sessions](https://github.com/harrythentrepreneur/omni/blob/main/lib/session-cards.ts): session state · Persists selected object character records. · `lib/session-cards.ts`
- [Face and voice overlay](https://github.com/harrythentrepreneur/omni/blob/main/components/face-voice.tsx): React renderer · Attaches animated eyes and mouth to tracked objects. · `components/face-voice.tsx`
- [Speech bubbles](https://github.com/harrythentrepreneur/omni/blob/main/components/speech-bubble.tsx): React UI · `components/speech-bubble.tsx`

### Next Server

Server-side AI, assessment, and speech endpoints.

- [Character generation](https://github.com/harrythentrepreneur/omni/blob/main/app/actions.ts): server actions / API · Creates object descriptions, personas, and opening lines. · `app/actions.ts`
- [Placement assessment](https://github.com/harrythentrepreneur/omni/blob/main/app/api/assess/route.ts): API route · Makes semantic face-placement judgments. · `app/api/assess/route.ts`
- [Conversation service](https://github.com/harrythentrepreneur/omni/blob/main/app/api/converse/route.ts): API route · Serves subsequent character dialogue turns. · `app/api/converse/route.ts`
- [Speech transcription](https://github.com/harrythentrepreneur/omni/blob/main/app/api/speak/route.ts): API route · Accepts speech input for transcription. · `app/api/speak/route.ts`
- [Streaming TTS](https://github.com/harrythentrepreneur/omni/blob/main/app/api/tts/stream/route.ts): API route · Streams character speech for browser playback. · `app/api/tts/stream/route.ts`
- **AI providers**: OpenAI · Cerebras · Zhipu · Server-held providers for vision, conversation, and placement.
- **Voice providers**: Fish.audio / OpenAI TTS · Primary voice synthesis with fallback.

### Mirror Runtime

Separately deployed webcam image-processing service.

- [Mirror UI](https://github.com/harrythentrepreneur/omni/blob/main/components/mirror.tsx): React client · Sends webcam imagery to the optional Mirror runtime. · `components/mirror.tsx`
- [Mirror processor](https://github.com/harrythentrepreneur/omni/blob/main/server/main.py): FastAPI / WebSocket · Uses OpenCV and dlib landmarks to composite facial features. · `server/main.py`

### Mobile Variant

Independent Expo/React Native execution target.

- [Expo mobile app](https://github.com/harrythentrepreneur/omni/blob/main/react-native-executorch/app/index.tsx): React Native entry · Independent mobile implementation. · `react-native-executorch/app/index.tsx`
- [Native detector](https://github.com/harrythentrepreneur/omni/blob/main/react-native-executorch/lib/detector.ts): detector abstraction · `react-native-executorch/lib/detector.ts`

## Connections

- App shell & routes → Tracker orchestrator: /
- App shell & routes → Tracker v2: /v2
- App shell & routes → Mirror UI: /mirror
- Tracker orchestrator → Local object detection: camera frames
- Tracker v2 → Local object detection: camera frames
- Local object detection → YOLO model assets: loads
- Tracker orchestrator → Detection stability: detections
- Detection stability → Character sessions: selected object
- Character sessions → Face and voice overlay: anchor and persona
- Tracker orchestrator → Speech bubbles: dialogue
- Tracker orchestrator → Character generation: object semantics
- Tracker orchestrator → Placement assessment: placement request
- Tracker orchestrator → Conversation service: conversation turn
- Tracker orchestrator → Speech transcription: recorded speech
- Tracker orchestrator → Streaming TTS: speak response
- Character generation → AI providers: vision and persona
- Placement assessment → AI providers: visual assessment
- Conversation service → AI providers: low-latency text
- Streaming TTS → Voice providers: voice synthesis
- Mirror UI → Mirror processor: webcam WebSocket
- Expo mobile app → Native detector: camera inference
