# skinnygiraffe1235/quattro-formaggi architecture

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

- Interactive diagram: https://gitdiagram.com/skinnygiraffe1235/quattro-formaggi
- Repository: https://github.com/skinnygiraffe1235/quattro-formaggi

## Overview

1. **System shape**
   - Quattro Formaggi is a **local, real-time performance instrument** with three main boundaries: a **browser UI**, a **Node.js bridge/server**, and a **SuperCollider synthesis engine**. The browser is the control surface; SuperCollider is the audio generator.

2. **Browser presentation layer**
   - `index.html`, `style.css`, and `script.js` implement the interactive front end. This layer contains the **Mood Pad**, piano-roll style input, and performance controls for **instrument selection, octave changes, and reverb**.

3. **User input sources**
   - The browser accepts multiple performance inputs: **computer keyboard**, **on-screen piano/piano-roll interaction**, **mouse actions on the Mood Pad**, and **MIDI controller input**. These are all normalized in the JavaScript layer into musical events and parameter changes.

4. **Control-state layer in the browser**
   - `script.js` is likely the main orchestration point for UI state: current instrument, octave, patch/randomization state, mood coordinates, and reverb amount. The Mood Pad is not just visual feedback; it maps to **sound-shaping parameters** such as brightness, darkness, softness, and aggressiveness.

5. **Node.js bridge**
   - `server.js` is the integration boundary between the browser and the synthesis engine. It serves the app and handles **OSC-based communication** to SuperCollider. The README also lists **Socket.IO**, so the server likely supports live bidirectional browser-server messaging in addition to OSC transport.

6. **Audio engine boundary**
   - `string_engine.scd` is the SuperCollider synthesis layer. It implements the actual quartet sound model and is responsible for turning note and control messages into audio. This is the only layer that directly produces sound.

7. **Synthesis design**
   - The engine is based on **DWGBowed** and related bowed-string techniques, so the quartet is modeled as **physically inspired bowed strings** rather than sampled instruments. Each of the four voices has its own role: **Violin I, Violin II, Viola, and Cello**.

8. **Per-instrument processing**
   - The SuperCollider side adds instrument-specific shaping such as **resonance, bow noise, vibrato, stereo spreading, saturation, dynamic filtering, and reverb**. This suggests a modular preset structure where each quartet member has a tailored timbre rather than sharing one generic patch.

9. **Data flow**
   - The core path is: **user interaction in the browser → JavaScript event handling → Node.js/OSC message transport → SuperCollider synthesis parameters → audio output**. The reverse path is probably limited to state/status synchronization rather than audio data.

10. **Performance controls and routing**
   - The UI exposes several live-performance commands: **instrument switching, octave switching, random patch generation, and reverb adjustment**. These are part of the control plane, not separate subsystems, and they affect the current synth preset in real time.

11. **Runtime and deployment context**
   - This is not a typical web app deployed to a remote backend; it is a **desktop/local performance stack** that depends on a browser, Node.js, and a running SuperCollider environment on the same machine or local network.

12. **Repo organization**
   - The repo is intentionally small and split by responsibility: frontend assets, server bridge, and synthesis script. That separation is the main architectural clue for diagramming: **UI, transport, and sound engine are distinct nodes with OSC as the key integration protocol**.

