# stekohl/janus-gateway architecture

> Architecture diagram of the GitHub repository stekohl/janus-gateway, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-26). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/stekohl/janus-gateway
- Repository: https://github.com/stekohl/janus-gateway

## Overview

Janus is a general-purpose WebRTC server. A client sends API requests through a configured transport; the core routes sessions and plugin requests, while media negotiation and packet handling use the WebRTC protocol stack. Plugins provide distinct services such as conferencing, streaming, calling, messaging, and recording. The README documents additional API transports, event handlers, and post-processing capabilities. Source excerpts are partial, so links for unsampled subsystems follow documented roles and the repository’s module boundaries.

Main entry points: [`src/plugins/plugin.h`](https://github.com/stekohl/janus-gateway/blob/master/src/plugins/plugin.h) (Plugin interface), [`src/janus.c`](https://github.com/stekohl/janus-gateway/blob/master/src/janus.c) (Janus core), [`html/demos/janus.js`](https://github.com/stekohl/janus-gateway/blob/master/html/demos/janus.js) (Janus JS API), [`src/dtls.c`](https://github.com/stekohl/janus-gateway/blob/master/src/dtls.c) (DTLS and SRTP)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Client interface"]
  node_jsapi["Janus JS API<br/>[janus.js]"]
  node_browserpc["Browser peer connection"]
end

subgraph group_gateway["Gateway core"]
  node_transport["API transports<br/>[transport.h]"]
  node_http["HTTP transport<br/>[janus_http.c]"]
  node_websockets["WebSocket transport<br/>[janus_websockets.c]"]
  node_core["Janus core<br/>[janus.c]"]
  node_auth["Request authentication<br/>[auth.c]"]
  node_plugins["Plugin interface<br/>[plugin.h]"]
  node_events["Event dispatch<br/>[events.c]"]
end

subgraph group_media["Media stack"]
  node_ice["ICE connectivity<br/>[ice.c]"]
  node_dtls["DTLS and SRTP<br/>[dtls.c]"]
  node_sdp["SDP negotiation<br/>[sdp.c]"]
  node_rtp["RTP and RTCP<br/>[rtp.c]"]
  node_sctp["Data channels<br/>[sctp.c]"]
end

subgraph group_services["Plugins and services"]
  node_eventhandlers["Event handlers<br/>[eventhandler.h]"]
  node_audiobridge["AudioBridge"]
  node_videoroom["VideoRoom<br/>[janus_videoroom.c]"]
  node_streaming["Streaming<br/>[janus_streaming.c]"]
  node_sip["SIP gateway<br/>[janus_sip.c]"]
  node_videocall["VideoCall<br/>[janus_videocall.c]"]
  node_textroom["TextRoom<br/>[janus_textroom.c]"]
  node_recordplay["Recording playback<br/>[janus_recordplay.c]"]
  node_recorder["Recording helper<br/>[record.c]"]
  node_postprocess["Recording post-processing<br/>[janus-pp-rec.c]"]
end

node_user(("WebRTC client"))
node_external(("External event sinks"))

node_user -->|"uses"| node_jsapi
node_jsapi -->|"sends API requests"| node_http
node_jsapi -.->|"sends API requests"| node_websockets
node_jsapi -->|"creates peer connection"| node_browserpc
node_http -->|"dispatches requests"| node_core
node_websockets -->|"dispatches requests"| node_core
node_core -->|"checks credentials"| node_auth
node_core -->|"dispatches plugin requests"| node_plugins
node_core -->|"manages connectivity"| node_ice
node_core -->|"emits notifications"| node_events
node_plugins -->|"implements service"| node_audiobridge
node_plugins -->|"implements service"| node_videoroom
node_plugins -->|"implements service"| node_streaming
node_plugins -->|"implements service"| node_sip
node_plugins -->|"implements service"| node_videocall
node_plugins -->|"implements service"| node_textroom
node_plugins -->|"implements service"| node_recordplay
node_ice -->|"negotiates secure transport"| node_dtls
node_dtls -->|"secures negotiated media"| node_sdp
node_dtls -->|"protects media packets"| node_rtp
node_dtls -.->|"secures data channels"| node_sctp
node_events -->|"notifies handlers"| node_eventhandlers
node_eventhandlers -.->|"forwards events"| node_external
node_audiobridge -.->|"records media"| node_recorder
node_postprocess -->|"processes recordings"| node_recorder

click node_jsapi "https://github.com/stekohl/janus-gateway/blob/master/html/demos/janus.js"
click node_transport "https://github.com/stekohl/janus-gateway/blob/master/src/transports/transport.h"
click node_http "https://github.com/stekohl/janus-gateway/blob/master/src/transports/janus_http.c"
click node_websockets "https://github.com/stekohl/janus-gateway/blob/master/src/transports/janus_websockets.c"
click node_core "https://github.com/stekohl/janus-gateway/blob/master/src/janus.c"
click node_auth "https://github.com/stekohl/janus-gateway/blob/master/src/auth.c"
click node_plugins "https://github.com/stekohl/janus-gateway/blob/master/src/plugins/plugin.h"
click node_events "https://github.com/stekohl/janus-gateway/blob/master/src/events.c"
click node_eventhandlers "https://github.com/stekohl/janus-gateway/blob/master/src/events/eventhandler.h"
click node_ice "https://github.com/stekohl/janus-gateway/blob/master/src/ice.c"
click node_dtls "https://github.com/stekohl/janus-gateway/blob/master/src/dtls.c"
click node_sdp "https://github.com/stekohl/janus-gateway/blob/master/src/sdp.c"
click node_rtp "https://github.com/stekohl/janus-gateway/blob/master/src/rtp.c"
click node_sctp "https://github.com/stekohl/janus-gateway/blob/master/src/sctp.c"
click node_audiobridge "https://github.com/stekohl/janus-gateway/blob/master/src/plugins/janus_audiobridge.c"
click node_videoroom "https://github.com/stekohl/janus-gateway/blob/master/src/plugins/janus_videoroom.c"
click node_streaming "https://github.com/stekohl/janus-gateway/blob/master/src/plugins/janus_streaming.c"
click node_sip "https://github.com/stekohl/janus-gateway/blob/master/src/plugins/janus_sip.c"
click node_videocall "https://github.com/stekohl/janus-gateway/blob/master/src/plugins/janus_videocall.c"
click node_textroom "https://github.com/stekohl/janus-gateway/blob/master/src/plugins/janus_textroom.c"
click node_recordplay "https://github.com/stekohl/janus-gateway/blob/master/src/plugins/janus_recordplay.c"
click node_recorder "https://github.com/stekohl/janus-gateway/blob/master/src/record.c"
click node_postprocess "https://github.com/stekohl/janus-gateway/blob/master/src/postprocessing/janus-pp-rec.c"

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_jsapi,node_browserpc,node_user toneBlue
class node_transport,node_http,node_websockets,node_core,node_auth,node_plugins,node_events toneAmber
class node_ice,node_dtls,node_sdp,node_rtp,node_sctp toneMint
class node_eventhandlers,node_audiobridge,node_videoroom,node_streaming,node_sip,node_videocall,node_textroom,node_recordplay,node_recorder,node_postprocess toneRose
class node_external toneIndigo
```

## Components

### Client interface

- [Janus JS API](https://github.com/stekohl/janus-gateway/blob/master/html/demos/janus.js): `html/demos/janus.js`
- **Browser peer connection**

### Gateway core

- [API transports](https://github.com/stekohl/janus-gateway/blob/master/src/transports/transport.h): `src/transports/transport.h`
- [HTTP transport](https://github.com/stekohl/janus-gateway/blob/master/src/transports/janus_http.c): `src/transports/janus_http.c`
- [WebSocket transport](https://github.com/stekohl/janus-gateway/blob/master/src/transports/janus_websockets.c): `src/transports/janus_websockets.c`
- [Janus core](https://github.com/stekohl/janus-gateway/blob/master/src/janus.c): `src/janus.c`
- [Request authentication](https://github.com/stekohl/janus-gateway/blob/master/src/auth.c): `src/auth.c`
- [Plugin interface](https://github.com/stekohl/janus-gateway/blob/master/src/plugins/plugin.h): `src/plugins/plugin.h`
- [Event dispatch](https://github.com/stekohl/janus-gateway/blob/master/src/events.c): `src/events.c`

### Media stack

- [ICE connectivity](https://github.com/stekohl/janus-gateway/blob/master/src/ice.c): `src/ice.c`
- [DTLS and SRTP](https://github.com/stekohl/janus-gateway/blob/master/src/dtls.c): `src/dtls.c`
- [SDP negotiation](https://github.com/stekohl/janus-gateway/blob/master/src/sdp.c): `src/sdp.c`
- [RTP and RTCP](https://github.com/stekohl/janus-gateway/blob/master/src/rtp.c): `src/rtp.c`
- [Data channels](https://github.com/stekohl/janus-gateway/blob/master/src/sctp.c): `src/sctp.c`

### Plugins and services

- [Event handlers](https://github.com/stekohl/janus-gateway/blob/master/src/events/eventhandler.h): `src/events/eventhandler.h`
- [AudioBridge](https://github.com/stekohl/janus-gateway/blob/master/src/plugins/janus_audiobridge.c): `src/plugins/janus_audiobridge.c`
- [VideoRoom](https://github.com/stekohl/janus-gateway/blob/master/src/plugins/janus_videoroom.c): `src/plugins/janus_videoroom.c`
- [Streaming](https://github.com/stekohl/janus-gateway/blob/master/src/plugins/janus_streaming.c): `src/plugins/janus_streaming.c`
- [SIP gateway](https://github.com/stekohl/janus-gateway/blob/master/src/plugins/janus_sip.c): `src/plugins/janus_sip.c`
- [VideoCall](https://github.com/stekohl/janus-gateway/blob/master/src/plugins/janus_videocall.c): `src/plugins/janus_videocall.c`
- [TextRoom](https://github.com/stekohl/janus-gateway/blob/master/src/plugins/janus_textroom.c): `src/plugins/janus_textroom.c`
- [Recording playback](https://github.com/stekohl/janus-gateway/blob/master/src/plugins/janus_recordplay.c): `src/plugins/janus_recordplay.c`
- [Recording helper](https://github.com/stekohl/janus-gateway/blob/master/src/record.c): `src/record.c`
- [Recording post-processing](https://github.com/stekohl/janus-gateway/blob/master/src/postprocessing/janus-pp-rec.c): `src/postprocessing/janus-pp-rec.c`

### Other components

- **WebRTC client**
- **External event sinks**

## Connections

- WebRTC client → Janus JS API: uses
- Janus JS API → HTTP transport: sends API requests
- Janus JS API → WebSocket transport: sends API requests
- Janus JS API → Browser peer connection: creates peer connection
- HTTP transport → Janus core: dispatches requests
- WebSocket transport → Janus core: dispatches requests
- Janus core → Request authentication: checks credentials
- Janus core → Plugin interface: dispatches plugin requests
- Janus core → ICE connectivity: manages connectivity
- Janus core → Event dispatch: emits notifications
- Plugin interface → AudioBridge: implements service
- Plugin interface → VideoRoom: implements service
- Plugin interface → Streaming: implements service
- Plugin interface → SIP gateway: implements service
- Plugin interface → VideoCall: implements service
- Plugin interface → TextRoom: implements service
- Plugin interface → Recording playback: implements service
- ICE connectivity → DTLS and SRTP: negotiates secure transport
- DTLS and SRTP → SDP negotiation: secures negotiated media
- DTLS and SRTP → RTP and RTCP: protects media packets
- DTLS and SRTP → Data channels: secures data channels
- Event dispatch → Event handlers: notifies handlers
- Event handlers → External event sinks: forwards events
- AudioBridge → Recording helper: records media
- Recording post-processing → Recording helper: processes recordings
