# kmesfor/skylink architecture

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

- Interactive diagram: https://gitdiagram.com/kmesfor/skylink
- Repository: https://github.com/kmesfor/skylink

## Overview

##### Project type and purpose
- Skylink is a C++ full-stack desktop application (no web layer) that helps users plan optimal airline routes.
- It consists of:
- A data-processing “graph generator” that ingests raw CSVs → builds a JSON adjacency-list graph.
- A backend of graph datamodels and pathfinding algorithms (Dijkstra, A*) that query that JSON graph.
- A custom SFML-based frontend/UI for user interaction and graph visualization.
- Unit tests for algorithm correctness.

##### File structure
Top-level directories/files:
- CMakeLists.txt / .gitignore / main.cpp – build & entrypoint
- dist – shipping folder with raw CSVs, generated JSON, and final executables
- src/backend – graph generator, datamodels, algorithms, data manager
- src/frontend – custom SFML UI (windows, components, visualization)
- test – Catch2 unit tests for algorithms
- resources – third-party JSON library, documentation
Patterns and components:
- Graph-generator module (src/backend/graph-generator)
- Algorithms module (src/backend/algorithms)
- Datamodel module (src/backend/datamodels)
- DataManager (handles JSON I/O)
- Frontend: WindowManager, UI components, GraphVisualization
- Build scripts & external deps: CMake, SFML, nlohmann/json, Catch2

##### README for additional insights
- Confirms JSON graph file as persistent storage.
- Describes how to generate vs. copy the JSON.
- Notes tech stack: C++17, CMake, SFML, Catch2, nlohmann/json.

a. Main components
1. Raw Data Storage (dist/data/raw CSV files)
2. Graph Generator (executable GenerateGraphFiles)
3. Generated Graph Storage (skylinkgraph.json)
4. Backend Engine
– DataManager
– Datamodels (Airport, Route, Graph)
– Algorithms (Dijkstra, A*)
– AlgorithmComparator
5. Frontend UI
– WindowManager & Windows (Primary, Result)
– UI Components (Button, Textbox)
– GraphVisualization Module
6. Unit Test Suite (Catch2 tests for A*, Dijkstra, comparator)
7. Build & Deployment (CMake, CLion, dist folder)
8. External Libraries (SFML, nlohmann/json, Catch2)
b. Relationships & interactions
- Raw CSV files → (Graph Generator) → JSON graph
- Frontend instantiates DataManager → loads JSON graph
- Frontend issues user queries (origin/destination) → calls Backend Engine
- Backend Engine uses Datamodels + Algorithms → produces AlgorithmResult
- Frontend GraphVisualization renders the result graph and statistics
- Tests isolate Algorithms & Comparator—no UI involvement
- CMake orchestrates build of Generator, Skylink executable, and Tests
c. Architectural patterns & design principles
- Layered architecture: Data layer (CSV/JSON), Backend logic, Presentation/UI
- Separation of concerns: graph generation vs. runtime pathfinding vs. UI
- Modular algorithms: each algorithm implements a common interface (Algorithm.h)
- MVC-like pattern in UI: WindowManager & windows = controller/view; GraphVisualization = view; DataManager/backend = model
- Dependency injection of DataManager & Algorithm implementations
d. Key technologies/frameworks
- C++17, CMake (build & dependency fetch)
- nlohmann/json (JSON serialization)
- SFML (UI rendering, events)
- Catch2 (unit testing)

