How sebhernandezamoros/mimidi works
1. Overall shape
- MiMIDI is a mobile-first music lab built as a layered TypeScript/React app.
- The repository is organized by musical capability, not by UI framework: audio, MIDI, projects, plugins, transport, editing, performance, and sampling are the main boundaries.
2. Top-level application shell
- src/main.tsx, src/App.tsx, and src/app/* define the app bootstrap, routing, theme, navigation, and shell layout.
- AppShell, appRoutes, appNavigation, appTheme, and appI18n centralize cross-cutting concerns so individual feature screens stay focused.
3. Feature screens as presentation layer
- Most user-facing behavior lives under src/features/* as screens and workspace components: edit, perform, project, catalog, plugins, settings, sampler, lab, tutorial, MIDI event log, piano preview, timeline preview, transport, and SMC pad.
- These components are primarily orchestration and UI; they call into application use-cases and engine services rather than containing synthesis or persistence logic.
4. Application layer for coordination
- src/application/use-cases/* contains the action-oriented business workflows: note playback, arpeggiator playback, sequencer steps, sample import/export, recording mic input, project import/export, bundle/audio export, and file saving.
- This layer is the bridge between UI intent and engine capabilities, keeping feature components thin and making side effects explicit.
5. Audio engine boundary
- src/engine/audio/* is the core sound subsystem: synthesis models, instrument catalog, mathematical instruments, sample handling, offline rendering, and WAV encoding.
- The README’s constraint is reflected here: the core is synth-based, with samples treated as a separate model rather than the default sound source.
- audioEngine.ts and offlineAudioRenderer.ts are the main runtime/rendering services; wavEncoder.ts handles export formatting.
6. MIDI and timing model
- src/engine/midi/* holds musical event primitives and playback logic: notes, MIDI-style events, and arpeggiator behavior.
- These modules represent musical intent and sequencing, distinct from audio generation, which is important for features like recording, timeline playback, and step triggering.
7. Project and sample persistence
- src/engine/project/* and src/engine/audio/sampleStorage.ts / sampleModel.ts handle persistent project state and sample data.
- The README indicates local persistence via IndexedDB; the engine layer is where long-lived project/sample state is modeled and stored.
8. Plugin system as a major architectural boundary
- src/engine/plugins/* is a complete subsystem: plugin model, registry, loader, API, internal plugins, and external plugin storage.
- Plugins are first-class extensions, not ad hoc UI add-ons. The API exposes audio, project, transport, clip/session storage, and UI notifications to plugin workspaces.
- There are two plugin types reflected in the code and README: instrument packs and React workspaces.
9. Plugin runtime and hosting
- PluginWorkspaceHost and the plugins feature screens provide the runtime shell that mounts external plugin UIs inside the app.
- public/mimidi-plugin-sdk.d.ts is the typed boundary contract for plugin authors.
- public/demo-plugins/* contains source and built examples, and scripts/build-mimod.mjs / scripts/build-plugin.mjs create distributable .mimod archives.
10. Lab as the plugin-centered working area
- The features/lab area is the central workspace for plugin usage, instrument selection, playback, recording, and project control.
- It ties together lab project state, instrument catalog access, recording session state, playback, and plugin-driven actions.
11. Editor, perform, sampler, and timeline workflows
- features/edit and features/timeline focus on composing and arranging musical events.
- features/perform and features/piano support live playing and instrument interaction.
- features/audio-sampler, features/sampler, and features/smc-pad provide sample and percussion workflows.
- These are separate surfaces over the same underlying engine and project state, not separate apps.
12. User feedback and stateful UX
- features/history, features/tutorial, features/midi-events, and reusable components like dialogs and error boundaries support undo/redo, onboarding, event inspection, and fault isolation.
- This suggests the app is state-heavy and interaction-driven, with UI state layered on top of engine state.
13. Infrastructure and tooling
- The app uses React 19, TypeScript, and Vite for the main product.
- Esbuild powers plugin bundling; fflate/ZIP-based .mimod packaging and IndexedDB-backed plugin storage are part of the plugin infrastructure.
- Tests exist for project history and plugin model/registry/storage, showing those boundaries are meant to be stable.
14. Data flow to capture in an architecture diagram
- User action in a feature screen → application use-case → engine audio/MIDI/project subsystem → persistence or audio output.
- Plugin install/import → plugin storage/registry/loader → plugin workspace host or instrument catalog → runtime API callbacks.
- Project export/import and WAV export are terminal flows that leave the app boundary as files.
15. What is most important to draw
- A diagram should emphasize the separation between:
- presentation screens,
- use-case coordination,
- core audio/MIDI/project engines,
- plugin runtime/storage,
- and file/persistence/export boundaries.
- The main architectural idea is that React is only the shell; musical behavior lives in engine and plugin subsystems.
Main entry points: appRoutes.ts Routes · AppShell.tsx Shell · LabApp.tsx Lab · playNote.ts Play Note
Components 27
App Shell
Bootstrap, routing, theme, and global UI concerns.
- main.tsx · React entrypoint.
src/main.tsx - App · Top-level app composition.
src/App.tsx - Shell · Global app layout and mode handling.
src/app/AppShell.tsx - Routes · App route definitions.
src/app/appRoutes.ts - Navigation · Primary navigation structure.
src/app/appNavigation.ts - Theme · Shared theme tokens and visual mode.
src/app/appTheme.ts
Presentation
Feature screens and workspaces that orchestrate user interactions.
- Lab · Central music lab workspace.
src/features/lab/LabApp.tsx - Edit · Composition and editing surface.
src/features/edit/EditScreen.tsx - Perform · Live playing and performance surface.
src/features/perform/PerformScreen.tsx - Plugins · Plugin management and hosting UI.
src/features/plugins-view/PluginsScreen.tsx - Project · Project overview and control surface.
src/features/project-view/ProjectScreen.tsx - Timeline · Timeline and clip preview UI.
src/features/timeline/TimelinePreview.tsx
Application
Use-cases that coordinate workflows between UI and engine subsystems.
- Play Note · Triggers note playback.
src/application/use-cases/playNote.ts - Record Mic · Captures microphone input into samples.
src/application/use-cases/recordMicSample.ts - Import Project · Loads project bundles into the app.
src/application/use-cases/importProjectBundle.ts - Export Audio · Renders project audio for export.
src/application/use-cases/exportProjectAudio.ts
Engine
Core audio, MIDI, project, and persistence subsystems.
- Audio Engine · Runtime synthesis and sound playback services.
src/engine/audio/audioEngine.ts - Renderer · Offline audio rendering pipeline.
src/engine/audio/offlineAudioRenderer.ts - MIDI Events · Musical event primitives.
src/engine/midi/events.ts - Project Store · Project state storage and retrieval.
src/engine/project/projectStorage.ts
Plugins
Plugin runtime, storage, API boundary, and authoring artifacts.
- Host · Mounts external plugin workspaces inside the app.
src/features/plugins-view/PluginWorkspaceHost.tsx - Registry · Tracks installed and available plugins.
src/engine/plugins/pluginRegistry.ts - Loader · Loads plugin packages into memory.
src/engine/plugins/pluginLoader.ts - Plugin Storage · Stores external plugin packages.
src/engine/plugins/externalPluginStorage.ts - Plugin API · Contract exposed to plugin workspaces.
src/engine/plugins/pluginApi.ts - SDK Types · Typed plugin SDK boundary for authors.
public/mimidi-plugin-sdk.d.ts - Build Plugin · Packages plugin distributions.
scripts/build-plugin.mjs
Connections 27
- main.tsx → App: boots · Entry point renders the app root.
- App → Shell: composes · Root component delegates to the shell.
- Shell → Routes: uses · Shell routes screens.
- Shell → Navigation: uses · Shell exposes primary navigation.
- Shell → Theme: applies · Shell applies shared theme.
- Shell → Lab: opens · Shell can navigate to the lab workspace.
- Routes → Edit: routes · Route target for editing.
- Routes → Perform: routes · Route target for performance.
- Routes → Plugins: routes · Route target for plugin management.
- Routes → Project: routes · Route target for project control.
- Routes → Timeline: routes · Route target for timeline views.
- Lab → Play Note: triggers · Lab actions invoke playback workflows.
- Lab → Record Mic: triggers · Lab recording uses mic capture workflow.
- Lab → Registry: queries · Lab reads available instruments and plugins.
- Play Note → MIDI Events: creates · Use-case builds musical events.
- Play Note → Audio Engine: plays · Use-case sends events to sound engine.
- Record Mic → Audio Engine: captures · Mic capture depends on audio services.
- Import Project → Project Store: loads · Project import populates persisted state.
- Export Audio → Renderer: renders · Export uses offline audio rendering.
- Renderer → Audio Engine: depends on · Renderer uses core synthesis/runtime logic.
- Project → Project Store: manages · Project UI reflects stored project state.
- Plugins → Host: mounts · Plugin screen hosts external workspaces.
- Host → Plugin API: exposes · Host provides SDK callbacks and services.
- Registry → Loader: uses · Registry resolves loadable plugins.
- Registry → Plugin Storage: persists · Registry reads/writes installed packages.
- Plugin API → SDK Types: contracts · Typed public boundary for authors.
- Build Plugin → SDK Types: packages · Tooling builds distributable plugin artifacts against the SDK.