# meetecho/janode architecture

> Architecture diagram of the GitHub repository meetecho/janode, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-18). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/meetecho/janode
- Repository: https://github.com/meetecho/janode

## Overview

##### Main Components

a) Client Layer:
- Browser/Node.js Client Applications
- Both browser and Node.js compatibility
- Example applications (EchoTest, AudioBridge, Streaming, VideoRoom)

b) Janode Core Components:
- Connection Manager (connection.js)
- Session Handler (session.js)
- Plugin System (handle.js)
- Protocol Handler (protocol.js)
- Transport Layer (transport-ws.js, transport-unix.js)

c) Transport Protocols:
- WebSocket Connection
- Unix DGRAM Socket Connection

d) Plugin System:
- EchoTest Plugin
- AudioBridge Plugin
- Streaming Plugin
- VideoRoom Plugin

##### Component Relationships

- Client Applications → Janode Core
- Janode Core → Transport Layer
- Transport Layer → Janus WebRTC Server
- Plugin System as a modular extension of the core

##### Specific Implementation Details

Create distinct sections showing:
a) Core Architecture:
**[Client Apps] → [Janode Core (Connection → Session → Handle)] → [Transport Layer] → [Janus Server]**

b) Plugin Architecture:
**[Plugin Base] ─┬─ [EchoTest Plugin]**
- [AudioBridge Plugin]
- [Streaming Plugin]
- [VideoRoom Plugin]

##### Important Flows to Highlight

- Connection establishment flow
- Plugin attachment process
- WebRTC media handling

Create these distinct sections:
**┌─ Client Layer ─────────────────────┐**
- [Browser Clients] [Node.js Clients]│
- Janode Core ────────────────────┐ │
- [Connection Manager]             │ │
- [Session Handler]                │ │
- [Plugin System]                  │ │
- Transport Layer ────────────────┤ │
- [WebSocket] [Unix DGRAM Socket]  │ │
- ┘ │
- ┘

##### Additional Notes

- Notes about configuration requirements
- Error handling paths
- Event emission points

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles
    classDef client fill:#f0f0f0,stroke:#333
    classDef core fill:#b3d1ff,stroke:#333
    classDef transport fill:#90EE90,stroke:#333
    classDef plugin fill:#FFB366,stroke:#333
    classDef server fill:#E6E6FA,stroke:#333
    classDef example fill:#D3D3D3,stroke:#333
    classDef config fill:#FFE4B5,stroke:#333
    classDef utils fill:#F0E68C,stroke:#333

    %% Client Layer
    subgraph Clients
        BC[Browser Clients]:::client
        NC[Node.js Clients]:::client
    end

    %% Example Applications
    subgraph Examples
        ET_EX[EchoTest Example]:::example
        AB_EX[AudioBridge Example]:::example
        ST_EX[Streaming Example]:::example
        VR_EX[VideoRoom Example]:::example
    end

    %% Core Components
    subgraph Core
        JN[Janode Core]:::core
        CM[Connection Manager]:::core
        SH[Session Handler]:::core
        PS[Plugin System]:::core
        PH[Protocol Handler]:::core
        TM[Transport Manager]:::core
        CF[Configuration]:::config
    end

    %% Transport Layer
    subgraph Transport
        WS[WebSocket Transport]:::transport
        US[Unix Socket Transport]:::transport
    end

    %% Plugin System
    subgraph Plugins
        ET[EchoTest Plugin]:::plugin
        AB[AudioBridge Plugin]:::plugin
        ST[Streaming Plugin]:::plugin
        VR[VideoRoom Plugin]:::plugin
    end

    %% Utilities
    subgraph Utils
        UF[Utility Functions]:::utils
        LS[Logging System]:::utils
    end

    %% External
    JS[Janus Server]:::server

    %% Relationships
    BC --> JN
    NC --> JN
    JN --> CM
    CM --> SH
    SH --> PS
    PS --> PH
    PH --> TM
    TM --> WS & US
    WS & US --> JS
    PS --> ET & AB & ST & VR
    CF -.-> JN
    UF -.-> JN
    LS -.-> JN

    %% Click Events
    click CM "https://github.com/meetecho/janode/blob/master/src/connection.js"
    click SH "https://github.com/meetecho/janode/blob/master/src/session.js"
    click PS "https://github.com/meetecho/janode/blob/master/src/handle.js"
    click PH "https://github.com/meetecho/janode/blob/master/src/protocol.js"
    click WS "https://github.com/meetecho/janode/blob/master/src/transport-ws.js"
    click US "https://github.com/meetecho/janode/blob/master/src/transport-unix.js"
    click ET "https://github.com/meetecho/janode/blob/master/src/plugins/echotest-plugin.js"
    click AB "https://github.com/meetecho/janode/blob/master/src/plugins/audiobridge-plugin.js"
    click ST "https://github.com/meetecho/janode/blob/master/src/plugins/streaming-plugin.js"
    click VR "https://github.com/meetecho/janode/blob/master/src/plugins/videoroom-plugin.js"
    click ET_EX "https://github.com/meetecho/janode/tree/master/examples/echotest"
    click AB_EX "https://github.com/meetecho/janode/tree/master/examples/audiobridge"
    click ST_EX "https://github.com/meetecho/janode/tree/master/examples/streaming"
    click VR_EX "https://github.com/meetecho/janode/tree/master/examples/videoroom"
    click CF "https://github.com/meetecho/janode/blob/master/src/configuration.js"
    click JN "https://github.com/meetecho/janode/blob/master/src/janode.js"
    click TM "https://github.com/meetecho/janode/blob/master/src/tmanager.js"
    click UF "https://github.com/meetecho/janode/blob/master/src/utils/utils.js"
    click LS "https://github.com/meetecho/janode/blob/master/src/utils/logger.js"

    %% Legend
    subgraph Legend
        L1[Client Components]:::client
        L2[Core Components]:::core
        L3[Transport Layer]:::transport
        L4[Plugins]:::plugin
        L5[Server]:::server
        L6[Examples]:::example
        L7[Configuration]:::config
        L8[Utilities]:::utils
    end
```
