# avis-drone-labs/fgcs architecture

> Architecture diagram of the GitHub repository avis-drone-labs/fgcs, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-11). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/avis-drone-labs/fgcs
- Repository: https://github.com/avis-drone-labs/fgcs

## Overview

##### Main Components
- Frontend (GUI):
- Located primarily in the “gcs” directory, it uses Electron, Vite, and React.
- Contains UI components (dashboard, telemetry, maps, graphs, settings, etc.) structured under “gcs/src/components”.
- Has configuration files like “package.json”, “vite.config.ts” and environmental variables (.env) that set the connection parameters (VITE_BACKEND_URL).
- Backend (Radio):
- Found in the “radio” directory, using Flask as the web framework and Pymavlink to handle drone communications.
- Contains a set of controllers and endpoints (under “radio/app/controllers” and “radio/app/endpoints”) for various operations (arm, flight modes, mission, etc.).
- Has utilities and tests for validating functionality.
- SITL Simulator & Docker:
- Although not a direct component in the source code, the README explains how to run a simulator (SITL) via Docker.
- This component simulates UAV behavior and can be shown as an external service with which the backend interacts over TCP (port 5760/5763).
- Supporting elements:
- Build and packaging scripts are present (“building”, “dockerfile”, and pyinstaller commands in the README) which package the backend and frontend deployments.
- Pre-commit hooks, GitHub workflows, and code style tools supporting development workflows can be noted as part of the development environment but may be optionally depicted.

##### Relationships and Interactions
- The Frontend communicates directly with the Backend using HTTP requests (using the URL specified in .env, e.g., http://127.0.0.1:4237).
- The Backend (Flask) receives these commands and interacts with the drone or simulator using the MAVLink protocol.
- The SITL Simulator (dockerized Ardupilot instance) is an external service that the backend connects to for simulation purposes.
- There are internal dependencies among various UI components (charts, maps, telemetry displays) in the frontend and among controllers/endpoints in the backend.
- The build and packaging process bridges development and deployment, bundling the backend (with PyInstaller) and frontend (with yarn build), and then integrating them into a deployable package.

##### Architectural Patterns and Design Principles
- Separation of Concerns:
- Frontend and backend are clearly separated, each with its own set of responsibilities.
- Within the frontend, components are organized by feature (dashboard, map, telemetry, etc.), suggesting an MVC-ish or component-based design.
- The backend uses a controller and endpoint pattern to handle different system operations.
- Communication Flow:
- Connection from the Flask backend to the SITL simulator (or actual drone hardware) via network protocols.
- Integration with External Systems:
- Use of Docker for simulation and how that interacts with the backend.
- Use of pre-commit hooks, testing frameworks (pytest for backend, playwright for UI), although they can be depicted as a “Development & Testing” overlay.

##### Technology and Framework Details
- Optionally, include build/packaging processes (PyInstaller for the backend and yarn build for the frontend) as part of the deployment pipeline.

## Diagram (Mermaid)

```mermaid
graph TD
    U["Desktop User"]:::user

    FE["Frontend (Electron + Vite + React)"]:::frontend
    FE_UI["UI Components"]:::frontend
    FE_pkg["package.json"]:::frontend
    FE_vite["vite.config.ts"]:::frontend

    BE["Backend (Flask + Pymavlink)"]:::backend
    BE_ctrl["Controllers"]:::backend
    BE_end["Endpoints"]:::backend

    SITL["SITL Simulator/Dockerized Ardupilot"]:::external
    SITL_docker["dockerfile"]:::external
    SITL_setup["sitl_setup/"]:::external

    BUILD["Build & Packaging Pipeline"]:::build
    BUILD_build["Build Scripts"]:::build
    BUILD_electron["Electron Builder Config"]:::build

    %% Relationships
    U -->|"UI_Interaction"| FE
    FE -->|"includes"| FE_UI
    FE -->|"includes"| FE_pkg
    FE -->|"includes"| FE_vite
    FE -->|"HTTP_API"| BE
    BE -->|"has"| BE_ctrl
    BE -->|"has"| BE_end
    BE -->|"MAVLink/TCP"| SITL
    SITL -->|"contains"| SITL_docker
    SITL -->|"contains"| SITL_setup
    BUILD -->|"packages"| BUILD_build
    BUILD -->|"packages"| BUILD_electron
    BUILD -->|"Deploys"| FE
    BUILD -->|"Deploys"| BE

    %% Click Events
    click FE "https://github.com/avis-drone-labs/fgcs/tree/main/gcs/"
    click FE_UI "https://github.com/avis-drone-labs/fgcs/tree/main/gcs/src/components"
    click FE_pkg "https://github.com/avis-drone-labs/fgcs/blob/main/gcs/package.json"
    click FE_vite "https://github.com/avis-drone-labs/fgcs/blob/main/gcs/vite.config.ts"
    click BE "https://github.com/avis-drone-labs/fgcs/tree/main/radio/"
    click BE_ctrl "https://github.com/avis-drone-labs/fgcs/tree/main/radio/app/controllers"
    click BE_end "https://github.com/avis-drone-labs/fgcs/tree/main/radio/app/endpoints"
    click SITL_docker "https://github.com/avis-drone-labs/fgcs/tree/main/dockerfile"
    click SITL_setup "https://github.com/avis-drone-labs/fgcs/tree/main/sitl_setup/"
    click BUILD_build "https://github.com/avis-drone-labs/fgcs/tree/main/building/"
    click BUILD_electron "https://github.com/avis-drone-labs/fgcs/blob/main/gcs/electron-builder.json5"

    %% Styles
    classDef user fill:#FFE4B5,stroke:#333,stroke-width:2px;
    classDef frontend fill:#ADD8E6,stroke:#333,stroke-width:2px;
    classDef backend fill:#90EE90,stroke:#333,stroke-width:2px;
    classDef external fill:#FFC0CB,stroke:#333,stroke-width:2px;
    classDef build fill:#FFFACD,stroke:#333,stroke-width:2px;
```
