# lokesh-reddy18/dijkstra-travel-planner architecture

> Architecture diagram of the GitHub repository lokesh-reddy18/dijkstra-travel-planner, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-07-13). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/lokesh-reddy18/dijkstra-travel-planner
- Repository: https://github.com/lokesh-reddy18/dijkstra-travel-planner

## Overview

##### Project Type and Purpose
- This is a C++ command-line travel route planner (an open-source DSA/tool project) that demonstrates Dijkstra’s algorithm.
- It reads city and route data from CSV files, builds an in-memory graph, runs shortest-path searches (fastest/cheapest), and emits an HTML file with a Leaflet/Google Maps visualization.

##### File Structure Analysis
- Top-level files:
- Main.cpp – entry point, CLI interface
- GraphFunctions.h – graph construction & Dijkstra implementation
- FileOperations.h, Parser.h – CSV parsing & file I/O utilities
- cities.csv, routes.csv – data sources
- output.html – generated visualization
- travel.make – build script
- There is a clear layering: Presentation (CLI), Infrastructure (I/O, parsing), Domain/Algorithms (graph & Dijkstra), and Output (HTML/Leaflet).

##### Key README Insights
- Uses adjacency-list graph, priority-queue (min-heap), stack for path reconstruction.
- Supports modes: plane/train/bus; cost multiplier for planes.
- Generates an HTML with embedded Leaflet map (external API).
- No persistent database—flat files only.

##### Components
- cities.csv
- routes.csv
b. Infrastructure Layer (rectangles)
- CSV Parser (Parser.h)
- FileOperations (FileOperations.h)
c. Domain & Algorithm Layer (stacked rectangles)
- Location & Route classes
- Graph Builder (adjacency list)
- Dijkstra Engine (GraphFunctions.h)
- Path Reconstructor (using stack)
d. Presentation Layer
- CLI Module (Main.cpp): user prompts, collects parameters
e. Output Layer
- HTML Generator (writes output.html, embeds Leaflet scripts)
- Leaflet / Google Maps for map tiles & visualization

##### Relationships and Data Flows
- FileOperations ↔ Parser (reads/writes)
- Graph Builder → Dijkstra Engine → Path Reconstructor
- CLI Module → (triggers) Algorithm Layer → HTML Generator
- HTML Generator → Output File → Browser + Leaflet Service

##### Architectural Patterns & Principles
- Layered Architecture: separates I/O, domain logic, UI, and external integration
- Single Responsibility: each module (parsing, graph logic, CLI, HTML gen) has its own file
- Modular Domain Model: Location and Route encapsulate data, easing graph construction
- Algorithmic Core: Dijkstra encapsulated in GraphFunctions for reusability/testing

##### Detailed Capture of Essential Elements
- Be explicit about:
- Input parameters (origin, destination, preference) flowing from CLI to Algorithm
- Graph representation structure (adjacency lists)
- Priority queue usage in Dijkstra
- Path reconstruction step
- HTML templating and Leaflet API calls

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Data Sources
    subgraph "Data Sources"
        CitiesData(("cities.csv")):::datasource
        RoutesData(("routes.csv")):::datasource
    end

    %% Infrastructure Layer
    subgraph "Infrastructure Layer"
        CSVParser["CSV Parser\n(Parser.h)"]:::infra
        FileOps["FileOperations\n(FileOperations.h)"]:::infra
        BuildScript["Makefile\n(travel.make)"]:::infra
    end

    %% Domain & Algorithm Layer
    subgraph "Domain & Algorithm Layer"
        subgraph "Domain Model"
            Location["Location\n(Location.h)"]:::domain
            Route["Route\n(Route.h)"]:::domain
        end
        subgraph "Core Algorithm"
            GraphModule["Graph Builder &\nDijkstra Engine\n(GraphFunctions.h)"]:::domain
            PathReconstructor["Path Reconstructor"]:::domain
        end
    end

    %% Presentation Layer
    subgraph "Presentation Layer"
        CLI["CLI Module\n(Main.cpp)"]:::presentation
    end

    %% Output Layer
    subgraph "Output Layer"
        HTMLGen["HTML Generator"]:::presentation
        OutputHTML(("output.html")):::artifact
    end

    %% External Service
    ExternalLeaflet["Leaflet / Google Maps"]:::external

    %% Data Flows
    CitiesData --> CSVParser
    RoutesData --> CSVParser
    FileOps --> CSVParser
    CSVParser --> FileOps
    CSVParser --> GraphModule
    GraphModule --> PathReconstructor
    CLI --> GraphModule
    CLI --> PathReconstructor
    PathReconstructor --> HTMLGen
    HTMLGen --> OutputHTML
    HTMLGen --> ExternalLeaflet

    %% Build
    BuildScript --> CLI

    %% Click Events
    click CitiesData "https://github.com/lokesh-reddy18/dijkstra-travel-planner/blob/main/cities.csv"
    click RoutesData "https://github.com/lokesh-reddy18/dijkstra-travel-planner/blob/main/routes.csv"
    click CSVParser "https://github.com/lokesh-reddy18/dijkstra-travel-planner/blob/main/Parser.h"
    click FileOps "https://github.com/lokesh-reddy18/dijkstra-travel-planner/blob/main/FileOperations.h"
    click Location "https://github.com/lokesh-reddy18/dijkstra-travel-planner/blob/main/Location.h"
    click Route "https://github.com/lokesh-reddy18/dijkstra-travel-planner/blob/main/Route.h"
    click GraphModule "https://github.com/lokesh-reddy18/dijkstra-travel-planner/blob/main/GraphFunctions.h"
    click CLI "https://github.com/lokesh-reddy18/dijkstra-travel-planner/blob/main/Main.cpp"
    click OutputHTML "https://github.com/lokesh-reddy18/dijkstra-travel-planner/blob/main/output.html"
    click BuildScript "https://github.com/lokesh-reddy18/dijkstra-travel-planner/blob/main/travel.make"

    %% Styles
    classDef datasource fill:#a2d5f2,stroke:#000,color:#000,stroke-width:1px;
    classDef infra fill:#9ecabf,stroke:#000,color:#000,stroke-width:1px;
    classDef domain fill:#b5e7a0,stroke:#000,color:#000,stroke-width:1px;
    classDef presentation fill:#ffd3b5,stroke:#000,color:#000,stroke-width:1px;
    classDef artifact fill:#f0c674,stroke:#000,color:#000,stroke-width:1px;
    classDef external fill:#d3d3d3,stroke:#000,color:#000,stroke-width:1px;
```
