# Internals reference

This page lists the server's paths, the repository layout, the database
tables, the job kinds and the app's routes. Why Mirli is built this way is
explained in [About Mirli's architecture](https://mirli.app/docs/architecture/index.md).

## Server paths

The server is a [Fastify](https://fastify.dev) app on port 17494.

| Path | Serves |
|---|---|
| `/` | The built web app, as static files |
| `/api/*` | The [HTTP API](https://mirli.app/docs/api/index.md) |
| `/v1/*` | OpenAI-compatible speech and transcription routes |
| `/mcp` | The [MCP endpoint](https://mirli.app/docs/mcp/index.md) |
| `/files/*` | The audio, straight off disk |
| `/artwork/*` | Generated cover art and avatars |

## Repository

The repository has three npm workspaces and a Rust shell:

```text
soundbox/
├── app/        the web app: React 19, Vite, Tailwind v4, shadcn/ui
├── server/     the server: Fastify, better-sqlite3, the model adapters
├── site/       the public static site, built from app/ components
├── src-tauri/  the desktop shell
├── docs/       these pages
└── scripts/    dev, build, and the content generators
```

## Data folder

The data folder holds one SQLite database, one WAV per sound, the weights and
the engines. It also has a `profiles/` folder: other libraries, each with its
own database and sounds, sharing one `models/` folder. The full layout is in
[Configuration](https://mirli.app/docs/install-config/index.md#data-folder).

## Database tables

| Table | Holds |
|---|---|
| `sounds` | Every generated or imported clip, with its full provenance |
| `sound_tags` | The tag index |
| `sessions` | A sitting: the sounds made in one run of the composer |
| `projects` | A folder you put sounds in on purpose |
| `stories` | A script or arrangement you keep coming back to |
| `story_segments` | The clips on a story's timeline |
| `story_tracks` | Per-lane mute, solo, gain and name |
| `voices` | Built-in voices and clones |
| `voice_samples` | The clips a cloned voice is made from |
| `mcp_calls` | What agents have done, for the Agents page |
| `conversations`, `conversation_entries` | The studio's chat and history |

Migrations are additive and run at startup. New columns are added to existing
databases and never removed, so a database made by an older build keeps
working.

## Jobs

A job is submitted with a request that returns a job id, and reported on a
Server-Sent Events stream:

```text
POST /api/generate          -> { "job_id": "<JOB_ID>" }
GET  /api/jobs/<JOB_ID>/events

queued -> loading -> generating -> encoding -> done
```

| Kind | Started by |
|---|---|
| `generate` | Making a sound or a track from a prompt |
| `speak` | Reading a script of one or more lines |
| `segment` | Reading or re-reading one line of a story |
| `separate` | Splitting a track into stems |
| `convert` | Voice conversion |
| `transcribe` | Turning a clip into text |
| `export` | Mixing a story's timeline down to one file |
| `download` | Fetching a model's weights, a runtime or a sample pack |
| `selftest` | A model's one-second test render |

| Property | Value |
|---|---|
| Queue | One worker, first in first out |
| Retention | The last 200 jobs, in memory. None survive a restart. |
| Not jobs | Streamed speech, `POST /api/render`, the `/v1/*` routes and artwork hold the request open instead. |

## Model tasks

A model is described by a `ModelSpec` and carries a `task`:

| Task | Meaning | Example |
|---|---|---|
| `gen` | Text to audio (sound effects or music) | Stable Audio, ACE-Step |
| `tts` | Text to speech | Chatterbox |
| `vc` | Voice conversion | RVC, Seed-VC |
| `sep` | Source separation into stems | HTDemucs |
| `asr` | Speech to text | Qwen3-ASR |

## Web app

The app is React 19 with a `HashRouter`. TanStack Query holds server state,
and Zustand holds client state, chiefly what is playing.

| Surface | Routes | What it is |
|---|---|---|
| Generate | `/chat`, `/console` | The composer: a prompt, a model and parameters in, one or more takes out. The console is the same session behind a hardware-style front panel. |
| Studio | `/studio/script/:storyId`, `/studio/music/:storyId` | The timeline, with lanes, clips, a mixer, a device rack and an export. See [the studio](https://mirli.app/docs/studio/index.md). |
| Library | `/library/*`, `/sounds/:id` | Everything made, searchable and taggable. |

## Public site

`site/` is a second Vite entry that prerenders app components to static HTML
with [vite-react-ssg](https://github.com/Daydreamer-riri/vite-react-ssg). It
imports from `app/src` through the `@/*` alias.

| Property | Value |
|---|---|
| Pages | `/sfx`, `/music`, `/models`, `/docs` and others, read from content files and manifests instead of the API |
| Backend | None. Components that call a live backend can't be used. |
| Swapped files | `seo-head`, which writes its tags while the page is prerendered |
