# romantrnt/mishka-s2s architecture

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

- Interactive diagram: https://gitdiagram.com/romantrnt/mishka-s2s
- Repository: https://github.com/romantrnt/mishka-s2s

## Overview

Mishka is an interactive voice assistant for a physical stand, with child-facing conversation, games, stories, safety policies, and lighting. The main workflow is an interaction handled by the application layer, which coordinates canonical state transitions and dialogue/audio services, then produces effects such as speech or lighting. The source index supports several module relationships, but the excerpts do not show the full runtime wiring or API entry path; uncertain links are omitted.

Main entry points: [`app/foundation/application.py`](https://github.com/romantrnt/mishka-s2s/blob/main/app/foundation/application.py) (Application), [`app/foundation/canonical_services.py`](https://github.com/romantrnt/mishka-s2s/blob/main/app/foundation/canonical_services.py) (Canonical services), [`app/foundation/s2s.py`](https://github.com/romantrnt/mishka-s2s/blob/main/app/foundation/s2s.py) (Speech dialogue), [`app/safety/guard.py`](https://github.com/romantrnt/mishka-s2s/blob/main/app/safety/guard.py) (Safety guard)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Runtime and interfaces"]
  node_api["HTTP API<br/>[api.py]"]
  node_application["Application<br/>[application.py]"]
  node_canonical["Canonical runtime"]
  node_scenario["Transition authorization<br/>[canonical_graph.py]"]
end

subgraph group_dialogue["Dialogue and audio"]
  node_s2s["Speech dialogue<br/>[s2s.py]"]
  node_voice["Voice processing<br/>[voice_pipeline.py]"]
  node_tts["TTS engine<br/>[tts_engine.py]"]
end

subgraph group_product["Experiences and policies"]
  node_age["Age policy<br/>[age_policy.py]"]
  node_game["Game engine<br/>[game_engine.py]"]
  node_gamecontent["Game content<br/>[game_content.py]"]
  node_menus["Scene menus<br/>[scene_menus.py]"]
  node_menucontent["Menu content<br/>[menu_content.py]"]
  node_services["Canonical services"]
  node_weather["Schedule and weather"]
end

subgraph group_safety["Safety"]
  node_safetyinput["Input safety<br/>[input_safety.py]"]
  node_safetyguard["Safety guard<br/>[guard.py]"]
  node_inputfilter["Input filter<br/>[input_filter.py]"]
  node_outputfilter["Output filter<br/>[output_filter.py]"]
  node_fallback["Fallback phrases<br/>[fallback.py]"]
end

subgraph group_hardware["Hardware and operations"]
  node_lighting["Lighting<br/>[lighting.py]"]
  node_hardware["Hardware adapter<br/>[hardware.py]"]
  node_latency[("Latency metrics<br/>[latency.py]")]
end

node_child(("Child"))
node_model(("Chat model service"))

node_child -.->|"sends interaction"| node_application
node_application -->|"handles events"| node_canonical
node_application -->|"coordinates dialogue"| node_s2s
node_application -->|"uses game logic"| node_game
node_application -->|"controls effects"| node_lighting
node_application -->|"uses policies"| node_services
node_application -->|"checks input"| node_safetyinput
node_application -->|"applies age policy"| node_age
node_canonical -->|"authorizes transitions"| node_scenario
node_game -->|"builds challenges"| node_gamecontent
node_s2s -->|"gets age details"| node_age
node_s2s -->|"uses audio operations"| node_voice
node_s2s -->|"uses dialogue content"| node_menucontent
node_s2s -->|"streams chat requests"| node_model
node_tts -->|"uses processing"| node_voice
node_services -->|"uses contract"| node_canonical
node_services -->|"uses schedule data"| node_weather
node_services -->|"uses lighting policy"| node_lighting
node_services -->|"uses scenario graph"| node_scenario
node_safetyinput -->|"uses safety classifier"| node_services
node_safetyguard -->|"checks input"| node_inputfilter
node_safetyguard -->|"checks output"| node_outputfilter
node_safetyguard -->|"selects fallback"| node_fallback
node_lighting -->|"drives output"| node_hardware

click node_api "https://github.com/romantrnt/mishka-s2s/blob/main/app/foundation/api.py"
click node_application "https://github.com/romantrnt/mishka-s2s/blob/main/app/foundation/application.py"
click node_canonical "https://github.com/romantrnt/mishka-s2s/blob/main/app/foundation/canonical_contract.py"
click node_scenario "https://github.com/romantrnt/mishka-s2s/blob/main/app/scenarios/canonical_graph.py"
click node_s2s "https://github.com/romantrnt/mishka-s2s/blob/main/app/foundation/s2s.py"
click node_voice "https://github.com/romantrnt/mishka-s2s/blob/main/app/foundation/voice_pipeline.py"
click node_tts "https://github.com/romantrnt/mishka-s2s/blob/main/app/foundation/tts_engine.py"
click node_age "https://github.com/romantrnt/mishka-s2s/blob/main/app/foundation/age_policy.py"
click node_game "https://github.com/romantrnt/mishka-s2s/blob/main/app/foundation/game_engine.py"
click node_gamecontent "https://github.com/romantrnt/mishka-s2s/blob/main/app/foundation/game_content.py"
click node_menus "https://github.com/romantrnt/mishka-s2s/blob/main/app/foundation/scene_menus.py"
click node_menucontent "https://github.com/romantrnt/mishka-s2s/blob/main/app/foundation/menu_content.py"
click node_services "https://github.com/romantrnt/mishka-s2s/blob/main/app/foundation/canonical_services.py"
click node_weather "https://github.com/romantrnt/mishka-s2s/blob/main/app/foundation/schedule_weather.py"
click node_safetyinput "https://github.com/romantrnt/mishka-s2s/blob/main/app/foundation/input_safety.py"
click node_safetyguard "https://github.com/romantrnt/mishka-s2s/blob/main/app/safety/guard.py"
click node_inputfilter "https://github.com/romantrnt/mishka-s2s/blob/main/app/safety/input_filter.py"
click node_outputfilter "https://github.com/romantrnt/mishka-s2s/blob/main/app/safety/output_filter.py"
click node_fallback "https://github.com/romantrnt/mishka-s2s/blob/main/app/safety/fallback.py"
click node_lighting "https://github.com/romantrnt/mishka-s2s/blob/main/app/foundation/lighting.py"
click node_hardware "https://github.com/romantrnt/mishka-s2s/blob/main/app/foundation/hardware.py"
click node_latency "https://github.com/romantrnt/mishka-s2s/blob/main/app/metrics/latency.py"

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_api,node_application,node_canonical,node_scenario toneBlue
class node_s2s,node_voice,node_tts toneAmber
class node_age,node_game,node_gamecontent,node_menus,node_menucontent,node_services,node_weather toneMint
class node_safetyinput,node_safetyguard,node_inputfilter,node_outputfilter,node_fallback toneRose
class node_lighting,node_hardware,node_latency,node_child,node_model toneIndigo
```

## Components

### Runtime and interfaces

- [HTTP API](https://github.com/romantrnt/mishka-s2s/blob/main/app/foundation/api.py): `app/foundation/api.py`
- [Application](https://github.com/romantrnt/mishka-s2s/blob/main/app/foundation/application.py): `app/foundation/application.py`
- [Canonical runtime](https://github.com/romantrnt/mishka-s2s/blob/main/app/foundation/canonical_contract.py): `app/foundation/canonical_contract.py`
- [Transition authorization](https://github.com/romantrnt/mishka-s2s/blob/main/app/scenarios/canonical_graph.py): `app/scenarios/canonical_graph.py`

### Dialogue and audio

- [Speech dialogue](https://github.com/romantrnt/mishka-s2s/blob/main/app/foundation/s2s.py): `app/foundation/s2s.py`
- [Voice processing](https://github.com/romantrnt/mishka-s2s/blob/main/app/foundation/voice_pipeline.py): `app/foundation/voice_pipeline.py`
- [TTS engine](https://github.com/romantrnt/mishka-s2s/blob/main/app/foundation/tts_engine.py): `app/foundation/tts_engine.py`

### Experiences and policies

- [Age policy](https://github.com/romantrnt/mishka-s2s/blob/main/app/foundation/age_policy.py): `app/foundation/age_policy.py`
- [Game engine](https://github.com/romantrnt/mishka-s2s/blob/main/app/foundation/game_engine.py): `app/foundation/game_engine.py`
- [Game content](https://github.com/romantrnt/mishka-s2s/blob/main/app/foundation/game_content.py): `app/foundation/game_content.py`
- [Scene menus](https://github.com/romantrnt/mishka-s2s/blob/main/app/foundation/scene_menus.py): `app/foundation/scene_menus.py`
- [Menu content](https://github.com/romantrnt/mishka-s2s/blob/main/app/foundation/menu_content.py): `app/foundation/menu_content.py`
- [Canonical services](https://github.com/romantrnt/mishka-s2s/blob/main/app/foundation/canonical_services.py): `app/foundation/canonical_services.py`
- [Schedule and weather](https://github.com/romantrnt/mishka-s2s/blob/main/app/foundation/schedule_weather.py): `app/foundation/schedule_weather.py`

### Safety

- [Input safety](https://github.com/romantrnt/mishka-s2s/blob/main/app/foundation/input_safety.py): `app/foundation/input_safety.py`
- [Safety guard](https://github.com/romantrnt/mishka-s2s/blob/main/app/safety/guard.py): `app/safety/guard.py`
- [Input filter](https://github.com/romantrnt/mishka-s2s/blob/main/app/safety/input_filter.py): `app/safety/input_filter.py`
- [Output filter](https://github.com/romantrnt/mishka-s2s/blob/main/app/safety/output_filter.py): `app/safety/output_filter.py`
- [Fallback phrases](https://github.com/romantrnt/mishka-s2s/blob/main/app/safety/fallback.py): `app/safety/fallback.py`

### Hardware and operations

- [Lighting](https://github.com/romantrnt/mishka-s2s/blob/main/app/foundation/lighting.py): `app/foundation/lighting.py`
- [Hardware adapter](https://github.com/romantrnt/mishka-s2s/blob/main/app/foundation/hardware.py): `app/foundation/hardware.py`
- [Latency metrics](https://github.com/romantrnt/mishka-s2s/blob/main/app/metrics/latency.py): `app/metrics/latency.py`

### Other components

- **Child**
- **Chat model service**

## Connections

- Child → Application: sends interaction
- Application → Canonical runtime: handles events (evidence: `app/foundation/application.py`)
- Application → Speech dialogue: coordinates dialogue (evidence: `app/foundation/application.py`)
- Application → Game engine: uses game logic (evidence: `app/foundation/application.py`)
- Application → Lighting: controls effects (evidence: `app/foundation/application.py`)
- Application → Canonical services: uses policies (evidence: `app/foundation/application.py`)
- Application → Input safety: checks input (evidence: `app/foundation/application.py`)
- Application → Age policy: applies age policy (evidence: `app/foundation/application.py`)
- Canonical runtime → Transition authorization: authorizes transitions (evidence: `app/scenarios/canonical_graph.py`)
- Game engine → Game content: builds challenges (evidence: `app/foundation/game_engine.py`)
- Speech dialogue → Age policy: gets age details (evidence: `app/foundation/s2s.py`)
- Speech dialogue → Voice processing: uses audio operations (evidence: `app/foundation/s2s.py`)
- Speech dialogue → Menu content: uses dialogue content (evidence: `app/foundation/s2s.py`)
- Speech dialogue → Chat model service: streams chat requests (evidence: `app/foundation/s2s.py`)
- TTS engine → Voice processing: uses processing (evidence: `app/foundation/tts_engine.py`)
- Canonical services → Canonical runtime: uses contract (evidence: `app/foundation/canonical_services.py`)
- Canonical services → Schedule and weather: uses schedule data (evidence: `app/foundation/canonical_services.py`)
- Canonical services → Lighting: uses lighting policy (evidence: `app/foundation/canonical_services.py`)
- Canonical services → Transition authorization: uses scenario graph (evidence: `app/foundation/canonical_services.py`)
- Input safety → Canonical services: uses safety classifier (evidence: `app/foundation/input_safety.py`)
- Safety guard → Input filter: checks input (evidence: `app/safety/guard.py`)
- Safety guard → Output filter: checks output (evidence: `app/safety/guard.py`)
- Safety guard → Fallback phrases: selects fallback (evidence: `app/safety/guard.py`)
- Lighting → Hardware adapter: drives output (evidence: `app/foundation/lighting.py`)
