Skip to content

Commit fcdb70f

Browse files
committed
update docs
1 parent 5c1059a commit fcdb70f

33 files changed

Lines changed: 1313 additions & 717 deletions

‎docs/_config.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ color_scheme: bug
66
description: Broadcast Universal Gateway
77
show_downloads: true
88

9-
footer_content: "BUG was created in <a href='https://bbc.co.uk/news'>BBC News</a>, by <a href='https://github.com/geoffhouse'>Geoff House</a> and <a href='https://github.com/ryanmccartney'>Ryan McCartney</a>."
9+
footer_content: "BUG was created at the <a href='https://bbc.co.uk/'>BBC</a>, by <a href='https://github.com/geoffhouse'>Geoff House</a> and <a href='https://github.com/ryanmccartney'>Ryan McCartney</a>."
1010
last_edit_timestamp: true
1111
last_edit_time_format: "%b %e %Y at %I:%M %p"
1212

‎docs/_includes/head_custom.html‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,5 @@
11
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" />
2+
<script type="module">
3+
import mermaid from 'https://cdn.jsdelivr.net/npm/mermaid@10/dist/mermaid.esm.min.mjs';
4+
mermaid.initialize({ startOnLoad: true });
5+
</script>
Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
<div class="site-footer">
22
<p>
3-
<a href="https://github.com/bbc/bug" title="GitHub"
4-
><i style="font-size: 2.5em !important" class="fa fa-github"></i
5-
></a>
3+
<a href="https://github.com/bbc/bug" title="GitHub"><i style="font-size: 2.5em !important"
4+
class="fa fa-github"></i></a>
65
</p>
76
<p>
8-
BUG was created in <a href="https://bbc.co.uk/news">BBC News</a>, by
7+
BUG was created at the <a href="https://bbc.co.uk/">BBC</a>, by
98
<a href="https://github.com/geoffhouse">Geoff House</a> and
109
<a href="https://github.com/ryanmccartney">Ryan McCartney</a>.
1110
</p>
12-
</div>
11+
</div>

‎docs/index.md‎

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,29 +8,38 @@ nav_order: 1
88

99
**Broadcast Universal Gateway**
1010

