# anviktor2411/xp-flight-computer architecture

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

- Interactive diagram: https://gitdiagram.com/anviktor2411/xp-flight-computer
- Repository: https://github.com/anviktor2411/xp-flight-computer
- Video tour (about a minute): https://gitdiagram.com/anviktor2411/xp-flight-computer/video

## Overview

XP Flight Computer is a study-oriented flight computer for X-Plane, available as a locally served web app and as an in-simulator plugin. The main workflow is: read live simulator data, expose it to the app, identify the aircraft, and present live values or aircraft-specific performance and calculator results. The web app also provides aircraft study pages, lessons, and equation explanations; the plugin embeds shared JavaScript calculations in an X-Plane window. Edges reflect README statements or sampled/indexed references; unsampled implementation details are not inferred.

Main entry points: [`web/js/app.js`](https://github.com/anviktor2411/xp-flight-computer/blob/main/web/js/app.js) (Web app), [`xpfc.py`](https://github.com/anviktor2411/xp-flight-computer/blob/main/xpfc.py) (Local web server), [`plugin/src/plugin.cpp`](https://github.com/anviktor2411/xp-flight-computer/blob/main/plugin/src/plugin.cpp) (Plugin lifecycle), [`plugin/src/ui.cpp`](https://github.com/anviktor2411/xp-flight-computer/blob/main/plugin/src/ui.cpp) (Plugin window)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_bridge["Simulator bridge"]
  node_webserver["Local web server<br/>[xpfc.py]"]
  node_simdata["Live sim data<br/>[xpfc.py]"]
  node_runways[("Runway data<br/>[xpfc.py]")]
end

subgraph group_web["Web flight tools"]
  node_webapp["Web app<br/>[app.js]"]
  node_calculators["Calculators<br/>[calculators.js]"]
  node_calcengine["Calculation core<br/>[calc.js]"]
  node_aircraft["Aircraft profiles<br/>[aircraft.js]"]
  node_performance["Airliner performance<br/>[perf.js]"]
  node_derived["Live value derivation<br/>[derive.js]"]
end

subgraph group_learning["Study library"]
  node_study["Study topics<br/>[study.js]"]
  node_aircraftstudy["Aircraft study pages<br/>[acstudy.js]"]
  node_equations["Equation explanations<br/>[explain.js]"]
end

subgraph group_plugin["In-sim plugin"]
  node_pluginui["Plugin window<br/>[ui.cpp]"]
  node_pluginhost["Plugin lifecycle<br/>[plugin.cpp]"]
  node_jshost["JavaScript host<br/>[jshost.cpp]"]
  node_pluginjs["Plugin host API<br/>[xphost.js]"]
end

node_pilot(("Pilot"))
node_browser(("Browser"))
node_xplane["X-Plane"]
node_simulator_user(("Sim user"))

node_pilot -->|"uses"| node_browser
node_browser -->|"requests app"| node_webserver
node_webserver -->|"serves app"| node_browser
node_xplane -->|"sends live data"| node_webserver
node_webserver -->|"builds state"| node_simdata
node_webserver -->|"indexes airport data"| node_runways
node_webapp -->|"presents tools"| node_calculators
node_calculators -->|"uses calculations"| node_calcengine
node_webapp -->|"detects aircraft"| node_aircraft
node_webapp -->|"shows performance"| node_performance
node_webapp -->|"derives values"| node_derived
node_derived -->|"uses calculations"| node_calcengine
node_webapp -->|"opens library"| node_study
node_webapp -->|"opens aircraft page"| node_aircraftstudy
node_webapp -->|"explains equations"| node_equations
node_simulator_user -->|"flies aircraft"| node_xplane
node_simulator_user -->|"opens plugin"| node_pluginui
node_pluginhost -->|"initializes scripts"| node_jshost
node_pluginhost -->|"creates window"| node_pluginui
node_pluginui -->|"calls functions"| node_jshost
node_pluginhost -->|"loads host API"| node_pluginjs
node_pluginhost -->|"reads simulator"| node_xplane
node_pluginui -->|"shares calculations"| node_calcengine

click node_webserver "https://github.com/anviktor2411/xp-flight-computer/blob/main/xpfc.py"
click node_simdata "https://github.com/anviktor2411/xp-flight-computer/blob/main/xpfc.py"
click node_runways "https://github.com/anviktor2411/xp-flight-computer/blob/main/xpfc.py"
click node_webapp "https://github.com/anviktor2411/xp-flight-computer/blob/main/web/js/app.js"
click node_calculators "https://github.com/anviktor2411/xp-flight-computer/blob/main/web/js/calculators.js"
click node_calcengine "https://github.com/anviktor2411/xp-flight-computer/blob/main/web/js/calc.js"
click node_aircraft "https://github.com/anviktor2411/xp-flight-computer/blob/main/web/js/aircraft.js"
click node_performance "https://github.com/anviktor2411/xp-flight-computer/blob/main/web/js/perf.js"
click node_derived "https://github.com/anviktor2411/xp-flight-computer/blob/main/web/js/derive.js"
click node_study "https://github.com/anviktor2411/xp-flight-computer/blob/main/web/js/study.js"
click node_aircraftstudy "https://github.com/anviktor2411/xp-flight-computer/blob/main/web/js/acstudy.js"
click node_equations "https://github.com/anviktor2411/xp-flight-computer/blob/main/web/js/explain.js"
click node_pluginui "https://github.com/anviktor2411/xp-flight-computer/blob/main/plugin/src/ui.cpp"
click node_pluginhost "https://github.com/anviktor2411/xp-flight-computer/blob/main/plugin/src/plugin.cpp"
click node_jshost "https://github.com/anviktor2411/xp-flight-computer/blob/main/plugin/src/jshost.cpp"
click node_pluginjs "https://github.com/anviktor2411/xp-flight-computer/blob/main/plugin/js/xphost.js"

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_webserver,node_simdata,node_runways,node_browser,node_simulator_user toneBlue
class node_webapp,node_calculators,node_calcengine,node_aircraft,node_performance,node_derived toneAmber
class node_study,node_aircraftstudy,node_equations toneMint
class node_pluginui,node_pluginhost,node_jshost,node_pluginjs toneRose
class node_pilot,node_xplane toneIndigo
```

## Components

### Simulator bridge

- [Local web server](https://github.com/anviktor2411/xp-flight-computer/blob/main/xpfc.py): `xpfc.py`
- [Live sim data](https://github.com/anviktor2411/xp-flight-computer/blob/main/xpfc.py): `xpfc.py`
- [Runway data](https://github.com/anviktor2411/xp-flight-computer/blob/main/xpfc.py): `xpfc.py`

### Web flight tools

- [Web app](https://github.com/anviktor2411/xp-flight-computer/blob/main/web/js/app.js): `web/js/app.js`
- [Calculators](https://github.com/anviktor2411/xp-flight-computer/blob/main/web/js/calculators.js): `web/js/calculators.js`
- [Calculation core](https://github.com/anviktor2411/xp-flight-computer/blob/main/web/js/calc.js): `web/js/calc.js`
- [Aircraft profiles](https://github.com/anviktor2411/xp-flight-computer/blob/main/web/js/aircraft.js): `web/js/aircraft.js`
- [Airliner performance](https://github.com/anviktor2411/xp-flight-computer/blob/main/web/js/perf.js): `web/js/perf.js`
- [Live value derivation](https://github.com/anviktor2411/xp-flight-computer/blob/main/web/js/derive.js): `web/js/derive.js`

### Study library

- [Study topics](https://github.com/anviktor2411/xp-flight-computer/blob/main/web/js/study.js): `web/js/study.js`
- [Aircraft study pages](https://github.com/anviktor2411/xp-flight-computer/blob/main/web/js/acstudy.js): `web/js/acstudy.js`
- [Equation explanations](https://github.com/anviktor2411/xp-flight-computer/blob/main/web/js/explain.js): `web/js/explain.js`

### In-sim plugin

- [Plugin window](https://github.com/anviktor2411/xp-flight-computer/blob/main/plugin/src/ui.cpp): `plugin/src/ui.cpp`
- [Plugin lifecycle](https://github.com/anviktor2411/xp-flight-computer/blob/main/plugin/src/plugin.cpp): `plugin/src/plugin.cpp`
- [JavaScript host](https://github.com/anviktor2411/xp-flight-computer/blob/main/plugin/src/jshost.cpp): `plugin/src/jshost.cpp`
- [Plugin host API](https://github.com/anviktor2411/xp-flight-computer/blob/main/plugin/js/xphost.js): `plugin/js/xphost.js`

### Other components

- **Pilot**
- **Browser**
- **X-Plane**
- **Sim user**

## Connections

- Pilot → Browser: uses (evidence: `README.md`)
- Browser → Local web server: requests app (evidence: `README.md`)
- Local web server → Browser: serves app (evidence: `README.md`)
- X-Plane → Local web server: sends live data (evidence: `README.md`)
- Local web server → Live sim data: builds state (evidence: `xpfc.py`)
- Local web server → Runway data: indexes airport data (evidence: `README.md`)
- Web app → Calculators: presents tools (evidence: `README.md`)
- Calculators → Calculation core: uses calculations (evidence: `README.md`)
- Web app → Aircraft profiles: detects aircraft (evidence: `README.md`)
- Web app → Airliner performance: shows performance (evidence: `README.md`)
- Web app → Live value derivation: derives values (evidence: `web/js/derive.js`)
- Live value derivation → Calculation core: uses calculations (evidence: `web/js/derive.js`)
- Web app → Study topics: opens library (evidence: `README.md`)
- Web app → Aircraft study pages: opens aircraft page (evidence: `README.md`)
- Web app → Equation explanations: explains equations (evidence: `README.md`)
- Sim user → X-Plane: flies aircraft (evidence: `README.md`)
- Sim user → Plugin window: opens plugin (evidence: `README.md`)
- Plugin lifecycle → JavaScript host: initializes scripts (evidence: `plugin/src/plugin.cpp`)
- Plugin lifecycle → Plugin window: creates window (evidence: `plugin/src/plugin.cpp`)
- Plugin window → JavaScript host: calls functions (evidence: `plugin/src/ui.cpp`)
- Plugin lifecycle → Plugin host API: loads host API (evidence: `plugin/src/plugin.cpp`)
- Plugin lifecycle → X-Plane: reads simulator (evidence: `plugin/src/plugin.cpp`)
- Plugin window → Calculation core: shares calculations (evidence: `README.md`)
