# andreabak/sibilant architecture

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

- Interactive diagram: https://gitdiagram.com/andreabak/sibilant
- Repository: https://github.com/andreabak/sibilant

## Overview

##### Main Components

a. Protocol Stack Layer:
- SIP (Session Initiation Protocol) Layer
- RTP (Real-time Transport Protocol) Layer
- SDP (Session Description Protocol) Layer
- Codec Layer (PCMA, PCMU, telephone-event)

b. Core Components:
- VOIP Phone Implementation
- Client Implementations
- Codec Framework
- Message Handling System

##### Component Organization

**[Application Layer]**
- VOIP Phone Component (voip/phone.py)

**[Protocol Layer]**
- SIP Component (sip/*) ←→ SDP Component (sdp/*)

- RTP Component (rtp/*)

**[Codec Layer]**
- Codec Framework (codecs/*)

**[Infrastructure Layer]**
- Helpers & Structures

##### Key Relationships to Highlight

- Bidirectional communication between SIP and SDP components
- Flow from VOIP Phone component down through the protocol stack
- Demonstrate how the codec framework interfaces with the RTP layer
- DTMF handling as a special case in the RTP layer

##### Specific Implementation Details

- Blue rectangles for main protocol components (SIP, RTP, SDP)
- Green rectangles for codec implementations
- Yellow diamonds for client interfaces
- Gray rectangles for utility components
- Red hexagons for DTMF and special event handling

##### Component Details

For each major component, include:
- Supported features (e.g., PCMA, PCMU for codecs)
- Key classes/modules
- External interfaces

##### Notes Section

A notes section mentioning:
- Early development status
- Supported codec types
- Future expansion points

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles and Classes
    classDef protocol fill:#a8d1f0,stroke:#333
    classDef codec fill:#90EE90,stroke:#333
    classDef client fill:#FFE4B5,stroke:#333
    classDef infrastructure fill:#D3D3D3,stroke:#333
    classDef dtmf fill:#FFB6C1,stroke:#333

    %% Application Layer
    subgraph AppLayer["Application Layer"]
        VoIPPhone["VoIP Phone Implementation"]
    end

    %% Protocol Layer
    subgraph ProtocolLayer["Protocol Layer"]
        subgraph SIPLayer["SIP Layer"]
            SIPClient["SIP Client"]:::protocol
            SIPMsg["Message Handling"]:::protocol
            SIPHeaders["Headers Processing"]:::protocol
        end

        subgraph SDPLayer["SDP Layer"]
            SDPSession["Session Management"]:::protocol
            SDPMedia["Media Description"]:::protocol
            SDPTime["Time Description"]:::protocol
        end

        subgraph RTPLayer["RTP Layer"]
            RTPClient["RTP Client"]:::protocol
            RTPPacket["Packet Processing"]:::protocol
            DTMF["DTMF Handling"]:::dtmf
        end
    end

    %% Codec Layer
    subgraph CodecLayer["Codec Layer"]
        CodecBase["Base Codec Framework"]:::codec
        G711["G711 Implementation"]:::codec
    end

    %% Infrastructure Layer
    subgraph InfraLayer["Infrastructure Layer"]
        Constants["Constants"]:::infrastructure
        Helpers["Helper Functions"]:::infrastructure
        Structures["Data Structures"]:::infrastructure
        Exceptions["Exception Handling"]:::infrastructure
    end

    %% Relationships
    VoIPPhone --> SIPClient
    VoIPPhone --> RTPClient
    
    SIPClient --> SIPMsg
    SIPClient --> SIPHeaders
    SIPClient <--> SDPSession
    
    SDPSession --> SDPMedia
    SDPSession --> SDPTime
    
    RTPClient --> RTPPacket
    RTPClient --> DTMF
    RTPClient --> CodecBase
    
    CodecBase --> G711

    %% Infrastructure connections
    VoIPPhone -.-> Constants
    VoIPPhone -.-> Helpers
    VoIPPhone -.-> Structures
    VoIPPhone -.-> Exceptions

    %% Click events
    click VoIPPhone "https://github.com/andreabak/sibilant/blob/main/sibilant/voip/phone.py"
    click SIPClient "https://github.com/andreabak/sibilant/blob/main/sibilant/sip/client.py"
    click SIPMsg "https://github.com/andreabak/sibilant/blob/main/sibilant/sip/messages.py"
    click SIPHeaders "https://github.com/andreabak/sibilant/blob/main/sibilant/sip/headers.py"
    click RTPClient "https://github.com/andreabak/sibilant/blob/main/sibilant/rtp/client.py"
    click RTPPacket "https://github.com/andreabak/sibilant/blob/main/sibilant/rtp/packet.py"
    click DTMF "https://github.com/andreabak/sibilant/blob/main/sibilant/rtp/dtmf.py"
    click SDPSession "https://github.com/andreabak/sibilant/blob/main/sibilant/sdp/session.py"
    click SDPMedia "https://github.com/andreabak/sibilant/blob/main/sibilant/sdp/media.py"
    click SDPTime "https://github.com/andreabak/sibilant/blob/main/sibilant/sdp/time.py"
    click CodecBase "https://github.com/andreabak/sibilant/blob/main/sibilant/codecs/base.py"
    click G711 "https://github.com/andreabak/sibilant/blob/main/sibilant/codecs/g711.py"
    click Constants "https://github.com/andreabak/sibilant/blob/main/sibilant/constants.py"
    click Helpers "https://github.com/andreabak/sibilant/blob/main/sibilant/helpers.py"
    click Structures "https://github.com/andreabak/sibilant/blob/main/sibilant/structures.py"
    click Exceptions "https://github.com/andreabak/sibilant/blob/main/sibilant/exceptions.py"

    %% Legend
    subgraph Legend
        P1["Protocol Component"]:::protocol
        C1["Codec Component"]:::codec
        D1["DTMF Component"]:::dtmf
        I1["Infrastructure Component"]:::infrastructure
    end
```
