# dark-li/bmd_webtally architecture

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

- Interactive diagram: https://gitdiagram.com/dark-li/bmd_webtally
- Repository: https://github.com/dark-li/bmd_webtally

## Overview

BMD WebTally connects a browser-based tally interface to a Blackmagic ATEM switcher. An operator configures the switcher IP and source-to-label mappings; the service reads Program, Preview, and tally state, which the server exposes to the overview and label-specific client pages. The client page supports fullscreen tally lamps. Configuration is persisted in JSON. The sampled server and scripts show the main request and update paths; page behavior and capabilities are also supported by the README.

Main entry points: [`app/main.py`](https://github.com/dark-li/bmd_webtally/blob/main/app/main.py) (FastAPI routes), [`static/app.js`](https://github.com/dark-li/bmd_webtally/blob/main/static/app.js) (Tally management UI), [`static/client.js`](https://github.com/dark-li/bmd_webtally/blob/main/static/client.js) (Client lamp UI), [`app/atem_service.py`](https://github.com/dark-li/bmd_webtally/blob/main/app/atem_service.py) (ATEM state service)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web interface"]
  node_admin_ui["Tally management UI<br/>[app.js]"]
  node_admin_page["Management page<br/>[index.html]"]
  node_client_ui["Client lamp UI<br/>[client.js]"]
  node_client_page["Client page<br/>[client.html]"]
end

subgraph group_server["Application server"]
  node_server["FastAPI routes<br/>[main.py]"]
  node_state_projection["Mapped client state<br/>[main.py]"]
  node_mapping_api["Mapping management<br/>[main.py]"]
end

subgraph group_tally["ATEM tally"]
  node_tally_service["ATEM state service<br/>[atem_service.py]"]
end

subgraph group_persistence["Configuration"]
  node_config_store["Config store<br/>[config_store.py]"]
  node_config_file[("JSON configuration<br/>[config.json]")]
end

node_operator(("Operator"))
node_camera_operator(("Camera operator"))
node_switcher["ATEM switcher"]
node_atem_library["PyATEMMax"]

node_operator -->|"configures"| node_admin_ui
node_admin_ui -->|"sends API requests"| node_server
node_admin_ui -->|"receives live state"| node_server
node_server -->|"renders"| node_admin_page
node_server -->|"renders"| node_client_page
node_camera_operator -->|"views tally"| node_client_ui
node_client_ui -->|"requests client state"| node_server
node_client_ui -->|"receives live state"| node_server
node_server -->|"builds payload"| node_state_projection
node_state_projection -->|"reads state"| node_tally_service
node_state_projection -->|"uses mappings"| node_mapping_api
node_server -->|"routes mapping requests"| node_mapping_api
node_mapping_api -->|"persists mappings"| node_config_store
node_server -->|"connects and disconnects"| node_tally_service
node_server -->|"loads and saves IP"| node_config_store
node_tally_service -->|"registers events"| node_atem_library
node_atem_library -->|"communicates with"| node_switcher
node_config_store -->|"reads and writes"| node_config_file

click node_admin_ui "https://github.com/dark-li/bmd_webtally/blob/main/static/app.js"
click node_admin_page "https://github.com/dark-li/bmd_webtally/blob/main/templates/index.html"
click node_client_ui "https://github.com/dark-li/bmd_webtally/blob/main/static/client.js"
click node_client_page "https://github.com/dark-li/bmd_webtally/blob/main/templates/client.html"
click node_server "https://github.com/dark-li/bmd_webtally/blob/main/app/main.py"
click node_state_projection "https://github.com/dark-li/bmd_webtally/blob/main/app/main.py"
click node_mapping_api "https://github.com/dark-li/bmd_webtally/blob/main/app/main.py"
click node_tally_service "https://github.com/dark-li/bmd_webtally/blob/main/app/atem_service.py"
click node_config_store "https://github.com/dark-li/bmd_webtally/blob/main/app/config_store.py"
click node_config_file "https://github.com/dark-li/bmd_webtally/blob/main/data/config.json"

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_admin_ui,node_admin_page,node_client_ui,node_client_page toneBlue
class node_server,node_state_projection,node_mapping_api toneAmber
class node_tally_service toneMint
class node_config_store,node_config_file toneRose
class node_operator,node_camera_operator,node_switcher,node_atem_library toneIndigo
```

## Components

### Web interface

- [Tally management UI](https://github.com/dark-li/bmd_webtally/blob/main/static/app.js): `static/app.js`
- [Management page](https://github.com/dark-li/bmd_webtally/blob/main/templates/index.html): `templates/index.html`
- [Client lamp UI](https://github.com/dark-li/bmd_webtally/blob/main/static/client.js): `static/client.js`
- [Client page](https://github.com/dark-li/bmd_webtally/blob/main/templates/client.html): `templates/client.html`

### Application server

- [FastAPI routes](https://github.com/dark-li/bmd_webtally/blob/main/app/main.py): `app/main.py`
- [Mapped client state](https://github.com/dark-li/bmd_webtally/blob/main/app/main.py): `app/main.py`
- [Mapping management](https://github.com/dark-li/bmd_webtally/blob/main/app/main.py): `app/main.py`

### ATEM tally

- [ATEM state service](https://github.com/dark-li/bmd_webtally/blob/main/app/atem_service.py): `app/atem_service.py`

### Configuration

- [Config store](https://github.com/dark-li/bmd_webtally/blob/main/app/config_store.py): `app/config_store.py`
- [JSON configuration](https://github.com/dark-li/bmd_webtally/blob/main/data/config.json): `data/config.json`

### Other components

- **Operator**
- **Camera operator**
- **ATEM switcher**
- **PyATEMMax**

## Connections

- Operator → Tally management UI: configures (evidence: `README.md`)
- Tally management UI → FastAPI routes: sends API requests (evidence: `static/app.js`)
- Tally management UI → FastAPI routes: receives live state (evidence: `static/app.js`)
- FastAPI routes → Management page: renders (evidence: `app/main.py`)
- FastAPI routes → Client page: renders (evidence: `app/main.py`)
- Camera operator → Client lamp UI: views tally (evidence: `README.md`)
- Client lamp UI → FastAPI routes: requests client state (evidence: `static/client.js`)
- Client lamp UI → FastAPI routes: receives live state (evidence: `static/client.js`)
- FastAPI routes → Mapped client state: builds payload (evidence: `app/main.py`)
- Mapped client state → ATEM state service: reads state (evidence: `app/main.py`)
- Mapped client state → Mapping management: uses mappings (evidence: `app/main.py`)
- FastAPI routes → Mapping management: routes mapping requests (evidence: `app/main.py`)
- Mapping management → Config store: persists mappings (evidence: `app/main.py`)
- FastAPI routes → ATEM state service: connects and disconnects (evidence: `app/main.py`)
- FastAPI routes → Config store: loads and saves IP (evidence: `app/main.py`)
- ATEM state service → PyATEMMax: registers events (evidence: `app/atem_service.py`)
- PyATEMMax → ATEM switcher: communicates with (evidence: `README.md`)
- Config store → JSON configuration: reads and writes (evidence: `app/config_store.py`)