11-
[![Backend](https://github.com/bbc/bug/actions/workflows/backend.yml/badge.svg)](https://github.com/bbc/bug/actions/workflows/backend.yml) [![Frontend](https://github.com/bbc/bug/actions/workflows/frontend.yml/badge.svg)](https://github.com/bbc/bug/actions/workflows/frontend.yml) [![BUG Deploy](https://github.com/bbc/bug/actions/workflows/docker.yml/badge.svg)](https://github.com/bbc/bug/actions/workflows/docker.yml) [![Documentation](https://github.com/bbc/bug/actions/workflows/documentation.yml/badge.svg)](https://github.com/bbc/bug/actions/workflows/documentation.yml)
11+
[![BUG Deploy](https://github.com/bbc/bug/actions/workflows/deploy.yml/badge.svg)](https://github.com/bbc/bug/actions/workflows/deploy.yml)
12+
[![Documentation](https://github.com/bbc/bug/actions/workflows/documentation.yml/badge.svg)](https://github.com/bbc/bug/actions/workflows/documentation.yml)
1213

13-
Control and monitor a wide range of equipment from a single web interface.
14+
BUG is a web-based system for **controlling and monitoring broadcast and media equipment from a single interface**.
1415

15-
You can run BUG on a server within your network. A single web page then allows you to add panels that control equipment. Examples include, network switches, video and audio codecs, video matrixes and many more.
16+
Run BUG on a server within your network and access it through a browser. From one web page, you can add panels to control and observe a wide range of devices and services — including network switches, video and audio codecs, video matrices, and more.
1617

1718
![BUG Home Screenshot](/bug/assets/images/screenshots/bug-home.png)
1819

19-
# Getting Started
20+
## Getting started
2021

21-
- [Installation](./pages/installation) - Installation guide for any operating system
22-
- [Modules](./pages/modules) - A list of equipment that can be controlled and implemented functionality
22+
- [Installation](./pages/installation) — Install BUG on any supported operating system
23+
- [Modules](./pages/modules) — See which devices and services can be controlled, and what functionality is available
2324

24-
# Development
25+
## Development
2526

26-
We welcome [development](./pages/development) of additional modules for BUG. A module adds additional control or monitoring functionality to BUG. In principle a module normally represents control of a specific piece of hardware or a service. For example a single module exists to control Blackmagic Videohub matrices and another modules to monitor and report on a NewTek NDI discovery service.
27+
BUG is designed to be extended. We welcome [development](./pages/development) of additional modules that add new control or monitoring capabilities.
2728

28-
An instance of a module is a panel. Multiple panels of the same type can co-exist in BUG. Learn more about [developing](./pages/development) your own below;
29+
A **module** typically represents a specific piece of hardware or service. For example:
30+
31+
- a module for controlling Blackmagic Videohub matrices
32+
- a module for monitoring a NewTek NDI discovery service
33+
34+
Each module can be instantiated one or more times as **panels** within the BUG interface, allowing multiple devices of the same type to be controlled simultaneously.
35+
36+
To learn more about developing your own modules, see:
2937

3038
- [Architecture](./pages/architecture.html)
31-
- [Project Layout](./pages/development/layout.html)
32-
- [Coding Style](./pages/development/style.html)
39+
- [Project layout](./pages/development/layout.html)
40+
- [Coding style](./pages/development/style.html)
3341

34-
# Open Source
42+
## Open source
3543

36-
BUG is just one of many Open Source projects at the BBC. Check out the full catalog - [https://www.bbc.co.uk/opensource/](https://www.bbc.co.uk/opensource/).
44+
BUG is one of many open source projects developed at the BBC.
45+
Explore the full catalogue at [https://www.bbc.co.uk/opensource/](https://www.bbc.co.uk/opensource/).

‎docs/pages/architecture.md‎

Lines changed: 43 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -7,68 +7,76 @@ has_children: false
77

88
# Architecture
99

10-
BUG makes a few underlying assumptions built into its architecture that will guide you in developing modules for it. A module's backend exists within its own docker container. The frontend is loaded by BUG core
10+
BUG is built around a modular, containerized architecture designed to simplify control and monitoring of broadcast equipment. Understanding the assumptions and principles of this architecture is important when developing new modules.
1111

12-
BUG runs entirely in Docker. It can be run locally, but this is designed for development purposes only.
12+
## Core Principles
1313

14-
BUG is made up of a number of containers. Every BUG instance will have at least the following containers
14+
- Each module is self-contained: one module per function.
15+
- Modules are designed to be independent but can interact via APIs if needed.
16+
- Focus on simplicity: aim to implement ~80% of a device’s functionality.
17+
- BUG is mobile-first: UI components are designed to scale across screen sizes.
18+
- Performance matters: consider the load on devices and frequency of data polling.
19+
- Modules run in Docker containers, isolating their backend logic from the core system.
20+
- Module memory is volatile: any temporary data should not be relied upon for persistent state.
1521

16-
- BUG Core
17-
- Mongo
22+
## Containers Overview
1823

19-
![Architecture Overview](/bug/assets/diagrams/architecture-overview.drawio.svg)
20-
21-
In development an additional module
22-
23-
- Mongo Express
24+
Every BUG instance includes at minimum:
2425

25-
Each module is then allocated its own container, an isolated environment to carry out backend monitoring, control and data acquisition functions associated with controlling broadcast infrastructure.
26+
- BUG Core – serves the frontend UI, manages configuration, and orchestrates modules.
27+
- Mongo – stores persistent configuration and module data.
2628

27-
# Principles
29+
![Architecture Overview](/bug/assets/diagrams/architecture-overview.drawio.svg)
2830

29-
- [Overview ](/bug/pages/architecture/overview.html)
31+
In development environments, additional containers such as Mongo Express may be present for easier inspection of the database.
3032

31-
* Mobile first
32-
* It's not mission critical
33-
* 80% of the functionality of any device.
34-
* Keep it simple
35-
* Keep it self-contained
36-
* One module per function
37-
* Connect modules (videohub) but don't depend
38-
* Consider performance
39-
* Consider load on device
40-
* Consider connections to device
33+
Each module is allocated its own container, which provides:
4134

42-
---
35+
- Isolated environment for backend logic
36+
- Data acquisition and monitoring for connected devices
37+
- REST APIs and WebSocket endpoints for communication with the core
4338

4439
## Panel Communication
4540

4641
![Panel Communication](/bug/assets/diagrams/panel-communication.drawio.svg)
4742

48-
## Panel Config
43+
Panels communicate only with the BUG Core API. Workers within module containers fetch data directly from devices or external services and write to the module’s Mongo database. The frontend reads data from the BUG Core, not directly from devices or module containers.
4944

50-
Configs contain panel configurations. This configuration is stored in BUG core and pushed to panels on either start or update.
45+
### Key Points
5146

52-
Each module is responsible for providing a base config page accessible in the module router from;
47+
- Workers handle device communication asynchronously.
48+
- The frontend interacts only with BUG Core, not module containers.
49+
- Central Mongo databases are per-panel and facilitate sharing data between workers.
50+
- NodeCache or other local caches can be used within containers for temporary data.
5351

54-
`/config`
52+
## Module Configuration
5553

56-
Any config input or form should be wrapped in a PanelConfig component with a save button.
54+
Panel configuration is persistent and stored in BUG Core. Module containers receive their configuration when started or updated.
55+
56+
- Each module should provide a base config page accessible at `/config`.
57+
- Config forms should use the `PanelConfig` component to ensure consistent behavior:
5758

5859
```
59-
<PanelConfig>
6060
61+
<PanelConfig>
62+
<!-- form fields -->
6163
</PanelConfig>
6264
```
6365

64-
The API route `/api/panel/config/${panelId}` uses the HTTP action PUT and accepts a config object. Any valid fields are MERGED with the existing config. Any invalid fields are ignored. ??? Should we check and passed config against the `module.json` deafulConfig ???
66+
- The API route `/api/panel/config/${panelId}` accepts a PUT request with a config object.
67+
- Valid fields are merged with existing configuration; invalid fields are ignored.
68+
- Field validation is the responsibility of the module developer.
6569

66-
Responsibility for validating fields rests with the module developer.
70+
Persistent configuration includes things like IP addresses, credentials, or default module options. Temporary runtime data should be stored in the module’s container database or cache.
6771

6872
## Module Memory is Volatile
6973

70-
Anything created in a module's container during operation should not be viewed as persistent. While it is true that this data in fact persists for as long as the container does you should design modules in such a way that operation could continue without this data.
74+
Anything stored in a module’s container during runtime should not be considered permanent. Containers can be restarted, rebuilt, or removed at any time.
7175

72-
Leading on from this configuration that should persist is managed and stored by BUG core and passed to the container when it is created, started or changes are made to the config in BUG core.
76+
- Design modules to function correctly even if runtime data is lost.
77+
- Persistent config should always be stored in BUG Core and passed to the module container.
78+
- Use the panel-specific Mongo database for temporary or frequently-updated data.
79+
80+
---
7381

74-
Each module has access to a mongo database named as the panel ID that can be used as desired by the module developer. It functions in a similar way to a cache facilitating the sharing of data between workers.
82+
This architecture ensures that BUG remains scalable, modular, and resilient while providing clear boundaries between persistent configuration, frontend UI, and module runtime logic.

‎docs/pages/development/capabilities.md‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,16 @@ parent: Development
55
nav_order: 2
66
---
77

8-
# Development - Module Capabilities
8+
# Module capabilities
99

10-
Each module type can support one or more capabilities. These are standardised API endpoints to allow data flow between modules.
10+
Modules can expose one or more **capabilities**.
11+
A capability is a **standardised API endpoint** that allows data to be shared between modules in a consistent way.
12+
13+
Capabilities make it possible for modules to consume information provided by other modules without needing to know their internal implementation.
1114

1215
## dhcp-server
1316

14-
This capability is used primary for network routers which provide DHCP servers. It can be used to provide 'friendly' names in other modules when only the IP address is known.
17+
This capability is used primary for network routers which provide DHCP servers. It can be used to provide 'friendly' names in other modules when only the MAC or IP address is known.
1518

1619
`/container/{panelid}/capabilities/dhcp-server/`
1720

‎docs/pages/development/docker.md‎

Lines changed: 39 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,30 +7,56 @@ nav_order: 10
77

88
# Docker and BUG
99

10-
BUG's main application runs in a docker container, it speaks to a separate database in a separate container.
11-
When you start a panel the main BUG application will build a docker container and launch it on your system and then speak to it via an API.
12-
This enables BUG to perform very different monitoring and control tasks without continually adjusting the core BUG code.
10+
BUG runs its main application in a **Docker container**, with a separate container for its database.
11+
When you start a panel, the core BUG application **builds and launches a dedicated container** for that panel, then communicates with it via an API.
1312

14-
Below we've gathered a few helpful terminal commands that'll help you work with the docker cli and debug inside a panel's container.
13+
This containerised architecture allows BUG to handle a wide variety of monitoring and control tasks **without modifying the core application code**. It also allows individual panels to be restarted independently of each other and the core services.
14+
15+
Below are some useful Docker commands to help you **monitor, debug, and manage BUG containers**.
16+
17+
---
1518

1619
## Checking BUG status
1720

18-
Verify your containers are running using the `docker ps` command.
21+
Use the following command to see which containers are running:
22+
23+
```bash
24+
docker ps
25+
```
26+
27+
Find the one named `bug` and make sure it's not in a `restarting` mode.
28+
To look at the logs (terminal) of the core container use:
29+
30+
```bash
31+
docker logs bug
32+
```
1933

2034
## Check individual container outputs
2135

22-
To look at the logs (terminal) of the core container use;
36+
All running panels will have a relevant docker container, identifiable by their panel id. This is the same as the one shown when you navigate to the panel in the Web UI.
37+
38+
To view the logs of a particular panel:
39+
40+
```bash
41+
docker logs yourlongpanelid
42+
```
43+
44+
## BUG system actions
2345

24-
`docker logs bug_app`
46+
To perform any of these actions, navigate to the installation folder containing the `docker-compose.yml` file (usually `/opt/bug`).
2547

26-
Where `bug_app` is the name of the container that can be seen from `docker ps`. You could also add a panel id here to view a panel's terminal output
48+
### Stop BUG
2749

28-
## Stop BUG
50+
To stop all BUG services and containers
2951

30-
To stop the bug, all it's services and containers use;
52+
```
53+
docker compose down --remove-orphans
54+
```
3155

32-
`docker compose down --remove-orphans`
56+
### Start BUG
3357

34-
## Detaching from the Terminal
58+
This will start the BUG core web service and database, but not any previously-built individual panel containers. You'll have to enable these in the BUG UI.
3559

36-
Using the flag `-d` with docker-compose detaches the container output stream from the terminal
60+
```
61+
docker compose up -d
62+
```

‎docs/pages/development/error-handling.md‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,23 @@ router.get(
2121
);
2222
```
2323

24-
Then in services - we should log and throw:
24+
Any error thrown inside the async function will automatically be passed to Express’s error handler.
25+
26+
# Throwing errors in services
27+
28+
Inside module services, log the error and then throw a new one.
29+
This ensures it’s visible in logs and propagated to the router:
2530

2631
```
32+
try {
33+
await buildModule(moduleName);
2734
} catch (error) {
2835
logger.warn(`module-build: ${error.stack || error.trace || error || error.message}`);
2936
throw new Error(`Failed to build module ${moduleName}`);
3037
}
3138
```
3239

33-
Inside a service, if you want to stop execution because a step has failed, use:
40+
If a step fails and you want to stop execution immediately, simply throw an error:
3441

3542
```
3643
throw new Error(`Failed to write dockerfile to '${modulePath}'`);

‎docs/pages/development/fetching-data.md‎

Lines changed: 0 additions & 13 deletions
This file was deleted.

‎docs/pages/development/layout.md‎

Lines changed: 36 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -5,35 +5,47 @@ parent: Development
55
nav_order: 2
66
---
77

8-
BUG's project structure is documented here - what types of files are in each folder. What there general functions are and in some case what is passed to and from the functions they contain.
8+
# Project Layout
99

10-
## /src/routes
10+
This page describes the structure of the BUG project, the purpose of each major folder under `src/`, and how responsibilities are separated across the codebase. BUG’s source is organised to keep frontend, backend, and modules clear and maintainable.
1111

12-
- should contain route logic
13-
- if request params are needed, they should be extracted and passed from here
14-
- no req or resp should be passed to services
15-
- should return http error codes if problem
16-
- no logging?
12+
---
13+
14+
## `/src/client`
15+
16+
- Contains the **frontend application** for BUG.
17+
- UI code for rendering panels, controls, dashboards, and views.
18+
- Communicates with the backend using REST APIs and modules.
19+
- Includes React component logic and assets.
20+
21+
---
22+
23+
## `/src/modulebuilder`
1724

18-
## /src/services
25+
- Contains code responsible for **creating and managing module scaffolding**.
26+
- Includes templates or builders that generate module structures.
27+
- Used internally when generating new modules or updating existing ones.
28+
- Handles registration and initialization of modules with the server.
1929

20-
- one file for each service 'user', 'config', 'docker'
21-
- lots of business logic
22-
- can combine results from multiple sources
23-
- or just direct model
24-
- may well be complex
30+
---
31+
32+
## `/src/modules`
33+
34+
- Contains the implementations of all available module types.
35+
- Each module type contains a `client` and `container` folder:
36+
- `client` files are bundled into the main UI build.
37+
- `container` files are used to build the Docker image that runs when a panel is created for this module type.
38+
- Each Docker container runs a web service exposing its own API endpoints.
39+
- You can define any endpoints; however, a few endpoints are **mandatory** (`/api/status`, `/api/config`).
2540

26-
## /src/models
41+
---
42+
43+
## `/src/server`
2744

28-
- read a file, access a db, save a file etc
29-
- divided up by logical group, but includes all CRUD for that thing
30-
- no business logic - access only
45+
- Contains the Node.js code and runs an Express.js server for the main BUG backend application.
46+
- Provides the API for the user interface and manages panel lifecycle via Docker.
47+
- Loads modules, orchestrates their lifecycle, and configures middleware, error handling, and global services.
3148

32-
## /src/modules
49+
---
3350

34-
- the following api endpoints should be defined:
35-
> - /api/status - returns an array including:
36-
> - state: 'starting', 'ready', 'failed'
37-
> - /api/config - should be able to receive a config object and save it locally
38-
> - module logging should be to console only
39-
> - module APIs must follow JSON output standard (status, data, error)
51+
This layout keeps BUG **organized and modular**, separating frontend UI, backend API layers, and module logic for easier maintenance and scalable development.

0 commit comments

Comments
 (0)