# balena/elixir-sippet architecture

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

- Interactive diagram: https://gitdiagram.com/balena/elixir-sippet
- Repository: https://github.com/balena/elixir-sippet

## Overview

Sippet is an Elixir SIP middleware stack. The principal workflow is: a SIP peer sends a datagram, UDP delivers it to the router, the message parser constructs a structured SIP message, and a client/server transaction drives callbacks into the registered application core. Outbound requests follow the reverse path through transaction state machines and UDP. Digest authentication is an optional application-facing capability. The graph reflects sampled Elixir and C++ paths; some router dispatch details are inferred only where documented.

Main entry points: [`lib/sippet/router.ex`](https://github.com/balena/elixir-sippet/blob/master/lib/sippet/router.ex) (SIP Router), [`lib/sippet/transports/udp.ex`](https://github.com/balena/elixir-sippet/blob/master/lib/sippet/transports/udp.ex) (UDP Transport), [`lib/sippet/message.ex`](https://github.com/balena/elixir-sippet/blob/master/lib/sippet/message.ex) (SIP Message), [`lib/sippet.ex`](https://github.com/balena/elixir-sippet/blob/master/lib/sippet.ex) (Sippet API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["Stack API"]
  node_sippet_api["Sippet API<br/>[sippet.ex]"]
  node_router["SIP Router<br/>[router.ex]"]
  node_core["Core Callbacks<br/>[core.ex]"]
end

subgraph group_messages["Message Processing"]
  node_message["SIP Message<br/>[message.ex]"]
  node_parser["Message Parser<br/>[parser.ex]"]
  node_nif_parser["C++ NIF Parser<br/>[parser.cc]"]
end

subgraph group_transactions["Transaction State"]
  node_client_invite["Client INVITE FSM<br/>[invite.ex]"]
  node_client_noninvite["Client Non-INVITE FSM<br/>[non_invite.ex]"]
  node_server_invite["Server INVITE FSM<br/>[invite.ex]"]
  node_server_noninvite["Server Non-INVITE FSM<br/>[non_invite.ex]"]
end

subgraph group_transport["Network Transport"]
  node_udp["UDP Transport<br/>[udp.ex]"]
end

subgraph group_security["Authentication"]
  node_digest_auth["Digest Authentication<br/>[digest_auth.ex]"]
end

node_sip_peer(("SIP Peer"))
node_middleware_app(("Middleware App"))

node_middleware_app -->|"calls API"| node_sippet_api
node_sippet_api -->|"dispatches"| node_router
node_sip_peer -->|"sends datagrams"| node_udp
node_udp -->|"delivers datagrams"| node_router
node_router -->|"parses messages"| node_message
node_message -->|"calls parser"| node_parser
node_parser -->|"loads NIF"| node_nif_parser
node_router -->|"starts transaction"| node_client_invite
node_router -->|"starts transaction"| node_client_noninvite
node_router -->|"starts transaction"| node_server_invite
node_router -->|"starts transaction"| node_server_noninvite
node_client_invite -->|"sends transport"| node_router
node_client_noninvite -->|"sends transport"| node_router
node_server_invite -->|"sends response"| node_router
node_server_noninvite -->|"sends response"| node_router
node_router -->|"sends messages"| node_udp
node_udp -->|"serializes messages"| node_message
node_router -->|"delivers callbacks"| node_core
node_middleware_app -.->|"uses authentication"| node_digest_auth
node_digest_auth -.->|"updates headers"| node_message

click node_sippet_api "https://github.com/balena/elixir-sippet/blob/master/lib/sippet.ex"
click node_router "https://github.com/balena/elixir-sippet/blob/master/lib/sippet/router.ex"
click node_core "https://github.com/balena/elixir-sippet/blob/master/lib/sippet/core.ex"
click node_message "https://github.com/balena/elixir-sippet/blob/master/lib/sippet/message.ex"
click node_parser "https://github.com/balena/elixir-sippet/blob/master/lib/sippet/parser.ex"
click node_nif_parser "https://github.com/balena/elixir-sippet/blob/master/c_src/parser.cc"
click node_client_invite "https://github.com/balena/elixir-sippet/blob/master/lib/sippet/transactions/client/invite.ex"
click node_client_noninvite "https://github.com/balena/elixir-sippet/blob/master/lib/sippet/transactions/client/non_invite.ex"
click node_server_invite "https://github.com/balena/elixir-sippet/blob/master/lib/sippet/transactions/server/invite.ex"
click node_server_noninvite "https://github.com/balena/elixir-sippet/blob/master/lib/sippet/transactions/server/non_invite.ex"
click node_udp "https://github.com/balena/elixir-sippet/blob/master/lib/sippet/transports/udp.ex"
click node_digest_auth "https://github.com/balena/elixir-sippet/blob/master/lib/sippet/digest_auth.ex"

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_sippet_api,node_router,node_core toneBlue
class node_message,node_parser,node_nif_parser toneAmber
class node_client_invite,node_client_noninvite,node_server_invite,node_server_noninvite toneMint
class node_udp toneRose
class node_digest_auth,node_sip_peer,node_middleware_app toneIndigo
```

## Components

### Stack API

- [Sippet API](https://github.com/balena/elixir-sippet/blob/master/lib/sippet.ex): `lib/sippet.ex`
- [SIP Router](https://github.com/balena/elixir-sippet/blob/master/lib/sippet/router.ex): `lib/sippet/router.ex`
- [Core Callbacks](https://github.com/balena/elixir-sippet/blob/master/lib/sippet/core.ex): `lib/sippet/core.ex`

### Message Processing

- [SIP Message](https://github.com/balena/elixir-sippet/blob/master/lib/sippet/message.ex): `lib/sippet/message.ex`
- [Message Parser](https://github.com/balena/elixir-sippet/blob/master/lib/sippet/parser.ex): `lib/sippet/parser.ex`
- [C++ NIF Parser](https://github.com/balena/elixir-sippet/blob/master/c_src/parser.cc): `c_src/parser.cc`

### Transaction State

- [Client INVITE FSM](https://github.com/balena/elixir-sippet/blob/master/lib/sippet/transactions/client/invite.ex): `lib/sippet/transactions/client/invite.ex`
- [Client Non-INVITE FSM](https://github.com/balena/elixir-sippet/blob/master/lib/sippet/transactions/client/non_invite.ex): `lib/sippet/transactions/client/non_invite.ex`
- [Server INVITE FSM](https://github.com/balena/elixir-sippet/blob/master/lib/sippet/transactions/server/invite.ex): `lib/sippet/transactions/server/invite.ex`
- [Server Non-INVITE FSM](https://github.com/balena/elixir-sippet/blob/master/lib/sippet/transactions/server/non_invite.ex): `lib/sippet/transactions/server/non_invite.ex`

### Network Transport

- [UDP Transport](https://github.com/balena/elixir-sippet/blob/master/lib/sippet/transports/udp.ex): `lib/sippet/transports/udp.ex`

### Authentication

- [Digest Authentication](https://github.com/balena/elixir-sippet/blob/master/lib/sippet/digest_auth.ex): `lib/sippet/digest_auth.ex`

### Other components

- **SIP Peer**
- **Middleware App**

## Connections

- Middleware App → Sippet API: calls API
- Sippet API → SIP Router: dispatches
- SIP Peer → UDP Transport: sends datagrams
- UDP Transport → SIP Router: delivers datagrams
- SIP Router → SIP Message: parses messages
- SIP Message → Message Parser: calls parser
- Message Parser → C++ NIF Parser: loads NIF
- SIP Router → Client INVITE FSM: starts transaction
- SIP Router → Client Non-INVITE FSM: starts transaction
- SIP Router → Server INVITE FSM: starts transaction
- SIP Router → Server Non-INVITE FSM: starts transaction
- Client INVITE FSM → SIP Router: sends transport
- Client Non-INVITE FSM → SIP Router: sends transport
- Server INVITE FSM → SIP Router: sends response
- Server Non-INVITE FSM → SIP Router: sends response
- SIP Router → UDP Transport: sends messages
- UDP Transport → SIP Message: serializes messages
- SIP Router → Core Callbacks: delivers callbacks
- Middleware App → Digest Authentication: uses authentication
- Digest Authentication → SIP Message: updates headers
