# jordanepeer/flight-ai-super-resilient-system architecture

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

- Interactive diagram: https://gitdiagram.com/jordanepeer/flight-ai-super-resilient-system
- Repository: https://github.com/jordanepeer/flight-ai-super-resilient-system

## Overview

##### Project Type and Purpose
- This is a full-stack research dashboard (“Flight-AI-Super-Resilient-System”) whose goal is to inject control-parameters into Microsoft Flight Simulator (MSFS) via SimConnect, collect flight telemetry, store it, and run offline ML/analytics to predict whether a flight will reach its destination.

##### File Structure Analysis
- Top-level directory “MSFS_UseCase_Control_Dashboard” holds:
- SimConnect/… – a Python package wrapping the MSFS SimConnect API.
- server.py & Server_Description.py – the backend web server and its documentation.
- Templates/ + static/ – a Flask (or similar) templating layer and accompanying CSS/JS for the browser-based dashboard.
- Analytics/ – standalone Python scripts for data sampling, transformation, plotting, and populating the SQLite database with “bad flights.”
- DataBase.db & DataBase.sql – the SQLite persistence layer.
- requirements.txt – lists Python dependencies.

##### README Insights
- Confirms the system uses parameter injection into MSFS, logging via SimConnect, and ML model evaluation to classify flight outcomes.

##### Main Components
a. External Service:
– MS Flight Simulator (MSFS)
b. Adapter Layer:
– SimConnect Python package (Attributes, Constants, RequestList, etc.)
c. Backend Server:
– server.py (Flask or FastAPI)
– Business logic that:
- Initiates connections to MSFS via SimConnect
- Receives telemetry/events
- Reads/writes to the SQLite Database
- Exposes REST/WebSocket APIs to the front end
d. Database:
– SQLite (DataBase.db) – stores raw telemetry and “bad flight” records
e. Frontend Dashboard:
– HTML templates (index.html)
– CSS (styles.css, Styles_Description.css)
– JavaScript (app.js, App_Description.js)
– Renders real-time telemetry, classification results, and control widgets
f. Analytics & ML Pipeline (Offline):
– Python scripts in Analytics/ – perform latin-square sampling, CSV transforms, plotting, and database seeding
– ML models (assumed to be imported/trained via these scripts)

##### Relationships and Data Flows
1. MSFS → SimConnect Adapter → Backend Server
2. Backend Server ↔ SQLite Database
3. Backend Server → Frontend Dashboard (via REST/WebSocket)
4. Analytics Scripts → SQLite Database (read/write)
5. Analytics Scripts ↔ ML Models → Database (optional)

##### Architectural Patterns & Design Principles
- Layered architecture: External simulator → Adapter → Business logic → Persistence → Presentation
- Separation of concerns: Adapter isolates MSFS API; server handles HTTP and data orchestration; analytics is an offline batch process
- MVC-like pattern in the web app: Templates (View), server.py (Controller), Database (Model)

##### Technologies & Frameworks to Call Out
- Python 3.x
- Flask (or equivalent) for server.py
- SimConnect Python package
- SQLite for embedded storage
- HTML/CSS/JavaScript for dashboard UI
- Matplotlib/pandas (implied in plot_points.py, movetocsv.py) for analytics

## Diagram (Mermaid)

