Core SDK architecture
The core package is a thin, framework-agnostic layer that centralizes configuration and shared logic. Client adapters plug into it but keep platform-specific code (WebRTC, UI primitives) on their side of the boundary.
Layered view
Responsibilities by layer
| Core concern | Description |
|---|---|
| Config | Stores SDK-wide options such as default model/voice, session config fetchers, log level. |
| API bridge | connectToRealtime sends SDP offers + ICE candidate payloads to Orga and returns the SDP answer. |
| Shared types | Single source for ConnectionState, OrgaAIModel, SessionConfig, etc. Adapters re-export them. |
| Utilities | Logging, validation helpers, optional functions like fetchSessionConfig. |
| Error classes | Standardized errors so adapters can respond uniformly. |
Adapter responsibilities (not core)
- Creating and managing
RTCPeerConnection. - Grabbing media devices, toggling mic/camera, handling permissions.
- Rendering UI controls or exposing framework-specific hooks.
- Translating native events into React/React Native state updates.
This separation lets core stay tiny and testable while adapters can evolve independently.
Data path recap
- Adapter collects SDP offer + ICE candidates using its platform APIs.
- Adapter calls
connectToRealtime(offer, params)from core. - Core reads global config (set via
OrgaAI.init()), attaches auth headers, and POSTs to/v1/realtime/calls. - Orga returns
{ answer, conversation_id }; core hands it back to the adapter. - Adapter applies the answer to the peer connection and continues streaming.
Core never touches DOM APIs, native modules, or even Node-specific constructs—only plain TypeScript plus fetch.
Developer implications
- Changing a type or error in core automatically updates React and React Native packages because the monorepo links them via TypeScript project references.
- When debugging cross-platform issues, compare behavior at the adapter layer first; if the bug exists in both, it probably lives in core.
Related docs
- Core introduction – why this layer exists.
- React architecture & React Native architecture – see how adapters plug into core.
- Node architecture – learn how credentials reach the adapters.
Last updated on