Main entry points: [`script.js`](https://github.com/skinnygiraffe1235/quattro-formaggi/blob/main/script.js) (Controller), [`server.js`](https://github.com/skinnygiraffe1235/quattro-formaggi/blob/main/server.js) (Bridge Server), [`index.html`](https://github.com/skinnygiraffe1235/quattro-formaggi/blob/main/index.html) (UI Shell), [`string_engine.scd`](https://github.com/skinnygiraffe1235/quattro-formaggi/blob/main/string_engine.scd) (String Engine)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_browser["Browser UI"]
  node_index_html["UI Shell<br/>html entry<br/>[index.html]"]
  node_style_css["Visual Theme<br/>css layout<br/>[style.css]"]
  node_script_js["Controller<br/>ui orchestration<br/>[script.js]"]
  node_kb_input(("Keyboard<br/>input source"))
  node_mouse_input(("Mood Pad<br/>input source"))
  node_midi_input(("MIDI<br/>input source"))
end

subgraph group_bridge["Node Bridge"]
  node_server_js["Bridge Server<br/>node bridge<br/>[server.js]"]
  node_osc_bus["OSC Link<br/>transport"]
end

subgraph group_audio["Audio Engine"]
  node_sc_engine["String Engine<br/>supercollider synth<br/>[string_engine.scd]"]
  node_quartet_voices{{"Quartet Voices<br/>voice model"}}
  node_bowed_model{{"Bowed Model<br/>synthesis model"}}
end

subgraph group_project["Project Runtime"]
  node_package_json["Package Config<br/>node metadata<br/>[package.json]"]
end

node_index_html -->|"styles"| node_style_css
node_index_html -->|"loads"| node_script_js
node_kb_input -->|"events"| node_script_js
node_mouse_input -->|"events"| node_script_js
node_midi_input -->|"events"| node_script_js
node_script_js -->|"messages"| node_server_js
node_server_js -->|"publishes"| node_osc_bus
node_osc_bus -->|"controls"| node_sc_engine
node_sc_engine -->|"implements"| node_quartet_voices
node_quartet_voices -->|"driven by"| node_bowed_model
node_script_js -.->|"state sync"| node_osc_bus
node_package_json -->|"supports"| node_server_js

click node_index_html "https://github.com/skinnygiraffe1235/quattro-formaggi/blob/main/index.html"
click node_style_css "https://github.com/skinnygiraffe1235/quattro-formaggi/blob/main/style.css"
click node_script_js "https://github.com/skinnygiraffe1235/quattro-formaggi/blob/main/script.js"
click node_server_js "https://github.com/skinnygiraffe1235/quattro-formaggi/blob/main/server.js"
click node_sc_engine "https://github.com/skinnygiraffe1235/quattro-formaggi/blob/main/string_engine.scd"
click node_package_json "https://github.com/skinnygiraffe1235/quattro-formaggi/blob/main/package.json"

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_index_html,node_style_css,node_script_js,node_kb_input,node_mouse_input,node_midi_input toneBlue
class node_server_js,node_osc_bus toneAmber
class node_sc_engine,node_quartet_voices,node_bowed_model toneMint
class node_package_json toneRose
```

## Components

### Browser UI

Client-side performance surface and state orchestration.

- [UI Shell](https://github.com/skinnygiraffe1235/quattro-formaggi/blob/main/index.html): html entry · Browser entry point that hosts the performance interface. · `index.html`
- [Visual Theme](https://github.com/skinnygiraffe1235/quattro-formaggi/blob/main/style.css): css layout · Styling for the performance UI, controls, and pad surfaces. · `style.css`
- [Controller](https://github.com/skinnygiraffe1235/quattro-formaggi/blob/main/script.js): ui orchestration · Main browser logic for input handling, state, mood mapping, and live control changes. · `script.js`
- **Keyboard**: input source · Computer keyboard performance input normalized by the browser controller.
- **Mood Pad**: input source · Pointer-driven control surface for expressive mood and timbre shaping.
- **MIDI**: input source · External MIDI controller input mapped into notes and parameter changes.

### Node Bridge

Local server and transport layer between browser and synthesis engine.

- [Bridge Server](https://github.com/skinnygiraffe1235/quattro-formaggi/blob/main/server.js): node bridge · Local Node.js server that serves the app and mediates live communication to the synth engine. · `server.js`
- **OSC Link**: transport · Message channel used to send control and note events to SuperCollider.

### Audio Engine

SuperCollider synthesis and quartet sound generation.

- [String Engine](https://github.com/skinnygiraffe1235/quattro-formaggi/blob/main/string_engine.scd): supercollider synth · SuperCollider bowed-string quartet engine that turns control messages into audio. · `string_engine.scd`
- **Quartet Voices**: voice model · Violin I, Violin II, Viola, and Cello synthesis roles within the engine.
- **Bowed Model**: synthesis model · Physically inspired bowed-string synthesis based on DWGBowed-style techniques.

### Project Runtime

Repository-level runtime and launch metadata.

- [Package Config](https://github.com/skinnygiraffe1235/quattro-formaggi/blob/main/package.json): node metadata · Node.js dependency and startup metadata for the local bridge/runtime. · `package.json`

## Connections

- UI Shell → Visual Theme: styles · The UI shell is presented through the stylesheet.
- UI Shell → Controller: loads · The browser entry loads the main controller script.
- Keyboard → Controller: events · Keyboard gestures are normalized into musical actions.
- Mood Pad → Controller: events · Mood Pad gestures become timbre and expression changes.
- MIDI → Controller: events · MIDI messages are converted into notes and control changes.
- Controller → Bridge Server: messages · The browser controller sends live control data to the bridge.
- Bridge Server → OSC Link: publishes · The bridge formats events for OSC transport.
- OSC Link → String Engine: controls · OSC messages reach the SuperCollider synthesis layer.
- String Engine → Quartet Voices: implements · The engine instantiates the four instrument voices.
- Quartet Voices → Bowed Model: driven by · Each voice is built on bowed-string synthesis techniques.
- Controller → OSC Link: state sync · Live performance state is translated into engine-facing parameters.
- Package Config → Bridge Server: supports · Node runtime metadata supports the bridge/server process.