```mermaid
graph TB
    %% External System
    MSFS["MS Flight Simulator"]:::external

    %% Adapter Layer
    subgraph "SimConnect Adapter"
        direction TB
        Attr["Attributes.py"]:::adapter
        Const["Constants.py"]:::adapter
        Enum["Enum.py"]:::adapter
        EventList["EventList.py"]:::adapter
        Facilities["FacilitiesList.py"]:::adapter
        RequestList["RequestList.py"]:::adapter
        SimConnectPy["SimConnect.py"]:::adapter
        Init["__init__.py"]:::adapter
    end

    %% Backend Server
    subgraph "Backend Server"
        direction TB
        Server["server.py"]:::backend
        ServerDesc["Server_Description.py"]:::backend
    end

    %% Database
    DB[(SQLite Database)]:::database

    %% Frontend Dashboard
    subgraph "Frontend Dashboard"
        direction TB
        Templates["index.html<br/>Index_Description.html"]:::frontend
        CSS["styles.css<br/>Styles_Description.css"]:::frontend
        JS["app.js<br/>App_Description.js"]:::frontend
        Img["static/img/"]:::frontend
    end

    %% Analytics & ML Pipeline
    subgraph "Analytics & ML Pipeline"
        direction TB
        DBTest[/Database Test.py/]:::analytics
        AddBad[/add_bad_flights_to_db.py/]:::analytics
        CreateBad[/create_bad_flights.py/]:::analytics
        Latin[/latinSquareSampler.py/]:::analytics
        Transform[/transform_csv.py/]:::analytics
        MoveCSV[/movetocsv.py/]:::analytics
        Plot[/plot_points.py/]:::analytics
    end

    %% Data Flows
    MSFS -->|"MSFS API Calls"| SimConnectPy
    SimConnectPy -->|“Telemetry & Events”| Server
    Server -->|"SQL INSERT/SELECT"| DB
    Server -->|"JSON over WebSocket/REST"| Templates
    Server -->|"JSON over WebSocket/REST"| JS
    Templates -->|“renders UI”| JS
    JS -->|"updates UI"| Templates
    DBTest -->|"SQL INSERT/SELECT"| DB
    AddBad -->|"SQL INSERT"| DB
    CreateBad -->|"SQL INSERT"| DB
    Latin -->|"CSV EXPORT"| Transform
    Transform -->|"CSV IMPORT"| DB
    MoveCSV -->|"CSV EXPORT"| DB
    Plot -->|"reads CSV"| DB

    %% Click Events
    click Attr "https://github.com/jordanepeer/flight-ai-super-resilient-system/blob/main/MSFS_UseCase_Control_Dashboard/SimConnect/Attributes.py"
    click Const "https://github.com/jordanepeer/flight-ai-super-resilient-system/blob/main/MSFS_UseCase_Control_Dashboard/SimConnect/Constants.py"
    click Enum "https://github.com/jordanepeer/flight-ai-super-resilient-system/blob/main/MSFS_UseCase_Control_Dashboard/SimConnect/Enum.py"
    click EventList "https://github.com/jordanepeer/flight-ai-super-resilient-system/blob/main/MSFS_UseCase_Control_Dashboard/SimConnect/EventList.py"
    click Facilities "https://github.com/jordanepeer/flight-ai-super-resilient-system/blob/main/MSFS_UseCase_Control_Dashboard/SimConnect/FacilitiesList.py"
    click RequestList "https://github.com/jordanepeer/flight-ai-super-resilient-system/blob/main/MSFS_UseCase_Control_Dashboard/SimConnect/RequestList.py"
    click SimConnectPy "https://github.com/jordanepeer/flight-ai-super-resilient-system/blob/main/MSFS_UseCase_Control_Dashboard/SimConnect/SimConnect.py"
    click Init "https://github.com/jordanepeer/flight-ai-super-resilient-system/blob/main/MSFS_UseCase_Control_Dashboard/SimConnect/__init__.py"

    click Server "https://github.com/jordanepeer/flight-ai-super-resilient-system/blob/main/MSFS_UseCase_Control_Dashboard/server.py"
    click ServerDesc "https://github.com/jordanepeer/flight-ai-super-resilient-system/blob/main/MSFS_UseCase_Control_Dashboard/Server_Description.py"

    click DB "https://github.com/jordanepeer/flight-ai-super-resilient-system/blob/main/MSFS_UseCase_Control_Dashboard/DataBase.db"
    click DB "https://github.com/jordanepeer/flight-ai-super-resilient-system/blob/main/MSFS_UseCase_Control_Dashboard/DataBase.sql"

    click Templates "https://github.com/jordanepeer/flight-ai-super-resilient-system/blob/main/MSFS_UseCase_Control_Dashboard/Templates/index.html"
    click Templates "https://github.com/jordanepeer/flight-ai-super-resilient-system/blob/main/MSFS_UseCase_Control_Dashboard/Templates/Index_Description.html"
    click CSS "https://github.com/jordanepeer/flight-ai-super-resilient-system/blob/main/MSFS_UseCase_Control_Dashboard/static/css/styles.css"
    click CSS "https://github.com/jordanepeer/flight-ai-super-resilient-system/blob/main/MSFS_UseCase_Control_Dashboard/static/css/Styles_Description.css"
    click JS "https://github.com/jordanepeer/flight-ai-super-resilient-system/blob/main/MSFS_UseCase_Control_Dashboard/static/js/app.js"
    click JS "https://github.com/jordanepeer/flight-ai-super-resilient-system/blob/main/MSFS_UseCase_Control_Dashboard/static/js/App_Description.js"
    click Img "https://github.com/jordanepeer/flight-ai-super-resilient-system/tree/main/MSFS_UseCase_Control_Dashboard/static/img/"

    click DBTest "https://github.com/jordanepeer/flight-ai-super-resilient-system/blob/main/MSFS_UseCase_Control_Dashboard/Analytics/Database Test.py"
    click AddBad "https://github.com/jordanepeer/flight-ai-super-resilient-system/blob/main/MSFS_UseCase_Control_Dashboard/Analytics/add_bad_flights_to_db.py"
    click CreateBad "https://github.com/jordanepeer/flight-ai-super-resilient-system/blob/main/MSFS_UseCase_Control_Dashboard/Analytics/create_bad_flights.py"
    click Latin "https://github.com/jordanepeer/flight-ai-super-resilient-system/blob/main/MSFS_UseCase_Control_Dashboard/Analytics/latinSquareSampler.py"
    click Transform "https://github.com/jordanepeer/flight-ai-super-resilient-system/blob/main/MSFS_UseCase_Control_Dashboard/Analytics/transform_csv.py"
    click MoveCSV "https://github.com/jordanepeer/flight-ai-super-resilient-system/blob/main/MSFS_UseCase_Control_Dashboard/Analytics/movetocsv.py"
    click Plot "https://github.com/jordanepeer/flight-ai-super-resilient-system/blob/main/MSFS_UseCase_Control_Dashboard/Analytics/plot_points.py"

    %% Styles
    classDef external fill:#E0F7FA,stroke:#00838F,color:#006064,stroke-width:2px;
    classDef adapter fill:#E3F2FD,stroke:#1E88E5,color:#0D47A1,stroke-width:2px;
    classDef backend fill:#E8F5E9,stroke:#43A047,color:#1B5E20,stroke-width:2px;
    classDef database fill:#F3E5F5,stroke:#8E24AA,color:#4A148C,stroke-width:2px;
    classDef frontend fill:#FFF3E0,stroke:#FB8C00,color:#E65100,stroke-width:2px;
    classDef analytics fill:#FCE4EC,stroke:#D81B60,color:#880E4F,stroke-width:2px;
```
