# nachetyson/mario_examen2 architecture

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

- Interactive diagram: https://gitdiagram.com/nachetyson/mario_examen2
- Repository: https://github.com/nachetyson/mario_examen2

## Overview

##### Project Type and Purpose
- This is a full-stack web application whose goal is to predict European flight durations using real-time meteorological data.
- Frontend: single-page interactive map (Leaflet.js + Tailwind CSS + JavaScript).
- Backend: Flask (Python) serving HTML and JSON APIs, performing data retrieval (OurAirports CSV via pandas), weather lookups (Open-Meteo API via requests), Haversine distance and flight-time calculations.

##### File Structure Analysis
- Top-level Python scripts:
- AirportsEurope_FTbyAircraft.py – likely contains logic for flight time calculation by aircraft type.
- AirportsEurope_FlightTime.py – likely contains distance & weather-adjusted duration logic.
- README.md – project description, instructions, architecture overview.
- requirement.txt – lists flask, pandas, requests.
- FlighWithMe.jfif – logo or UI placeholder.
- No separate “frontend” or “templates” folder: the HTML/JS is embedded in the Flask script (`app.py` or equivalent).

##### Architecture Insights from README
- Client-Server pattern: SPA served by Flask.
- API Endpoints:
/           → serves the single HTML_TEMPLATE
/api/airports → returns JSON list of 50 top European airports
/api/weather/<iata> → returns real-time weather for one airport
/api/calculate   → computes distance + weather + aircraft type → returns flight duration
- Data Sources:
- OurAirports CSV on GitHub (download_airport_data())
- Open-Meteo API for current wind and temperature

a. Main Components
- Browser/Client UI
- Flask Web Server
- Flight-time Logic Modules (distance, aircraft adjustments)
- Airport Data Loader (pandas + CSV)
- Weather API Adapter (requests + Open-Meteo)
- External Services: GitHub CSV, Open-Meteo API
b. Relationships and Interactions
1. User interacts with UI (selects airports, aircraft type).
2. UI sends fetch requests to Flask API endpoints.
3. Flask invokes:
– Airport Data Loader for /api/airports.
– Weather API Adapter for /api/weather.
– Flight-time Logic Modules for /api/calculate.
4. Logic modules combine distance (Haversine) and weather to compute duration.
5. Flask returns JSON responses to client.
6. UI renders results on the map and result card.
c. Architectural Patterns and Principles
– Client-Server separation.
– Single-Page Application (SPA) pattern: one HTML template, asynchronous fetch calls.
– Modular backend: separate functions for data retrieval and business logic.
– Externalization: using external data sources instead of local DB.
d. Relevant Technologies and Frameworks
– Frontend: HTML, Tailwind CSS, JavaScript (ES6), Leaflet.js
– Backend: Python, Flask, pandas, requests
– External APIs: OurAirports (CSV), Open-Meteo (weather)

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "Frontend Layer"
        Browser["Browser/Client UI"]:::frontend
    end

    subgraph "Backend Layer"
        FlaskServer["Flask Web Server"]:::backend
        DataLoader["Airport Data Loader Module"]:::backend
        WeatherAdapter["Weather API Adapter Module"]:::backend
        FlightCalc["Flight-Time Calculation Module"]:::backend
        AircraftLogic["Aircraft-Specific Flight-Time Logic"]:::backend
    end

    subgraph "External Services"
        CSVService["OurAirports CSV Service"]:::external
        WeatherService["Open-Meteo API Service"]:::external
    end

    subgraph "Project Files"
        README["Project Documentation & Architecture Overview"]:::doc
        Requirements["Python Dependencies"]:::doc
        Logo["UI Logo/Placeholder"]:::doc
    end

    Browser -->|"/api/airports"| FlaskServer
    Browser -->|"/api/weather/{iata}"| FlaskServer
    Browser -->|"/api/calculate"| FlaskServer
    FlaskServer -->|"download_airport_data()"| DataLoader
    DataLoader -->|"CSV download"| CSVService
    FlaskServer -->|"get_weather()"| WeatherAdapter
    WeatherAdapter -->|"HTTP GET weather"| WeatherService
    FlaskServer -->|"calculate_duration()"| FlightCalc
    FlightCalc -->|"adjust_by_aircraft()"| AircraftLogic
    FlaskServer -->|JSON response| Browser

    classDef frontend fill:#cce5ff,stroke:#004085,color:#004085
    classDef backend fill:#d4edda,stroke:#155724,color:#155724
    classDef external fill:#fff3cd,stroke:#856404,color:#856404
    classDef doc fill:#e2e3e5,stroke:#6c757d,color:#6c757d

    click Browser "https://github.com/nachetyson/mario_examen2/blob/master/AirportsEurope_FlightTime.py"
    click FlaskServer "https://github.com/nachetyson/mario_examen2/blob/master/AirportsEurope_FlightTime.py"
    click DataLoader "https://github.com/nachetyson/mario_examen2/blob/master/AirportsEurope_FlightTime.py"
    click WeatherAdapter "https://github.com/nachetyson/mario_examen2/blob/master/AirportsEurope_FlightTime.py"
    click FlightCalc "https://github.com/nachetyson/mario_examen2/blob/master/AirportsEurope_FlightTime.py"
    click AircraftLogic "https://github.com/nachetyson/mario_examen2/blob/master/AirportsEurope_FTbyAircraft.py"
    click README "https://github.com/nachetyson/mario_examen2/blob/master/README.md"
    click Requirements "https://github.com/nachetyson/mario_examen2/blob/master/requirement.txt"
    click Logo "https://github.com/nachetyson/mario_examen2/blob/master/FlighWithMe.jfif"
```
