# yogender-ai/fun-particle-feedback architecture

> Architecture diagram of the GitHub repository yogender-ai/fun-particle-feedback, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-08-24). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/yogender-ai/fun-particle-feedback
- Repository: https://github.com/yogender-ai/fun-particle-feedback

## Overview

#### Purpose
Quantum Flux is documented as a browser-based interactive particle-art experience: webcam hand gestures and optional audio drive a high-particle-count gravity simulation and WebGL visuals. The deployed target is Cloudflare Pages at `particle-gravity-fun.pages.dev`.

#### Repository Reality and Entry Points
The supplied tree contains only `README.md`; no executable source, package manifest, Rust crate, assets, or Cloudflare configuration are present to validate the documented build or runtime entry points. `README.md` documents intended commands (`wasm-pack build`, `npm run dev`) and identifies a planned JavaScript entry point, but that path is absent from the supplied repository view.

Grounding: `README.md`.

#### Browser Input and Interaction Stage
The documented client flow begins with webcam capture, passed to MediaPipe Hands. The AI layer produces 21 landmarks per hand; gesture recognition maps landmarks to particle modes and effects such as swarm, supernova, beam/fire, and battle. Webcam permission and MediaPipe model execution are key browser/external-service boundaries.

Documented intended paths: `src/tracking/mediapipe.js`, `src/tracking/gestures.js` (not present in supplied tree).

#### Physics / WASM Core
A Rust core compiled to WebAssembly is intended to own particle state and per-frame simulation. Its stated stages are spatial-hash neighbor lookup, N-body gravity force calculation, and Verlet integration. Hand landmark coordinates enter this boundary as gravity-well/control inputs; updated particle positions leave it for rendering. This is the primary performance boundary behind the claimed 8,192-particle target.

Documented intended paths: `src-rust/lib.rs`, `src-rust/physics/solver.rs`, `src-rust/physics/verlet.rs` (not present).

#### Particle Modes and Morphing
The physics layer is documented to support shape/mode initialization or targets, including heart, Saturn, flower, fireworks, battle, survival, and audio-reactive behavior. Morph implementations are conceptually separate from the generic particle lifecycle and solver.

Documented intended paths: `src-rust/particle.rs`, `src-rust/morphs/heart.rs`, `src-rust/morphs/saturn.rs` (not present).

#### Rendering and Audio Pipeline
Three.js is intended to create the scene and consume particle positions from WASM. Custom WebGL vertex and fragment shaders draw particle geometry, glow, and color. An FFT audio analyzer can feed music features into particle behavior. The frame loop coordinates tracking updates, simulation, and GPU rendering.

Documented intended paths: `src/main.js`, `src/scene.js`, `src/shaders/particle.vert` (not present).

#### UI, Deployment, and External Dependencies
A browser HUD and controls layer is documented to expose mode selection and runtime stats. Material runtimes/services are JavaScript in the browser, Rust/WASM, Three.js/WebGL 2.0, MediaPipe Hands, browser webcam/audio APIs, and Cloudflare Pages hosting. The documented Cloudflare configuration file is absent from the supplied tree.

Documented intended paths: `src/ui/hud.js`, `src/ui/controls.js`, `wrangler.toml` (not present).

