# bacemkarray/great-circle-mapper architecture

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

- Interactive diagram: https://gitdiagram.com/bacemkarray/great-circle-mapper
- Repository: https://github.com/bacemkarray/great-circle-mapper

## Overview

##### Project type and purpose
- This is a single‐module, desktop GUI application written in Python.
- Purpose: Let users enter a chain of ICAO airport codes, fetch their lat/long via the `airportsdata` library, and render the great-circle flight paths on a satellite map image (Google Maps Static API) inside a Tkinter window.

##### File structure
- Top-level files only:
- `great_circle_mapper.py` – the entire application logic (UI, data fetching, map generation, rendering).
- `requirements.txt` – third-party dependencies (`airportsdata`, `requests`, `pillow`).
- `.gitignore` – standard ignore rules (e.g., `.env`).
- `README.md` – high-level overview, instructions.
- Configuration: uses a `.env` file (not checked in) to supply `MAPS_STATIC_API_KEY`.
- No separate “backend” or “service” folders—everything lives in one script.

##### Key insights from the README
- Dependencies:
- `airportsdata` (airport metadata lookup)
- `requests` (HTTP client for map image)
- `pillow` (image display)
- `tkinter` (GUI)
- Workflow:
1. Parse user’s ICAO string.
2. Look up each airport’s coordinates.
3. Build Google Maps Static API URL with markers and great circle polylines.
4. Fetch the image.
5. It in a Tkinter window via Pillow.

##### Main components
a. UI Layer (Tkinter)
- Input field for ICAO string
- Canvas or Label for displaying the map image
b. Data-Lookup Service
- `airportsdata` library
- Function to parse codes and return lat/long pairs
c. Route-Generation Logic
- Great-circle computation (either custom math or leveraging API’s path parameter)
d. API Client
- Builds the Google Static Maps URL (markers + path)
- Uses `requests` to GET the image
e. Image Renderer
- `pillow` loads the raw JPEG/PNG bytes
- Converts to a PhotoImage for Tkinter display
f. Configuration Loader
- Reads `MAPS_STATIC_API_KEY` from `.env` via `os.getenv`
g. External Services
- airportsdata (local library, but external package)
- Google Static Maps API endpoint

##### Relationships and data flow
- UI → (parse input) → Route-Generation Logic
- Route-Generation Logic → (requests coords) → Data-Lookup Service
- Data-Lookup Service → coordinates → Route-Generation Logic
- Route-Generation Logic → (build URL) → Map API Client
- API Client → (HTTP GET) → External Google Maps service → image bytes → Image Renderer
- Image Renderer → GUI canvas → UI
- Configuration Loader → provides API key to Map API Client

##### Architectural patterns & design principles
- Separation of concerns: UI vs. data lookup vs. map fetching vs. rendering
- Dependency inversion for external services (e.g., wrap `requests` in a client class to facilitate testing)
- Environment‐based configuration for keys and secrets

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "Application"
        UI["UI Layer\n(Tkinter)"] 
        DataLookup["Data-Lookup Service\n(airportsdata)"] 
        RouteGen["Route-Generation Logic"] 
        APIClient["Map API Client"] 
        Renderer["Image Renderer"] 
        Config["Configuration Loader"]
    end

    subgraph "External Services"
        ExtAirports["airportsdata\n(library)"] 
        ExtMaps["Google Static Maps API"]
    end

    Config -->|"API key"| APIClient
    UI -->|"ICAO list"| RouteGen
    RouteGen -->|"ICAO list"| DataLookup
    DataLookup -->|"coordinates"| RouteGen
    RouteGen -->|"Map URL"| APIClient
    APIClient -->|"GET request"| ExtMaps
    ExtMaps -->|"image bytes"| APIClient
    APIClient -->|"image bytes"| Renderer
    Renderer -->|"display image"| UI

    click UI "https://github.com/bacemkarray/great-circle-mapper/blob/main/great_circle_mapper.py"
    click DataLookup "https://github.com/bacemkarray/great-circle-mapper/blob/main/great_circle_mapper.py"
    click RouteGen "https://github.com/bacemkarray/great-circle-mapper/blob/main/great_circle_mapper.py"
    click APIClient "https://github.com/bacemkarray/great-circle-mapper/blob/main/great_circle_mapper.py"
    click Renderer "https://github.com/bacemkarray/great-circle-mapper/blob/main/great_circle_mapper.py"
    click Config "https://github.com/bacemkarray/great-circle-mapper/blob/main/great_circle_mapper.py"
    click Config "https://github.com/bacemkarray/great-circle-mapper/blob/main/.gitignore"
    click ExtAirports "https://github.com/bacemkarray/great-circle-mapper/blob/main/requirements.txt"
    click ExtMaps "https://github.com/bacemkarray/great-circle-mapper/blob/main/great_circle_mapper.py"

    classDef internal fill:#D6EAF8,stroke:#2980B9;
    classDef external fill:#D5F5E3,stroke:#27AE60;
    classDef config fill:#FCF3CF,stroke:#B7950B;

    class UI,DataLookup,RouteGen,APIClient,Renderer internal
    class Config config
    class ExtAirports,ExtMaps external
```
