# heinrick7/astera-live-transcriber architecture

> Architecture diagram of the GitHub repository heinrick7/astera-live-transcriber, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-08-15). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/heinrick7/astera-live-transcriber
- Repository: https://github.com/heinrick7/astera-live-transcriber

## Overview

#### Purpose and entry points
Astera Live Transcriber is an independent Python service that converts audio into structured transcription segments, timestamps, revisions, and lifecycle events; it deliberately does not perform clinical interpretation. The ASGI entry point is `src/astera_live_transcriber/main.py`, which exposes HTTP, WebSocket, and a local browser UI through `src/astera_live_transcriber/presentation/api/app.py`.

#### API and session boundary
The presentation layer accepts batch-compatible WAV transcription, realtime file uploads, engine/model status requests, and bidirectional realtime audio sessions. Routes and WebSocket protocol are separated from application logic in:
- `src/astera_live_transcriber/presentation/api/routes/transcriptions.py`
- `src/astera_live_transcriber/presentation/api/routes/files.py`
- `src/astera_live_transcriber/presentation/api/websocket/realtime.py`

API-key authentication and dependency composition sit at the infrastructure/presentation boundary in `src/astera_live_transcriber/infrastructure/auth/api_key.py` and `src/astera_live_transcriber/presentation/api/dependencies.py`.

#### Application ports and orchestration
Hexagonal ports isolate the core from audio sources, speech engines, VAD, turn detection, and outbound event delivery:
- `src/astera_live_transcriber/application/ports/audio_source.py`
- `src/astera_live_transcriber/application/ports/transcription_engine.py`
- `src/astera_live_transcriber/application/ports/event_publisher.py`

Use cases coordinate batch and streaming paths in `src/astera_live_transcriber/application/use_cases/transcribe_audio.py` and `src/astera_live_transcriber/application/use_cases/stream_transcription.py`. Services divide pipeline processing, segmentation, streaming/session work, and inference orchestration.

#### Realtime audio pipeline
Audio enters as canonical PCM16 mono 16 kHz chunks (direct WebSocket) or is read from an uploaded MP3/WAV file. Chunks pass through an in-memory ring buffer, RMS VAD, and time-based turn detection before transcription. Key implementation stages are:
- `src/astera_live_transcriber/application/services/audio_pipeline.py`
- `src/astera_live_transcriber/infrastructure/audio/buffer.py`
- `src/astera_live_transcriber/infrastructure/vad/rms.py`
- `src/astera_live_transcriber/infrastructure/turn_detection/time_based.py`

The pipeline applies bounded backpressure and session cleanup. File sessions retain the source temporarily and stream/decode it rather than materializing full PCM: `src/astera_live_transcriber/infrastructure/audio/file_session_manager.py`, `src/astera_live_transcriber/infrastructure/audio/file_source.py`. File decoding requires `ffmpeg`.

#### Transcript lifecycle and domain model
Domain entities model audio, sessions, transcription segments, and events. Realtime output follows stable segment identity through `partial` → `revised` → `committed`; EOF or microphone stop flushes and force-commits active speech. Core definitions are:
- `src/astera_live_transcriber/domain/transcription/entities.py`
- `src/astera_live_transcriber/domain/transcription/events.py`
- `src/astera_live_transcriber/domain/session/entities.py`

`src/astera_live_transcriber/application/services/segment_service.py` owns segment construction/lifecycle, while `transcription_service.py` invokes the selected engine.

#### Speech-engine runtime
A runtime-selected engine adapter implements the transcription port:
- `src/astera_live_transcriber/infrastructure/engines/runtime.py`
- `src/astera_live_transcriber/infrastructure/engines/noop/adapter.py`
- `src/astera_live_transcriber/infrastructure/engines/parakeet/adapter.py`

`noop` is the safe default. Optional NVIDIA Parakeet TDT 0.6B v3 INT8 uses `sherpa-onnx`; its loader validates all ONNX artifacts, loads once, and keeps the recognizer resident (`src/astera_live_transcriber/infrastructure/engines/parakeet/loader.py`). Missing Parakeet assets fail explicitly rather than falling back.

