# bigbluebutton/docker architecture

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

- Interactive diagram: https://gitdiagram.com/bigbluebutton/docker
- Repository: https://github.com/bigbluebutton/docker

## Overview

##### Project Type and Purpose

**Type:**
BigBlueButton 2.7 Docker is a **containerized deployment** of the BigBlueButton open-source video conferencing system. It leverages Docker and Docker Compose to orchestrate various services required for running BigBlueButton in a scalable and manageable manner.

**Purpose:**
The project aims to provide an easy-to-install, scalable, and feature-rich video conferencing solution that includes integrated components like Greenlight (a front-end interface), TURN server for NAT traversal, automated HTTPS certificates, and full IPv6 support. It is designed to run on major Linux distributions with specific requirements regarding RAM, networking, and system access.

##### Analyzing the File Structure

**Top-Level Directories and Files:**

- **`conf/`**: Contains configuration files for dial plans and SIP profiles.
- **`docker-compose.tmpl.yml`**: Template for Docker Compose configuration, indicating container orchestration.
- **`docs/`**: Documentation covering various aspects like NAT configurations, development guidelines, and upgrading procedures.
- **`mod/`**: Houses multiple modules, each potentially representing different services or components of the system (e.g., `nginx`, `freeswitch`, `mongo`, `webhooks`, `webrtc-sfu`).
- **`repos/`**: Contains repositories for plugins and integrations related to BigBlueButton.
- **`scripts/`**: Automation scripts for setup, upgrades, publishing, and other maintenance tasks.
- **Root Files**: Includes `.gitignore`, `CHANGELOG.md`, `LICENSE`, `README.md`, `sample.env`, etc., indicating standard project management and configuration practices.

**Patterns and Architectural Indicators:**

- **Microservices Architecture:** The presence of multiple Dockerfiles within the `mod/` directory suggests a microservices approach, where each module is a separate service/container.
- **Configuration Management:** Use of `.conf` files and Docker Compose templates indicates standardized configuration practices.
- **Automation and Scripting:** The `scripts/` directory implies automated deployment and maintenance processes.

##### Examining the README for Additional Insights

**Key Sections:**

- **Features:** Highlights the inclusion of Greenlight, TURN server, automated HTTPS, and IPv6 support.
- **Requirements:** Specifies system prerequisites, emphasizing Docker usage and network configurations.
- **Installation Steps:** Detailed instructions for setting up the environment, configuring Docker, and starting the containers.
- **Further How-To's:** Links to documentation for running behind NAT and integrating with existing web servers.

**Architectural Clues:**

- **Containerized Services:** Installation and setup involve Docker, reinforcing the microservices/containerized architecture.
- **Networking Configurations:** Emphasis on NAT and web server integration points to the importance of network management within the architecture.
- **Scalability and Extensibility:** Modular components like webhooks and webrtc-sfu suggest scalability and potential for extending functionalities.

**a. Identify the Main Components:**

- **Frontend Components:**
- **Greenlight:** The user-facing web interface for BigBlueButton.

- **Backend Services:**
- **BigBlueButton Core Services:** Including modules like `apps-akka`, `bbb-pads`, `bbb-web`, `freeswitch`, `webhooks`, `webrtc-sfu`.

- **Infrastructure Services:**
- **Nginx:** Acts as a reverse proxy and load balancer.
- **MongoDB:** Database service for storing application data.
- **Coturn:** TURN server for NAT traversal.

- **Auxiliary Services:**
- **Recordings Service:** Handles recording functionalities.
- **Periodic Tasks:** Scripts for maintenance tasks like removing old recordings.

- **External Integrations:**
- **Webhooks:** For integrating with external systems.

**b. Determine Relationships and Interactions:**

- **Data Flow:**
- **User Requests:** Flow from Greenlight through Nginx to the respective backend services.
- **Media Streams:** Managed by FreeSWITCH and WebRTC SFU for real-time communication.
- **Database Interactions:** Backend services communicate with MongoDB for data storage and retrieval.
- **TURN Services:** Facilitate media stream connections across NAT/firewall boundaries.
- **Recordings:** Backend services interact with the Recordings service to handle media recordings.

- **Service Dependencies:**
- **Nginx** depends on all backend services to route traffic appropriately.
- **Webhooks** interact with external systems based on events from BigBlueButton services.

**c. Highlight Architectural Patterns and Design Principles:**

- **Microservices Pattern:** Each module in the `mod/` directory represents a distinct service, promoting separation of concerns and scalability.
- **Containerization:** Use of Docker ensures consistency across environments and simplifies deployment.
- **Configuration as Code:** Managing configurations through files facilitates version control and reproducibility.
- **Automated Deployment:** Scripts and Docker Compose templates enable automated setup and scaling.

**d. Include Relevant Technologies, Frameworks, or Libraries:**

