# ilkermansur/gadget_record architecture

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

- Interactive diagram: https://gitdiagram.com/ilkermansur/gadget_record
- Repository: https://github.com/ilkermansur/gadget_record

## Overview

Gadget Record receives CUCM BiB SIP recording calls, captures call audio with Asterisk, then converts and stores recordings with metadata in PostgreSQL. Users manage recordings through a FastAPI interface for listing, metadata lookup, download, playback, and deletion. The graph reflects the sampled API and recording-worker code plus README-described capabilities; Asterisk configuration details are not sampled, so its internal call handling is represented only at a high level.

Main entry points: [`api/routers/recordings.py`](https://github.com/ilkermansur/gadget_record/blob/main/api/routers/recordings.py) (Recording routes), [`asterisk/save_recording.py`](https://github.com/ilkermansur/gadget_record/blob/main/asterisk/save_recording.py) (Recording worker), [`asterisk/extensions.conf`](https://github.com/ilkermansur/gadget_record/blob/main/asterisk/extensions.conf) (Asterisk server), [`api/main.py`](https://github.com/ilkermansur/gadget_record/blob/main/api/main.py) (FastAPI app)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_telephony["Call capture"]
  node_asterisk["Asterisk server<br/>[extensions.conf]"]
  node_capture["RTP recording<br/>[extensions.conf]"]
end

subgraph group_archive["Recording archive"]
  node_worker["Recording worker<br/>[save_recording.py]"]
  node_postgres[("Recordings store<br/>[init.sql]")]
end

subgraph group_management["Management API"]
  node_app["FastAPI app<br/>[main.py]"]
  node_routes["Recording routes<br/>[recordings.py]"]
  node_db_access["DB connection pool<br/>[database.py]"]
end

subgraph group_contracts["API contracts"]
  node_schemas["Response schemas<br/>[schemas.py]"]
end

node_cucm(("CUCM BiB"))
node_ffmpeg["FFmpeg tools"]
node_api_user(("API user"))

node_cucm -->|"sends SIP calls"| node_asterisk
node_asterisk -->|"captures streams"| node_capture
node_capture -.->|"processes recordings"| node_worker
node_worker -->|"transcodes audio"| node_ffmpeg
node_worker -->|"inserts audio"| node_postgres
node_api_user -->|"calls API"| node_app
node_app -->|"registers routes"| node_routes
node_routes -->|"gets connections"| node_db_access
node_routes -->|"queries recordings"| node_postgres
node_routes -->|"builds responses"| node_schemas

click node_asterisk "https://github.com/ilkermansur/gadget_record/blob/main/asterisk/extensions.conf"
click node_capture "https://github.com/ilkermansur/gadget_record/blob/main/asterisk/extensions.conf"
click node_worker "https://github.com/ilkermansur/gadget_record/blob/main/asterisk/save_recording.py"
click node_postgres "https://github.com/ilkermansur/gadget_record/blob/main/db/init.sql"
click node_app "https://github.com/ilkermansur/gadget_record/blob/main/api/main.py"
click node_routes "https://github.com/ilkermansur/gadget_record/blob/main/api/routers/recordings.py"
click node_db_access "https://github.com/ilkermansur/gadget_record/blob/main/api/database.py"
click node_schemas "https://github.com/ilkermansur/gadget_record/blob/main/api/schemas.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_asterisk,node_capture,node_api_user toneBlue
class node_worker,node_postgres toneAmber
class node_app,node_routes,node_db_access toneMint
class node_schemas toneRose
class node_cucm,node_ffmpeg toneIndigo
```

## Components

### Call capture

- [Asterisk server](https://github.com/ilkermansur/gadget_record/blob/main/asterisk/extensions.conf): `asterisk/extensions.conf`
- [RTP recording](https://github.com/ilkermansur/gadget_record/blob/main/asterisk/extensions.conf): `asterisk/extensions.conf`

### Recording archive

- [Recording worker](https://github.com/ilkermansur/gadget_record/blob/main/asterisk/save_recording.py): `asterisk/save_recording.py`
- [Recordings store](https://github.com/ilkermansur/gadget_record/blob/main/db/init.sql): `db/init.sql`

### Management API

- [FastAPI app](https://github.com/ilkermansur/gadget_record/blob/main/api/main.py): `api/main.py`
- [Recording routes](https://github.com/ilkermansur/gadget_record/blob/main/api/routers/recordings.py): `api/routers/recordings.py`
- [DB connection pool](https://github.com/ilkermansur/gadget_record/blob/main/api/database.py): `api/database.py`

### API contracts

- [Response schemas](https://github.com/ilkermansur/gadget_record/blob/main/api/schemas.py): `api/schemas.py`

### Other components

- **CUCM BiB**
- **FFmpeg tools**
- **API user**

## Connections

- CUCM BiB → Asterisk server: sends SIP calls (evidence: `README.md`)
- Asterisk server → RTP recording: captures streams (evidence: `README.md`)
- RTP recording → Recording worker: processes recordings (evidence: `README.md`)
- Recording worker → FFmpeg tools: transcodes audio (evidence: `asterisk/save_recording.py`)
- Recording worker → Recordings store: inserts audio (evidence: `asterisk/save_recording.py`)
- API user → FastAPI app: calls API (evidence: `README.md`)
- FastAPI app → Recording routes: registers routes (evidence: `api/main.py`)
- Recording routes → DB connection pool: gets connections (evidence: `api/routers/recordings.py`)
- Recording routes → Recordings store: queries recordings (evidence: `api/routers/recordings.py`)
- Recording routes → Response schemas: builds responses (evidence: `api/routers/recordings.py`)
