# techmaniac89/pbxsense-agent architecture

> Architecture diagram of the GitHub repository techmaniac89/pbxsense-agent, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-07). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/techmaniac89/pbxsense-agent
- Repository: https://github.com/techmaniac89/pbxsense-agent

## Overview

PBXSense Agent is a local PBX-to-app bridge. Its main workflow selects a PBX connector, gathers and normalizes observations, builds a consistent snapshot for Home and live clients, and exposes authenticated pairing, diagnostics, and recording APIs. Separate history and insight processing enriches operational data; push and opt-in encrypted Internet Relay paths serve paired apps. The README documents several connector and feature capabilities whose implementation details were not sampled, so those relationships are shown only where documented or directly evidenced by the index.

Main entry points: [`pbxsense_agent/main.py`](https://github.com/techmaniac89/pbxsense-agent/blob/main/pbxsense_agent/main.py) (Agent API), [`pbxsense_agent/connectors.py`](https://github.com/techmaniac89/pbxsense-agent/blob/main/pbxsense_agent/connectors.py) (Connector selection), [`pbxsense_agent/pulse.py`](https://github.com/techmaniac89/pbxsense-agent/blob/main/pbxsense_agent/pulse.py) (Snapshot and presence), [`pbxsense_agent/cucm.py`](https://github.com/techmaniac89/pbxsense-agent/blob/main/pbxsense_agent/cucm.py) (Cisco CUCM)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_collection["PBX collection"]
  node_dispatch["Connector selection<br/>[connectors.py]"]
  node_asterisk["Asterisk AMI<br/>[ami.py]"]
  node_freeswitch["FreeSWITCH ESL<br/>[freeswitch.py]"]
  node_yeastar["Yeastar API<br/>[yeastar.py]"]
  node_grandstream["Grandstream UCM<br/>[grandstream.py]"]
  node_cucm["Cisco CUCM<br/>[cucm.py]"]
  node_jtapi["JTAPI live bridge<br/>[jtapi.py]"]
  node_mock["Mock connector<br/>[mock.py]"]
end

subgraph group_processing["State and insights"]
  node_snapshot["Snapshot and presence<br/>[pulse.py]"]
  node_insights["Home insights<br/>[engine.py]"]
end

subgraph group_local_api["Local Agent API"]
  node_agent["Agent API<br/>[main.py]"]
  node_config["Agent settings<br/>[settings.py]"]
  node_live["Live updates<br/>[live.py]"]
  node_diagnostics["Connector diagnostics<br/>[diagnostics.py]"]
end

subgraph group_relay["Push and Internet Relay"]
  node_push_client["Push relay client<br/>[relay.py]"]
  node_internet["Internet Relay path<br/>[internet_relay.py]"]
end

subgraph group_history["History and recordings"]
  node_history["Call history<br/>[history.py]"]
  node_presence_history[("Presence persistence")]
  node_recordings["Recording access<br/>[recordings.py]"]
end

node_app(("PBXSense app"))
node_pbx{{"Phone system"}}
node_cloud_relay["Push and secure relay<br/>[app.py]"]

node_app -->|"requests API"| node_agent
node_pbx -->|"serves AMI state"| node_asterisk
node_pbx -->|"serves ESL state"| node_freeswitch
node_pbx -->|"serves OpenAPI state"| node_yeastar
node_pbx -->|"serves UCM state"| node_grandstream
node_pbx -->|"serves CUCM state"| node_cucm
node_pbx -->|"provides mock state"| node_mock
node_agent -->|"uses settings"| node_config
node_agent -->|"selects connector"| node_dispatch
node_dispatch -->|"constructs client"| node_asterisk
node_dispatch -->|"constructs client"| node_freeswitch
node_dispatch -->|"constructs client"| node_yeastar
node_dispatch -->|"constructs client"| node_grandstream
node_dispatch -->|"constructs client"| node_cucm
node_dispatch -->|"selects mock"| node_mock
node_asterisk -->|"returns snapshot data"| node_snapshot
node_freeswitch -->|"returns snapshot data"| node_snapshot
node_yeastar -->|"returns snapshot data"| node_snapshot
node_cucm -->|"returns snapshot data"| node_snapshot
node_cucm -->|"reads live channels"| node_jtapi
node_mock -->|"returns mock snapshot"| node_snapshot
node_agent -->|"builds Home state"| node_snapshot
node_snapshot -->|"derives signals"| node_insights
node_agent -->|"adds Home insights"| node_insights
node_agent -->|"streams state"| node_live
node_agent -->|"serves diagnostics"| node_diagnostics
node_agent -->|"uses call history"| node_history
node_agent -->|"persists device activity"| node_presence_history
node_agent -->|"serves recordings"| node_recordings
node_agent -->|"forwards device lifecycle"| node_push_client
node_push_client -->|"sends relay requests"| node_cloud_relay
node_agent -->|"runs relay polling"| node_internet
node_internet -->|"sends encrypted snapshots"| node_cloud_relay
node_cloud_relay -.->|"delivers relay data"| node_app

click node_agent "https://github.com/techmaniac89/pbxsense-agent/blob/main/pbxsense_agent/main.py"
click node_config "https://github.com/techmaniac89/pbxsense-agent/blob/main/pbxsense_agent/settings.py"
click node_dispatch "https://github.com/techmaniac89/pbxsense-agent/blob/main/pbxsense_agent/connectors.py"
click node_asterisk "https://github.com/techmaniac89/pbxsense-agent/blob/main/pbxsense_agent/ami.py"
click node_freeswitch "https://github.com/techmaniac89/pbxsense-agent/blob/main/pbxsense_agent/freeswitch.py"
click node_yeastar "https://github.com/techmaniac89/pbxsense-agent/blob/main/pbxsense_agent/yeastar.py"
click node_grandstream "https://github.com/techmaniac89/pbxsense-agent/blob/main/pbxsense_agent/grandstream.py"
click node_cucm "https://github.com/techmaniac89/pbxsense-agent/blob/main/pbxsense_agent/cucm.py"
click node_jtapi "https://github.com/techmaniac89/pbxsense-agent/blob/main/pbxsense_agent/jtapi.py"
click node_mock "https://github.com/techmaniac89/pbxsense-agent/blob/main/pbxsense_agent/mock.py"
click node_snapshot "https://github.com/techmaniac89/pbxsense-agent/blob/main/pbxsense_agent/pulse.py"
click node_insights "https://github.com/techmaniac89/pbxsense-agent/blob/main/pbxsense_agent/engine.py"
click node_live "https://github.com/techmaniac89/pbxsense-agent/blob/main/pbxsense_agent/live.py"
click node_diagnostics "https://github.com/techmaniac89/pbxsense-agent/blob/main/pbxsense_agent/diagnostics.py"
click node_history "https://github.com/techmaniac89/pbxsense-agent/blob/main/pbxsense_agent/history.py"
click node_presence_history "https://github.com/techmaniac89/pbxsense-agent/blob/main/pbxsense_agent/presence_history.py"
click node_recordings "https://github.com/techmaniac89/pbxsense-agent/blob/main/pbxsense_agent/recordings.py"
click node_push_client "https://github.com/techmaniac89/pbxsense-agent/blob/main/pbxsense_agent/relay.py"
click node_internet "https://github.com/techmaniac89/pbxsense-agent/blob/main/pbxsense_agent/internet_relay.py"
click node_cloud_relay "https://github.com/techmaniac89/pbxsense-agent/blob/main/push_relay/app.py"

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_dispatch,node_asterisk,node_freeswitch,node_yeastar,node_grandstream,node_cucm,node_jtapi,node_mock toneBlue
class node_snapshot,node_insights toneAmber
class node_agent,node_config,node_live,node_diagnostics toneMint
class node_push_client,node_internet toneRose
class node_history,node_presence_history,node_recordings,node_app,node_pbx toneIndigo
class node_cloud_relay toneTeal
```

## Components

### PBX collection

- [Connector selection](https://github.com/techmaniac89/pbxsense-agent/blob/main/pbxsense_agent/connectors.py): `pbxsense_agent/connectors.py`
- [Asterisk AMI](https://github.com/techmaniac89/pbxsense-agent/blob/main/pbxsense_agent/ami.py): `pbxsense_agent/ami.py`
- [FreeSWITCH ESL](https://github.com/techmaniac89/pbxsense-agent/blob/main/pbxsense_agent/freeswitch.py): `pbxsense_agent/freeswitch.py`
- [Yeastar API](https://github.com/techmaniac89/pbxsense-agent/blob/main/pbxsense_agent/yeastar.py): `pbxsense_agent/yeastar.py`
- [Grandstream UCM](https://github.com/techmaniac89/pbxsense-agent/blob/main/pbxsense_agent/grandstream.py): `pbxsense_agent/grandstream.py`
- [Cisco CUCM](https://github.com/techmaniac89/pbxsense-agent/blob/main/pbxsense_agent/cucm.py): `pbxsense_agent/cucm.py`
- [JTAPI live bridge](https://github.com/techmaniac89/pbxsense-agent/blob/main/pbxsense_agent/jtapi.py): `pbxsense_agent/jtapi.py`
- [Mock connector](https://github.com/techmaniac89/pbxsense-agent/blob/main/pbxsense_agent/mock.py): `pbxsense_agent/mock.py`

### State and insights

- [Snapshot and presence](https://github.com/techmaniac89/pbxsense-agent/blob/main/pbxsense_agent/pulse.py): `pbxsense_agent/pulse.py`
- [Home insights](https://github.com/techmaniac89/pbxsense-agent/blob/main/pbxsense_agent/engine.py): `pbxsense_agent/engine.py`

### Local Agent API

- [Agent API](https://github.com/techmaniac89/pbxsense-agent/blob/main/pbxsense_agent/main.py): `pbxsense_agent/main.py`
- [Agent settings](https://github.com/techmaniac89/pbxsense-agent/blob/main/pbxsense_agent/settings.py): `pbxsense_agent/settings.py`
- [Live updates](https://github.com/techmaniac89/pbxsense-agent/blob/main/pbxsense_agent/live.py): `pbxsense_agent/live.py`
- [Connector diagnostics](https://github.com/techmaniac89/pbxsense-agent/blob/main/pbxsense_agent/diagnostics.py): `pbxsense_agent/diagnostics.py`

### Push and Internet Relay

- [Push relay client](https://github.com/techmaniac89/pbxsense-agent/blob/main/pbxsense_agent/relay.py): `pbxsense_agent/relay.py`
- [Internet Relay path](https://github.com/techmaniac89/pbxsense-agent/blob/main/pbxsense_agent/internet_relay.py): `pbxsense_agent/internet_relay.py`

### History and recordings

- [Call history](https://github.com/techmaniac89/pbxsense-agent/blob/main/pbxsense_agent/history.py): `pbxsense_agent/history.py`
- [Presence persistence](https://github.com/techmaniac89/pbxsense-agent/blob/main/pbxsense_agent/presence_history.py): `pbxsense_agent/presence_history.py`
- [Recording access](https://github.com/techmaniac89/pbxsense-agent/blob/main/pbxsense_agent/recordings.py): `pbxsense_agent/recordings.py`

### Other components

- **PBXSense app**
- **Phone system**
- [Push and secure relay](https://github.com/techmaniac89/pbxsense-agent/blob/main/push_relay/app.py): `push_relay/app.py`

## Connections

- PBXSense app → Agent API: requests API (evidence: `README.md`)
- Phone system → Asterisk AMI: serves AMI state (evidence: `README.md`)
- Phone system → FreeSWITCH ESL: serves ESL state (evidence: `README.md`)
- Phone system → Yeastar API: serves OpenAPI state (evidence: `README.md`)
- Phone system → Grandstream UCM: serves UCM state (evidence: `README.md`)
- Phone system → Cisco CUCM: serves CUCM state (evidence: `README.md`)
- Phone system → Mock connector: provides mock state (evidence: `README.md`)
- Agent API → Agent settings: uses settings (evidence: `pbxsense_agent/main.py`)
- Agent API → Connector selection: selects connector (evidence: `pbxsense_agent/main.py`)
- Connector selection → Asterisk AMI: constructs client (evidence: `pbxsense_agent/connectors.py`)
- Connector selection → FreeSWITCH ESL: constructs client (evidence: `pbxsense_agent/connectors.py`)
- Connector selection → Yeastar API: constructs client (evidence: `pbxsense_agent/connectors.py`)
- Connector selection → Grandstream UCM: constructs client (evidence: `pbxsense_agent/connectors.py`)
- Connector selection → Cisco CUCM: constructs client (evidence: `pbxsense_agent/connectors.py`)
- Connector selection → Mock connector: selects mock (evidence: `pbxsense_agent/connectors.py`)
- Asterisk AMI → Snapshot and presence: returns snapshot data (evidence: `pbxsense_agent/ami.py`)
- FreeSWITCH ESL → Snapshot and presence: returns snapshot data (evidence: `pbxsense_agent/freeswitch.py`)
- Yeastar API → Snapshot and presence: returns snapshot data (evidence: `pbxsense_agent/yeastar.py`)
- Cisco CUCM → Snapshot and presence: returns snapshot data (evidence: `pbxsense_agent/cucm.py`)
- Cisco CUCM → JTAPI live bridge: reads live channels (evidence: `pbxsense_agent/cucm.py`)
- Mock connector → Snapshot and presence: returns mock snapshot (evidence: `pbxsense_agent/connectors.py`)
- Agent API → Snapshot and presence: builds Home state (evidence: `pbxsense_agent/main.py`)
- Snapshot and presence → Home insights: derives signals (evidence: `pbxsense_agent/pulse.py`)
- Agent API → Home insights: adds Home insights (evidence: `README.md`)
- Agent API → Live updates: streams state (evidence: `README.md`)
- Agent API → Connector diagnostics: serves diagnostics (evidence: `pbxsense_agent/main.py`)
- Agent API → Call history: uses call history (evidence: `pbxsense_agent/main.py`)
- Agent API → Presence persistence: persists device activity (evidence: `pbxsense_agent/main.py`)
- Agent API → Recording access: serves recordings (evidence: `pbxsense_agent/main.py`)
- Agent API → Push relay client: forwards device lifecycle (evidence: `pbxsense_agent/main.py`)
- Push relay client → Push and secure relay: sends relay requests (evidence: `README.md`)
- Agent API → Internet Relay path: runs relay polling (evidence: `pbxsense_agent/main.py`)
- Internet Relay path → Push and secure relay: sends encrypted snapshots (evidence: `README.md`)
- Push and secure relay → PBXSense app: delivers relay data (evidence: `README.md`)