Main entry points: [`README.md`](https://github.com/yogender-ai/fun-particle-feedback/blob/main/README.md) (Documented architecture)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_browser["Browser Runtime"]
  node_frame_loop["Frame loop<br/>JavaScript entry"]
  node_webcam_audio["Webcam and audio APIs<br/>browser APIs"]
  node_mediapipe["MediaPipe Hands<br/>external ML runtime"]
  node_gestures["Gesture mapping<br/>interaction layer"]
  node_audio_fft["FFT analyzer<br/>audio processing"]
  node_hud_controls["HUD and controls<br/>UI layer"]
  node_three_scene["Three.js scene<br/>WebGL renderer"]
  node_particle_shader["Particle shaders<br/>WebGL shader"]
end

subgraph group_wasm["Rust / WASM Core"]
  node_wasm_bridge{{"WASM simulation boundary<br/>Rust/WASM API"}}
  node_particle_modes["Particle modes and morphs<br/>particle lifecycle"]
  node_spatial_hash["Spatial-hash lookup<br/>physics stage"]
  node_gravity_solver["N-body gravity<br/>physics stage"]
  node_verlet["Verlet integration<br/>physics stage"]
end

node_readme["Documented architecture<br/>README<br/>[README.md]"]
node_cloudflare{{"Cloudflare Pages<br/>hosting"}}

node_readme -.->|"documents"| node_frame_loop
node_readme -.->|"documents"| node_wasm_bridge
node_readme -.->|"documents deployment"| node_cloudflare
node_cloudflare -.->|"serves"| node_frame_loop
node_webcam_audio -->|"camera frames"| node_mediapipe
node_mediapipe -->|"hand landmarks"| node_gestures
node_gestures -->|"mode and hand controls"| node_wasm_bridge
node_webcam_audio -->|"audio stream"| node_audio_fft
node_audio_fft -->|"music features"| node_wasm_bridge
node_hud_controls -->|"user selections"| node_frame_loop
node_frame_loop -->|"updates"| node_mediapipe
node_frame_loop -->|"steps simulation"| node_wasm_bridge
node_wasm_bridge -->|"selects targets"| node_particle_modes
node_wasm_bridge -->|"particle state"| node_spatial_hash
node_spatial_hash -->|"neighbors"| node_gravity_solver
node_gravity_solver -->|"forces"| node_verlet
node_verlet -->|"updated positions"| node_wasm_bridge
node_wasm_bridge -->|"particle positions"| node_three_scene
node_frame_loop -->|"renders frame"| node_three_scene
node_three_scene -->|"draw calls"| node_particle_shader

click node_readme "https://github.com/yogender-ai/fun-particle-feedback/blob/main/README.md"

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_frame_loop,node_webcam_audio,node_mediapipe,node_gestures,node_audio_fft,node_hud_controls,node_three_scene,node_particle_shader toneBlue
class node_wasm_bridge,node_particle_modes,node_spatial_hash,node_gravity_solver,node_verlet toneAmber
class node_readme,node_cloudflare toneNeutral
```

## Components

### Browser Runtime

- **Frame loop**: JavaScript entry · Coordinates tracking, simulation, and rendering each frame.
- **Webcam and audio APIs**: browser APIs · Permission-gated camera capture and optional audio input.
- **MediaPipe Hands**: external ML runtime · Produces 21 landmarks per hand from webcam frames.
- **Gesture mapping**: interaction layer · Maps landmarks to modes and effects.
- **FFT analyzer**: audio processing · Extracts music features for audio-reactive behavior.
- **HUD and controls**: UI layer · Exposes mode selection and runtime statistics.
- **Three.js scene**: WebGL renderer · Consumes WASM positions and submits particle rendering.
- **Particle shaders**: WebGL shader · Draws particle geometry, glow, and color.

### Rust / WASM Core

- **WASM simulation boundary**: Rust/WASM API · Owns particle state and exchanges controls and positions with JavaScript.
- **Particle modes and morphs**: particle lifecycle · Initializes or targets heart, Saturn, battle, survival, and other modes.
- **Spatial-hash lookup**: physics stage · Finds neighboring particles efficiently.
- **N-body gravity**: physics stage · Calculates particle forces and hand gravity wells.
- **Verlet integration**: physics stage · Updates particle positions per frame.

### Other components

- [Documented architecture](https://github.com/yogender-ai/fun-particle-feedback/blob/main/README.md): README · The only supplied repository file; all runtime components are documented, not present. · `README.md`
- **Cloudflare Pages**: hosting · Intended deployed host; configuration is absent.

## Connections

- Documented architecture → Frame loop: documents
- Documented architecture → WASM simulation boundary: documents
- Documented architecture → Cloudflare Pages: documents deployment
- Cloudflare Pages → Frame loop: serves
- Webcam and audio APIs → MediaPipe Hands: camera frames
- MediaPipe Hands → Gesture mapping: hand landmarks
- Gesture mapping → WASM simulation boundary: mode and hand controls
- Webcam and audio APIs → FFT analyzer: audio stream
- FFT analyzer → WASM simulation boundary: music features
- HUD and controls → Frame loop: user selections
- Frame loop → MediaPipe Hands: updates
- Frame loop → WASM simulation boundary: steps simulation
- WASM simulation boundary → Particle modes and morphs: selects targets
- WASM simulation boundary → Spatial-hash lookup: particle state
- Spatial-hash lookup → N-body gravity: neighbors
- N-body gravity → Verlet integration: forces
- Verlet integration → WASM simulation boundary: updated positions
- WASM simulation boundary → Three.js scene: particle positions
- Frame loop → Three.js scene: renders frame
- Three.js scene → Particle shaders: draw calls