- **Docker & Docker Compose:** For container orchestration and service management.
- **Nginx:** As a reverse proxy and load balancer.
- **FreeSWITCH:** For handling voice/video communications.
- **MongoDB:** As the primary database.
- **Coturn:** For TURN server functionalities.
- **WebRTC SFU:** For efficient media stream management.
- **Greenlight:** Built with Ruby on Rails, serving as the frontend interface.

##### Including Essential Elements

- **Clear Labels:**
- Name each component/service accurately (e.g., Greenlight, Nginx, FreeSWITCH).

##### Emphasizing Detail and Essential Architectural Elements

- **Component Granularity:** Break down services into their individual modules to capture the full scope of the architecture.
- **Configuration Details:** Where relevant, indicate configuration files or scripts that govern service behavior.
- **Inter-Service Communication:** Clearly map out how services communicate, including protocols or APIs used.
- **Deployment Flow:** Optionally, illustrate the deployment pipeline from setup scripts to running containers.

##### Final Recommendations

- **Iterative Refinement:** Start with a high-level overview and progressively add details, refining as necessary.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend
    A["Greenlight"]:::frontend

    %% Infrastructure Services
    subgraph "Infrastructure Services"
        B["Nginx"]:::infrastructure
        C["MongoDB"]:::infrastructure
        D["Coturn"]:::infrastructure
    end

    %% Backend Services
    subgraph "Backend Services"
        E["Apps Akka"]:::backend
        F["BBB Pads"]:::backend
        G["BBB Web"]:::backend
        H["FreeSWITCH"]:::backend
        I["Webhooks"]:::backend
        J["WebRTC SFU"]:::backend
    end

    %% Auxiliary Services
    subgraph "Auxiliary Services"
        K["Recordings Service"]:::auxiliary
        L["Periodic Tasks"]:::auxiliary
    end

    %% External Systems
    subgraph "External Systems"
        M["External System"]:::external
    end

    %% Connections
    A -->|"User Requests"| B
    B -->|"Routes to"| E
    B -->|"Routes to"| F
    B -->|"Routes to"| G
    B -->|"Routes to"| H
    B -->|"Routes to"| I
    B -->|"Routes to"| J

    E -->|"Data"| C
    F -->|"Data"| C
    G -->|"Data"| C

    H -->|"Media Streams"| J
    H -->|"Media Streams"| D

    I -->|"Integrates with"| M
    J -->|"Media Streams"| D

    E -->|"Handles Recordings"| K
    F -->|"Handles Recordings"| K
    G -->|"Handles Recordings"| K
    H -->|"Handles Recordings"| K

    I -->|"Scheduled Tasks"| L

    %% Click Events
    click B "https://github.com/bigbluebutton/docker/tree/develop/mod/nginx/"
    click C "https://github.com/bigbluebutton/docker/tree/develop/mod/mongo/"
    click D "https://github.com/bigbluebutton/docker/tree/develop/mod/coturn/"
    click E "https://github.com/bigbluebutton/docker/tree/develop/mod/apps-akka/"
    click F "https://github.com/bigbluebutton/docker/tree/develop/mod/bbb-pads/"
    click G "https://github.com/bigbluebutton/docker/tree/develop/mod/bbb-web/"
    click H "https://github.com/bigbluebutton/docker/tree/develop/mod/freeswitch/"
    click I "https://github.com/bigbluebutton/docker/tree/develop/mod/webhooks/"
    click J "https://github.com/bigbluebutton/docker/tree/develop/mod/webrtc-sfu/"
    click K "https://github.com/bigbluebutton/docker/tree/develop/mod/recordings/"
    click L "https://github.com/bigbluebutton/docker/tree/develop/mod/periodic/"

    %% Styles
    classDef frontend fill:#ADD8E6,stroke:#000,stroke-width:1px
    classDef backend fill:#90EE90,stroke:#000,stroke-width:1px
    classDef infrastructure fill:#D3D3D3,stroke:#000,stroke-width:1px
    classDef auxiliary fill:#FFA500,stroke:#000,stroke-width:1px
    classDef external fill:#9370DB,stroke:#000,stroke-width:1px

    class A frontend
    class B,C,D infrastructure
    class E,F,G,H,I,J backend
    class K,L auxiliary
    class M external

    %% Legend
    subgraph Legend
        LF["■"]:::frontendLegend --> LFLabel["Frontend"]
        LB["■"]:::backendLegend --> LBLabel["Backend Services"]
        LI["■"]:::infrastructureLegend --> LILabel["Infrastructure Services"]
        LA["■"]:::auxiliaryLegend --> LALabel["Auxiliary Services"]
        LE["■"]:::externalLegend --> LELabel["External Systems"]
    end

    classDef frontendLegend fill:#ADD8E6,stroke:#000,stroke-width:1px
    classDef backendLegend fill:#90EE90,stroke:#000,stroke-width:1px
    classDef infrastructureLegend fill:#D3D3D3,stroke:#000,stroke-width:1px
    classDef auxiliaryLegend fill:#FFA500,stroke:#000,stroke-width:1px
    classDef externalLegend fill:#9370DB,stroke:#000,stroke-width:1px
```
