# habiba-imran/vertex-voyage-sfml-based-dsa-project architecture

> Architecture diagram of the GitHub repository habiba-imran/vertex-voyage-sfml-based-dsa-project, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-06-16). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/habiba-imran/vertex-voyage-sfml-based-dsa-project
- Repository: https://github.com/habiba-imran/vertex-voyage-sfml-based-dsa-project

## Overview

##### Project Type and Purpose
- This is a standalone C++ desktop application (“VertexVoyage”) that visualizes the shortest path between Pakistani cities on a map using Dijkstra’s algorithm.
- Built on top of SFML for graphics, it provides a simple GUI for city selection, supports multiple stops, and renders the resulting path in real time.

##### File-Structure Analysis
- Top-level source files:
- main.cpp (GUI entry point, orchestrates input, graph calls, and rendering)
- inputbox.cpp/h (encapsulates user-input widgets and text matching)
- graph.cpp/h (implements graph data structures and Dijkstra’s algorithm)
- source.cpp (likely contains helper routines or additional UI logic)
- Data files:
- Secret.txt (stores weighted adjacency list – distances between cities)
- .jpg / Output-Image.jpg (background map for rendering)
- Docs:
- README.md (setup & usage)
- DSA PROJECT REPORT.docx (academic report)

##### Key Components
a. User Interface Layer
- InputBox Component: captures source, destination, and intermediate stops
- Event Handler (in main.cpp): dispatches UI events
- SFML Renderer: draws map background and path overlays
b. Algorithm Layer
- Graph Module:
- Graph Loader (reads Secret.txt into adjacency list/matrix)
- Dijkstra Engine (computes shortest path(s))
c. Data Layer
- Secret.txt (adjacency data)
- .jpg (visual asset)
d. External Dependencies
- SFML Libraries (Graphics, Window, System DLLs)

##### Interactions & Data Flow
1. Application Launch → main.cpp initializes SFML window
2. Graph Loader reads Secret.txt into Graph data structure
3. User enters cities via InputBox → Event Handler captures inputs
4. Event Handler invokes Dijkstra Engine with selected nodes
5. Dijkstra returns ordered list of coordinates (path)
6. SFML Renderer draws map.jpg, overlays path polyline, and updates screen
7. Loop back to step 3 for additional inputs or exit

##### Architectural Patterns & Principles
- Separation of Concerns:
- UI / InputBox
- Core Algorithm (Graph + Dijkstra)
- Rendering
- Data I/O
- Single Responsibility: each .cpp/.h pair has a distinct role
- Data-Driven: adjacency is loaded at runtime from external text file

##### Essential Elements
- Component names (InputBox, GraphLoader, Dijkstra Engine, SFML Renderer)
- Data files with clear labels (Secret.txt, map.jpg)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% UI Layer
    subgraph "UI Layer"
        IB["InputBox Component"]:::ui
        EH["Event Handler & SFML Init"]:::ui
    end

    %% Algorithm Layer
    subgraph "Algorithm Layer"
        GL["Graph Loader"]:::algo
        DE["Dijkstra Engine"]:::algo
    end

    %% Rendering Layer
    subgraph "Rendering Layer"
        SR["SFML Renderer"]:::ui
    end

    %% Data Layer
    subgraph "Data Layer"
        ST["Secret.txt"]:::data
        MJ["map.jpg"]:::data
    end

    %% External Dependencies
    subgraph "External Dependencies"
        SFML["SFML Libraries"]:::ext
    end

    %% Documentation
    subgraph "Documentation"
        RD["README.md"]:::doc
        AR["DSA PROJECT REPORT.docx"]:::doc
    end

    %% Connections
    EH -->|"loads adjacency"| GL
    GL -->|"AdjacencyList"| DE
    IB -->|"CityList"| EH
    EH -->|"invoke Dijkstra"| DE
    DE -->|"PathCoordinates"| SR
    SR -->|"renders with"| MJ
    GL -->|"reads data"| ST
    EH -->|"initializes window"| SFML
    SR -->|"draws via"| SFML

    %% Click Events
    click IB "https://github.com/habiba-imran/vertex-voyage-sfml-based-dsa-project/blob/main/inputbox.cpp"
    click GL "https://github.com/habiba-imran/vertex-voyage-sfml-based-dsa-project/blob/main/graph.cpp"
    click DE "https://github.com/habiba-imran/vertex-voyage-sfml-based-dsa-project/blob/main/graph.cpp"
    click EH "https://github.com/habiba-imran/vertex-voyage-sfml-based-dsa-project/blob/main/source.cpp"
    click ST "https://github.com/habiba-imran/vertex-voyage-sfml-based-dsa-project/blob/main/Secret.txt"
    click RD "https://github.com/habiba-imran/vertex-voyage-sfml-based-dsa-project/blob/main/README.md"
    click AR "https://github.com/habiba-imran/vertex-voyage-sfml-based-dsa-project/blob/main/DSA PROJECT REPORT.docx"

    %% Styles
    classDef ui fill:#AED6F1,stroke:#1F618D,color:#1B2631
    classDef algo fill:#ABEBC6,stroke:#1D8348,color:#145A32
    classDef data fill:#F9E79F,stroke:#B7950B,color:#7D6608
    classDef ext fill:#D5D8DC,stroke:#566573,color:#2C3E50
    classDef doc fill:#F5B7B1,stroke:#C0392B,color:#641E16
```