##### Detail
- Every sub-module: AlgorithmComparator, AStar, Dijkstra, WindowManager, GraphVisualization, etc.
- Data formats (e.g., “CSV → JSON”) and file locations (dist/data/raw, dist/data/generated)

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Data Layer
    subgraph "Data Layer"
        direction TB
        RAW_CSV(["Raw CSV Files"]):::data
        GRAPH_GEN[/GenerateGraphFiles.exe/]:::data
        JSON_GRAPH[(skylinkgraph.json)]:::data
    end

    RAW_CSV -->|"ingests CSV"| GRAPH_GEN
    GRAPH_GEN -->|"produces JSON"| JSON_GRAPH

    %% Backend Layer
    subgraph "Backend Layer"
        direction TB
        DATAMANAGER["DataManager"]:::backend
        subgraph "Datamodels"
            direction TB
            AIRPORT["Airport"]:::backend
            AIRPORT_ROUTE["AirportRoute"]:::backend
            SKYLINK_GRAPH["SkylinkGraph"]:::backend
            ALGO_RESULT["AlgorithmResult"]:::backend
            FLIGHT_STATS["FlightRouteStatistics"]:::backend
            WEIGHT_TYPE["WeightType"]:::backend
        end
        subgraph "Algorithms"
            direction TB
            ALGO_IFACE["Algorithm (interface)"]:::backend
            DIJKSTRA["Dijkstra"]:::backend
            ASTAR["AStar"]:::backend
        end
        ALGO_COMP["AlgorithmComparator"]:::backend
    end

    JSON_GRAPH -->|"loads JSON"| DATAMANAGER
    DATAMANAGER -->|"provides data to"| ALGO_IFACE
    ALGO_IFACE -->|"implemented by"| DIJKSTRA
    ALGO_IFACE -->|"implemented by"| ASTAR
    DIJKSTRA -->|"yields results"| ALGO_RESULT
    ASTAR -->|"yields results"| ALGO_RESULT
    ALGO_RESULT -->|"compared by"| ALGO_COMP

    %% Frontend Layer
    subgraph "Frontend Layer"
        direction TB
        SKYLINK_EXE[/Skylink.exe/]:::frontend
        FW_MANAGER["WindowManager"]:::frontend
        subgraph "UI Components"
            direction TB
            BUTTON["Button"]:::frontend
            TEXTBOX["Textbox"]:::frontend
        end
        subgraph "Windows"
            direction TB
            PRIMARY_WIN["PrimaryWindow"]:::frontend
            RESULT_WIN["ResultWindow"]:::frontend
        end
        GVIS[/GraphVisualization/Module/]:::frontend
    end

    SKYLINK_EXE -->|"uses"| DATAMANAGER
    SKYLINK_EXE -->|"calls"| ALGO_COMP
    SKYLINK_EXE -->|"manages UI"| FW_MANAGER
    FW_MANAGER -->|"opens"| PRIMARY_WIN
    FW_MANAGER -->|"opens"| RESULT_WIN
    PRIMARY_WIN -->|"contains"| BUTTON
    PRIMARY_WIN -->|"contains"| TEXTBOX
    RESULT_WIN -->|"renders"| GVIS
    GVIS -->|"visualizes"| ALGO_RESULT

    %% Build & Test Infrastructure
    subgraph "Build & Test" 
        direction TB
        CMAKE["CMakeLists.txt"]:::infra
        MAIN_CPP["main.cpp"]:::infra
        GITIGNORE[".gitignore"]:::infra
        subgraph "Unit Tests"
            direction TB
            TEST_AST["test_astar.cpp"]:::infra
            TEST_DJ["test_dijkstra.cpp"]:::infra
            TEST_COMP["test_comparator.cpp"]:::infra
        end
    end

    CMAKE -->|builds| GRAPH_GEN
    CMAKE -->|builds| SKYLINK_EXE
    CMAKE -->|builds| TEST_AST
    CMAKE -->|builds| TEST_DJ
    CMAKE -->|builds| TEST_COMP
    TEST_AST -.->|tests| ASTAR
    TEST_DJ -.->|tests| DIJKSTRA
    TEST_COMP -.->|tests| ALGO_COMP

    %% External Libraries
    subgraph "External Libraries"
        direction TB
        SFML["SFML"]:::infra
        JSON_LIB["nlohmann/json"]:::infra
        CATCH2["Catch2"]:::infra
    end

    SFML --> FW_MANAGER
    JSON_LIB --> DATAMANAGER
    CATCH2 --> TEST_AST

    %% Click Events
    click RAW_CSV "https://github.com/kmesfor/skylink/tree/main/dist/data/raw"
    click JSON_GRAPH "https://github.com/kmesfor/skylink/blob/main/dist/data/generated/skylinkgraph.json"
    click GRAPH_GEN "https://github.com/kmesfor/skylink/blob/main/src/backend/graph-generator/GenerateGraphFiles.cpp"
    click LoadAirportCodes "https://github.com/kmesfor/skylink/blob/main/src/backend/graph-generator/LoadAirportCodes.h"
    click LoadAirportRoutes "https://github.com/kmesfor/skylink/blob/main/src/backend/graph-generator/LoadAirportRoutes.h"
    click AddAirportLocationData "https://github.com/kmesfor/skylink/blob/main/src/backend/graph-generator/AddAirportLocationData.h"
    click DeleteDisconnectedRoutes "https://github.com/kmesfor/skylink/blob/main/src/backend/graph-generator/DeleteDisconnectedRoutes.h"
    click DATAMANAGER "https://github.com/kmesfor/skylink/blob/main/src/backend/DataManager.h"
    click AIRPORT "https://github.com/kmesfor/skylink/blob/main/src/backend/datamodels/Airport.h"
    click AIRPORT_ROUTE "https://github.com/kmesfor/skylink/blob/main/src/backend/datamodels/AirportRoute.h"
    click SKYLINK_GRAPH "https://github.com/kmesfor/skylink/blob/main/src/backend/datamodels/SkylinkGraph.h"
    click ALGO_RESULT "https://github.com/kmesfor/skylink/blob/main/src/backend/datamodels/AlgorithmResult.h"
    click FLIGHT_STATS "https://github.com/kmesfor/skylink/blob/main/src/backend/datamodels/FlightRouteStatistics.h"
    click WEIGHT_TYPE "https://github.com/kmesfor/skylink/blob/main/src/backend/datamodels/WeightType.h"
    click ALGO_IFACE "https://github.com/kmesfor/skylink/blob/main/src/backend/algorithms/Algorithm.h"
    click DIJKSTRA "https://github.com/kmesfor/skylink/blob/main/src/backend/algorithms/Dijkstra.h"
    click ASTAR "https://github.com/kmesfor/skylink/blob/main/src/backend/algorithms/AStar.h"
    click ALGO_COMP "https://github.com/kmesfor/skylink/blob/main/src/backend/AlgorithmComparator.h"
    click SKYLINK_EXE "https://github.com/kmesfor/skylink/blob/main/src/frontend/frontend.cpp"
    click FW_MANAGER "https://github.com/kmesfor/skylink/blob/main/src/frontend/window/WindowManager.h"
    click BUTTON "https://github.com/kmesfor/skylink/blob/main/src/frontend/window/components/Button.h"
    click TEXTBOX "https://github.com/kmesfor/skylink/blob/main/src/frontend/window/components/Textbox.h"
    click PRIMARY_WIN "https://github.com/kmesfor/skylink/blob/main/src/frontend/window/windows/PrimaryWindow.h"
    click RESULT_WIN "https://github.com/kmesfor/skylink/blob/main/src/frontend/window/windows/ResultWindow.h"
    click GVIS "https://github.com/kmesfor/skylink/blob/main/src/frontend/graph-visualization/GraphVisualization.cpp"
    click TEST_AST "https://github.com/kmesfor/skylink/blob/main/test/test_astar.cpp"
    click TEST_DJ "https://github.com/kmesfor/skylink/blob/main/test/test_dijkstra.cpp"
    click TEST_COMP "https://github.com/kmesfor/skylink/blob/main/test/test_comparator.cpp"
    click CMAKE "https://github.com/kmesfor/skylink/blob/main/CMakeLists.txt"
    click MAIN_CPP "https://github.com/kmesfor/skylink/blob/main/src/main.cpp"
    click GITIGNORE "https://github.com/kmesfor/skylink/blob/main/.gitignore"
    click JSON_LIB "https://github.com/kmesfor/skylink/blob/main/resources/json.hpp"
    click SFML "https://github.com/kmesfor/skylink/blob/main/resources/MARKDOWN.md"

    %% Styles
    classDef data fill:#D3E5FF,stroke:#333,stroke-width:1px
    classDef backend fill:#D3FFD3,stroke:#333,stroke-width:1px
    classDef frontend fill:#FFD8A8,stroke:#333,stroke-width:1px
    classDef infra fill:#E0E0E0,stroke:#333,stroke-width:1px
```
