# sjxchng/drumvoice architecture

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

- Interactive diagram: https://gitdiagram.com/sjxchng/drumvoice
- Repository: https://github.com/sjxchng/drumvoice

## Overview

DrumVoice accepts spoken drummer commands and returns structured intents for a metronome or sheet-music viewer. The documented workflow runs from the browser’s voice interface through the Express command endpoint, which tries the configured Gemini provider and falls back to deterministic parsing on failure. The README also describes metronome controls, page navigation and scheduled turns; their client-side implementation is in public/index.html, which is listed in the tree but was not sampled. Edges reflect the shown server calls and documented browser workflow.

Main entry points: [`src/routes/commands.js`](https://github.com/sjxchng/drumvoice/blob/main/src/routes/commands.js) (Command API), [`public/index.html`](https://github.com/sjxchng/drumvoice/blob/main/public/index.html) (Voice and sheet UI), [`src/app.js`](https://github.com/sjxchng/drumvoice/blob/main/src/app.js) (HTTP app), [`src/parser/PatternProcessor.js`](https://github.com/sjxchng/drumvoice/blob/main/src/parser/PatternProcessor.js) (Regex fallback)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Web runtime"]
  node_server["Server entry<br/>[server.js]"]
  node_express["HTTP app<br/>[app.js]"]
end

subgraph group_command["Command parsing"]
  node_routes["Command API<br/>[commands.js]"]
  node_regex["Regex fallback"]
  node_normalizer["Text and numbers<br/>[normalizer.js]"]
end

subgraph group_provider["AI providers"]
  node_ai["AI provider contract<br/>[base.js]"]
  node_factory["Provider selection<br/>[index.js]"]
  node_gemini["Gemini parser<br/>[gemini.js]"]
end

subgraph group_client["Drummer interface"]
  node_web["Voice and sheet UI<br/>[index.html]"]
  node_metronome["Metronome controls<br/>[index.html]"]
  node_sheets["Sheet music viewer<br/>[index.html]"]
end

node_drummer(("Drummer"))

node_drummer -->|"speaks commands"| node_web
node_web -->|"submits commands"| node_routes
node_server -->|"starts"| node_express
node_express -->|"mounts API"| node_routes
node_routes -->|"calls provider"| node_factory
node_routes -->|"falls back"| node_regex
node_factory -->|"creates"| node_gemini
node_gemini -->|"extends"| node_ai
node_regex -->|"uses utilities"| node_normalizer
node_routes -->|"serves interface"| node_web
node_web -->|"controls"| node_metronome
node_web -->|"navigates"| node_sheets

click node_server "https://github.com/sjxchng/drumvoice/blob/main/server.js"
click node_express "https://github.com/sjxchng/drumvoice/blob/main/src/app.js"
click node_routes "https://github.com/sjxchng/drumvoice/blob/main/src/routes/commands.js"
click node_ai "https://github.com/sjxchng/drumvoice/blob/main/src/providers/base.js"
click node_factory "https://github.com/sjxchng/drumvoice/blob/main/src/providers/index.js"
click node_gemini "https://github.com/sjxchng/drumvoice/blob/main/src/providers/gemini.js"
click node_regex "https://github.com/sjxchng/drumvoice/blob/main/src/parser/PatternProcessor.js"
click node_normalizer "https://github.com/sjxchng/drumvoice/blob/main/src/parser/normalizer.js"
click node_web "https://github.com/sjxchng/drumvoice/blob/main/public/index.html"
click node_metronome "https://github.com/sjxchng/drumvoice/blob/main/public/index.html"
click node_sheets "https://github.com/sjxchng/drumvoice/blob/main/public/index.html"

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_server,node_express toneBlue
class node_routes,node_regex,node_normalizer toneAmber
class node_ai,node_factory,node_gemini toneMint
class node_web,node_metronome,node_sheets toneRose
class node_drummer toneIndigo
```

## Components

### Web runtime

- [Server entry](https://github.com/sjxchng/drumvoice/blob/main/server.js): `server.js`
- [HTTP app](https://github.com/sjxchng/drumvoice/blob/main/src/app.js): `src/app.js`

### Command parsing

- [Command API](https://github.com/sjxchng/drumvoice/blob/main/src/routes/commands.js): `src/routes/commands.js`
- [Regex fallback](https://github.com/sjxchng/drumvoice/blob/main/src/parser/PatternProcessor.js): `src/parser/PatternProcessor.js`
- [Text and numbers](https://github.com/sjxchng/drumvoice/blob/main/src/parser/normalizer.js): `src/parser/normalizer.js`

### AI providers

- [AI provider contract](https://github.com/sjxchng/drumvoice/blob/main/src/providers/base.js): `src/providers/base.js`
- [Provider selection](https://github.com/sjxchng/drumvoice/blob/main/src/providers/index.js): `src/providers/index.js`
- [Gemini parser](https://github.com/sjxchng/drumvoice/blob/main/src/providers/gemini.js): `src/providers/gemini.js`

### Drummer interface

- [Voice and sheet UI](https://github.com/sjxchng/drumvoice/blob/main/public/index.html): `public/index.html`
- [Metronome controls](https://github.com/sjxchng/drumvoice/blob/main/public/index.html): `public/index.html`
- [Sheet music viewer](https://github.com/sjxchng/drumvoice/blob/main/public/index.html): `public/index.html`

### Other components

- **Drummer**

## Connections

- Drummer → Voice and sheet UI: speaks commands (evidence: `README.md`)
- Voice and sheet UI → Command API: submits commands (evidence: `README.md`)
- Server entry → HTTP app: starts (evidence: `server.js`)
- HTTP app → Command API: mounts API (evidence: `src/app.js`)
- Command API → Provider selection: calls provider (evidence: `src/routes/commands.js`)
- Command API → Regex fallback: falls back (evidence: `src/routes/commands.js`)
- Provider selection → Gemini parser: creates (evidence: `src/providers/index.js`)
- Gemini parser → AI provider contract: extends (evidence: `src/providers/gemini.js`)
- Regex fallback → Text and numbers: uses utilities (evidence: `src/parser/PatternProcessor.js`)
- Command API → Voice and sheet UI: serves interface
- Voice and sheet UI → Metronome controls: controls (evidence: `README.md`)
- Voice and sheet UI → Sheet music viewer: navigates (evidence: `README.md`)
