# aryanambre77/distance-calculator architecture

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

- Interactive diagram: https://gitdiagram.com/aryanambre77/distance-calculator
- Repository: https://github.com/aryanambre77/distance-calculator

## Overview

##### Project type and purpose
- This is a small command‐line (CLI) Python utility whose purpose is to calculate distances (aerial and road) between two user‐specified locations and estimate travel time (ETA) based on a selected transport mode. It integrates with the MapQuest geocoding API to retrieve coordinates.

##### File structure
- Top level:
- README.md – describes project, dependencies, usage
- project.py – likely the main entry point, handles I/O, API calls, ties modules together
- time cal.py – contains the ETA calculation logic (speeds, time computations)
- No separate “src” or “lib” folders; instead flat structure with two Python scripts.
- No database or web server components.

##### README for additional insights
- Describes use of Haversine formula for aerial distance, then a simple formula for road distance (aerial × 1.3).
- Lists transport modes (Walk, Motorcycle, Car, Train, Aeroplane) & their average speeds.
- Notes reliance on MapQuest API (requires API key) and lack of exception handling.

a. Main Components
1. User Interface (CLI) – prompts user, reads input (origin, destination, mode)
2. Geocoding Module – issues HTTP requests to MapQuest API, parses JSON to get lat/lon
3. Distance Calculation Module – implements Haversine formula and road‐distance adjustment
4. ETA Calculation Module – uses selected mode’s speed to compute travel time
5. Output Module – formats and displays results to the console
6. External Service – MapQuest API
b. Component Interactions
- CLI → Geocoding Module: send location strings
- Geocoding Module → MapQuest API: REST call, receive coordinates
- Geocoding Module → CLI and Distance Module: return lat/lon
- Distance Module → CLI and ETA Module: return aerial & road distances
- CLI → ETA Module: supply chosen mode and distance
- ETA Module → CLI: return travel time
- CLI → User: display distance & ETA
c. Architectural patterns / design principles
– Separation of concerns: I/O (CLI), external integration, pure computation (distance & time)
– Single responsibility: each script/module does one logical task
d. Technologies / frameworks
– Python 3.x
– requests (or urllib) for HTTP calls to MapQuest
– Math module for Haversine formula
– Standard library for CLI I/O

1. Sketch a left‐to‐right flow:
[User] → (1) [CLI I/O] → (2) [Geocoding Module] → (3) {MapQuest API}
← coordinates ←                ↑
→ (4) [Distance Module] → distances →
↓
(5) [ETA Module] → time →
↓
(6) [CLI I/O] → [User]
5. Key formulas (e.g., Haversine formula, road = 1.3 × aerial, ETA = distance ÷ speed).

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% User Interface
    CLI_IO["CLI I/O"]:::io
    Output["Output Module"]:::io

    %% Computation Modules
    Geocoding["Geocoding Module"]:::compute
    Distance_Calc["Distance Calculation Module"]:::compute
    ETA_Calc["ETA Calculation Module"]:::compute

    %% External Service
    MapQuestAPI["MapQuest API"]:::external

    %% Documentation
    README["Project Documentation"]:::doc

    %% Flow
    CLI_IO -->|"location strings"| Geocoding
    Geocoding -->|"REST call"| MapQuestAPI
    MapQuestAPI -->|"coordinates JSON"| Geocoding
    Geocoding -->|"lat/lon"| Distance_Calc
    Distance_Calc -->|"aerial & road distances"| CLI_IO
    Distance_Calc -->|"distances"| ETA_Calc
    CLI_IO -->|"mode & distance"| ETA_Calc
    ETA_Calc -->|"travel time"| CLI_IO
    CLI_IO -->|"display results"| Output

    %% Click Events
    click CLI_IO "https://github.com/aryanambre77/distance-calculator/blob/main/project.py"
    click Geocoding "https://github.com/aryanambre77/distance-calculator/blob/main/project.py"
    click Distance_Calc "https://github.com/aryanambre77/distance-calculator/blob/main/project.py"
    click Output "https://github.com/aryanambre77/distance-calculator/blob/main/project.py"
    click ETA_Calc "https://github.com/aryanambre77/distance-calculator/blob/main/time cal.py"
    click README "https://github.com/aryanambre77/distance-calculator/blob/main/README.md"

    %% Styles
    classDef io fill:#ADD8E6,stroke:#000000,stroke-width:1px
    classDef compute fill:#90EE90,stroke:#000000,stroke-width:1px
    classDef external fill:#FFA500,stroke:#000000,stroke-width:1px
    classDef doc fill:#D3D3D3,stroke:#000000,stroke-width:1px
```