#### Runtime, delivery, and observability
The service runs under Uvicorn/Python, with Docker Compose for local deployment (`Dockerfile`, `docker-compose.yml`). Configuration is environment-driven in `src/astera_live_transcriber/infrastructure/config/settings.py`. Logging and pipeline metrics—including lag, inference rate, and discarded late cancellation results—are implemented in `src/astera_live_transcriber/infrastructure/observability/logging.py` and `src/astera_live_transcriber/infrastructure/observability/metrics.py`. CI runs in GitHub Actions; staging deployment is manually triggered and isolated from production.

Main entry points: [`src/astera_live_transcriber/application/services/audio_pipeline.py`](https://github.com/heinrick7/astera-live-transcriber/blob/main/src/astera_live_transcriber/application/services/audio_pipeline.py) (Streaming audio pipeline), [`src/astera_live_transcriber/presentation/api/app.py`](https://github.com/heinrick7/astera-live-transcriber/blob/main/src/astera_live_transcriber/presentation/api/app.py) (API application), [`src/astera_live_transcriber/application/use_cases/stream_transcription.py`](https://github.com/heinrick7/astera-live-transcriber/blob/main/src/astera_live_transcriber/application/use_cases/stream_transcription.py) (Streaming transcription), [`src/astera_live_transcriber/presentation/api/dependencies.py`](https://github.com/heinrick7/astera-live-transcriber/blob/main/src/astera_live_transcriber/presentation/api/dependencies.py) (Auth and dependencies)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_presentation["Presentation"]
  node_main["ASGI entry point<br/>Python ASGI<br/>[main.py]"]
  node_api_app["API application<br/>HTTP/WebSocket UI<br/>[app.py]"]
  node_http_routes["Transcription and file routes<br/>HTTP routes<br/>[transcriptions.py]"]
  node_realtime_ws["Realtime WebSocket<br/>WebSocket protocol<br/>[realtime.py]"]
  node_api_composition["Auth and dependencies<br/>API composition<br/>[dependencies.py]"]
end

subgraph group_application["Application Core"]
  node_transcribe_use_case{{"Batch transcription<br/>Use case"}}
  node_stream_use_case{{"Streaming transcription<br/>Use case"}}
  node_ports["Core ports<br/>Hexagonal ports"]
  node_segment_service["Segment lifecycle<br/>Application service<br/>[segment_service.py]"]
  node_transcript_domain["Transcript and session model<br/>Domain entities/events<br/>[entities.py]"]
end

subgraph group_audio["Audio Processing"]
  node_audio_pipeline["Streaming audio pipeline<br/>Pipeline service<br/>[audio_pipeline.py]"]
  node_ring_buffer["In-memory ring buffer<br/>Audio buffer<br/>[buffer.py]"]
  node_vad["RMS VAD<br/>Voice activity detector<br/>[rms.py]"]
  node_turn_detection["Time-based turn detection<br/>Turn detector<br/>[time_based.py]"]
  node_file_audio["Streaming file source<br/>File audio adapter"]
end

subgraph group_engines["Speech Engines"]
  node_engine_runtime["Runtime engine selector<br/>Engine adapter factory<br/>[runtime.py]"]
  node_engine_adapters["Noop and Parakeet adapters<br/>Speech engine adapters<br/>[adapter.py]"]
  node_parakeet_loader["Parakeet model loader<br/>ONNX runtime loader<br/>[loader.py]"]
end

subgraph group_runtime["Runtime &amp; Operations"]
  node_service_runtime["Uvicorn and Docker deployment<br/>Runtime deployment"]
  node_observability["Logging and pipeline metrics<br/>Observability<br/>[metrics.py]"]
end

node_main -->|"starts"| node_api_app
node_api_app -->|"serves"| node_http_routes
node_api_app -->|"serves"| node_realtime_ws
node_api_app -->|"wires"| node_api_composition
node_api_composition -->|"injects"| node_transcribe_use_case
node_api_composition -->|"injects"| node_stream_use_case
node_http_routes -->|"batch/upload requests"| node_transcribe_use_case
node_realtime_ws -->|"audio session"| node_stream_use_case
node_transcribe_use_case -->|"reads uploaded audio"| node_file_audio
node_stream_use_case -->|"processes chunks"| node_audio_pipeline
node_file_audio -->|"decoded stream"| node_audio_pipeline
node_audio_pipeline -->|"buffers"| node_ring_buffer
node_audio_pipeline -->|"detects speech"| node_vad
node_vad -->|"speech timing"| node_turn_detection
node_turn_detection -->|"opens and flushes turns"| node_segment_service
node_segment_service -->|"emits lifecycle"| node_transcript_domain
node_audio_pipeline -->|"transcribes turns"| node_engine_runtime
node_engine_runtime -->|"implements engine port"| node_ports
node_engine_runtime -->|"selects"| node_engine_adapters
node_engine_adapters -.->|"loads Parakeet"| node_parakeet_loader
node_stream_use_case -->|"publishes events"| node_transcript_domain
node_audio_pipeline -->|"records metrics"| node_observability
node_service_runtime -->|"runs"| node_main

click node_main "https://github.com/heinrick7/astera-live-transcriber/blob/main/src/astera_live_transcriber/main.py"
click node_api_app "https://github.com/heinrick7/astera-live-transcriber/blob/main/src/astera_live_transcriber/presentation/api/app.py"
click node_http_routes "https://github.com/heinrick7/astera-live-transcriber/blob/main/src/astera_live_transcriber/presentation/api/routes/transcriptions.py"
click node_realtime_ws "https://github.com/heinrick7/astera-live-transcriber/blob/main/src/astera_live_transcriber/presentation/api/websocket/realtime.py"
click node_api_composition "https://github.com/heinrick7/astera-live-transcriber/blob/main/src/astera_live_transcriber/presentation/api/dependencies.py"
click node_transcribe_use_case "https://github.com/heinrick7/astera-live-transcriber/blob/main/src/astera_live_transcriber/application/use_cases/transcribe_audio.py"
click node_stream_use_case "https://github.com/heinrick7/astera-live-transcriber/blob/main/src/astera_live_transcriber/application/use_cases/stream_transcription.py"
click node_ports "https://github.com/heinrick7/astera-live-transcriber/blob/main/src/astera_live_transcriber/application/ports/transcription_engine.py"
click node_segment_service "https://github.com/heinrick7/astera-live-transcriber/blob/main/src/astera_live_transcriber/application/services/segment_service.py"
click node_transcript_domain "https://github.com/heinrick7/astera-live-transcriber/blob/main/src/astera_live_transcriber/domain/transcription/entities.py"
click node_audio_pipeline "https://github.com/heinrick7/astera-live-transcriber/blob/main/src/astera_live_transcriber/application/services/audio_pipeline.py"
click node_ring_buffer "https://github.com/heinrick7/astera-live-transcriber/blob/main/src/astera_live_transcriber/infrastructure/audio/buffer.py"
click node_vad "https://github.com/heinrick7/astera-live-transcriber/blob/main/src/astera_live_transcriber/infrastructure/vad/rms.py"
click node_turn_detection "https://github.com/heinrick7/astera-live-transcriber/blob/main/src/astera_live_transcriber/infrastructure/turn_detection/time_based.py"
click node_file_audio "https://github.com/heinrick7/astera-live-transcriber/blob/main/src/astera_live_transcriber/infrastructure/audio/file_session_manager.py"
click node_engine_runtime "https://github.com/heinrick7/astera-live-transcriber/blob/main/src/astera_live_transcriber/infrastructure/engines/runtime.py"
click node_engine_adapters "https://github.com/heinrick7/astera-live-transcriber/blob/main/src/astera_live_transcriber/infrastructure/engines/parakeet/adapter.py"
click node_parakeet_loader "https://github.com/heinrick7/astera-live-transcriber/blob/main/src/astera_live_transcriber/infrastructure/engines/parakeet/loader.py"
click node_service_runtime "https://github.com/heinrick7/astera-live-transcriber/blob/main/Dockerfile"
click node_observability "https://github.com/heinrick7/astera-live-transcriber/blob/main/src/astera_live_transcriber/infrastructure/observability/metrics.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_main,node_api_app,node_http_routes,node_realtime_ws,node_api_composition toneBlue
class node_transcribe_use_case,node_stream_use_case,node_ports,node_segment_service,node_transcript_domain toneAmber
class node_audio_pipeline,node_ring_buffer,node_vad,node_turn_detection,node_file_audio toneMint
class node_engine_runtime,node_engine_adapters,node_parakeet_loader toneRose
class node_service_runtime,node_observability toneIndigo
```

## Components

### Presentation

- [ASGI entry point](https://github.com/heinrick7/astera-live-transcriber/blob/main/src/astera_live_transcriber/main.py): Python ASGI · `src/astera_live_transcriber/main.py`
- [API application](https://github.com/heinrick7/astera-live-transcriber/blob/main/src/astera_live_transcriber/presentation/api/app.py): HTTP/WebSocket UI · `src/astera_live_transcriber/presentation/api/app.py`
- [Transcription and file routes](https://github.com/heinrick7/astera-live-transcriber/blob/main/src/astera_live_transcriber/presentation/api/routes/transcriptions.py): HTTP routes · Supports WAV transcription, uploads, and engine status. · `src/astera_live_transcriber/presentation/api/routes/transcriptions.py`
- [Realtime WebSocket](https://github.com/heinrick7/astera-live-transcriber/blob/main/src/astera_live_transcriber/presentation/api/websocket/realtime.py): WebSocket protocol · Accepts bidirectional PCM16 mono 16 kHz sessions. · `src/astera_live_transcriber/presentation/api/websocket/realtime.py`
- [Auth and dependencies](https://github.com/heinrick7/astera-live-transcriber/blob/main/src/astera_live_transcriber/presentation/api/dependencies.py): API composition · API-key authentication and dependency wiring. · `src/astera_live_transcriber/presentation/api/dependencies.py`

### Application Core

- [Batch transcription](https://github.com/heinrick7/astera-live-transcriber/blob/main/src/astera_live_transcriber/application/use_cases/transcribe_audio.py): Use case · `src/astera_live_transcriber/application/use_cases/transcribe_audio.py`
- [Streaming transcription](https://github.com/heinrick7/astera-live-transcriber/blob/main/src/astera_live_transcriber/application/use_cases/stream_transcription.py): Use case · `src/astera_live_transcriber/application/use_cases/stream_transcription.py`
- [Core ports](https://github.com/heinrick7/astera-live-transcriber/blob/main/src/astera_live_transcriber/application/ports/transcription_engine.py): Hexagonal ports · Abstract audio sources, engines, VAD, turn detection, and event delivery. · `src/astera_live_transcriber/application/ports/transcription_engine.py`
- [Segment lifecycle](https://github.com/heinrick7/astera-live-transcriber/blob/main/src/astera_live_transcriber/application/services/segment_service.py): Application service · Builds partial, revised, and committed segments. · `src/astera_live_transcriber/application/services/segment_service.py`
- [Transcript and session model](https://github.com/heinrick7/astera-live-transcriber/blob/main/src/astera_live_transcriber/domain/transcription/entities.py): Domain entities/events · Stable segment identity and lifecycle events. · `src/astera_live_transcriber/domain/transcription/entities.py`

### Audio Processing

- [Streaming audio pipeline](https://github.com/heinrick7/astera-live-transcriber/blob/main/src/astera_live_transcriber/application/services/audio_pipeline.py): Pipeline service · Applies bounded backpressure and cleanup. · `src/astera_live_transcriber/application/services/audio_pipeline.py`
- [In-memory ring buffer](https://github.com/heinrick7/astera-live-transcriber/blob/main/src/astera_live_transcriber/infrastructure/audio/buffer.py): Audio buffer · `src/astera_live_transcriber/infrastructure/audio/buffer.py`
- [RMS VAD](https://github.com/heinrick7/astera-live-transcriber/blob/main/src/astera_live_transcriber/infrastructure/vad/rms.py): Voice activity detector · `src/astera_live_transcriber/infrastructure/vad/rms.py`
- [Time-based turn detection](https://github.com/heinrick7/astera-live-transcriber/blob/main/src/astera_live_transcriber/infrastructure/turn_detection/time_based.py): Turn detector · `src/astera_live_transcriber/infrastructure/turn_detection/time_based.py`
- [Streaming file source](https://github.com/heinrick7/astera-live-transcriber/blob/main/src/astera_live_transcriber/infrastructure/audio/file_session_manager.py): File audio adapter · Temporarily retains and ffmpeg-decodes uploaded MP3/WAV without full PCM materialization. · `src/astera_live_transcriber/infrastructure/audio/file_session_manager.py`

### Speech Engines

- [Runtime engine selector](https://github.com/heinrick7/astera-live-transcriber/blob/main/src/astera_live_transcriber/infrastructure/engines/runtime.py): Engine adapter factory · Selects the configured transcription engine. · `src/astera_live_transcriber/infrastructure/engines/runtime.py`
- [Noop and Parakeet adapters](https://github.com/heinrick7/astera-live-transcriber/blob/main/src/astera_live_transcriber/infrastructure/engines/parakeet/adapter.py): Speech engine adapters · Noop is default; Parakeet missing assets fail explicitly. · `src/astera_live_transcriber/infrastructure/engines/parakeet/adapter.py`
- [Parakeet model loader](https://github.com/heinrick7/astera-live-transcriber/blob/main/src/astera_live_transcriber/infrastructure/engines/parakeet/loader.py): ONNX runtime loader · Validates assets and retains a resident sherpa-onnx recognizer. · `src/astera_live_transcriber/infrastructure/engines/parakeet/loader.py`

### Runtime & Operations

- [Uvicorn and Docker deployment](https://github.com/heinrick7/astera-live-transcriber/blob/main/Dockerfile): Runtime deployment · Python service with local Docker Compose deployment. · `Dockerfile`
- [Logging and pipeline metrics](https://github.com/heinrick7/astera-live-transcriber/blob/main/src/astera_live_transcriber/infrastructure/observability/metrics.py): Observability · Records lag, inference rate, and discarded late cancellations. · `src/astera_live_transcriber/infrastructure/observability/metrics.py`

## Connections

- ASGI entry point → API application: starts
- API application → Transcription and file routes: serves
- API application → Realtime WebSocket: serves
- API application → Auth and dependencies: wires
- Auth and dependencies → Batch transcription: injects
- Auth and dependencies → Streaming transcription: injects
- Transcription and file routes → Batch transcription: batch/upload requests
- Realtime WebSocket → Streaming transcription: audio session
- Batch transcription → Streaming file source: reads uploaded audio
- Streaming transcription → Streaming audio pipeline: processes chunks
- Streaming file source → Streaming audio pipeline: decoded stream
- Streaming audio pipeline → In-memory ring buffer: buffers
- Streaming audio pipeline → RMS VAD: detects speech
- RMS VAD → Time-based turn detection: speech timing
- Time-based turn detection → Segment lifecycle: opens and flushes turns
- Segment lifecycle → Transcript and session model: emits lifecycle
- Streaming audio pipeline → Runtime engine selector: transcribes turns
- Runtime engine selector → Core ports: implements engine port
- Runtime engine selector → Noop and Parakeet adapters: selects
- Noop and Parakeet adapters → Parakeet model loader: loads Parakeet
- Streaming transcription → Transcript and session model: publishes events
- Streaming audio pipeline → Logging and pipeline metrics: records metrics
- Uvicorn and Docker deployment → ASGI entry point: runs
