# gaurav0502/us-domestic-flights architecture

> Architecture diagram of the GitHub repository gaurav0502/us-domestic-flights, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/gaurav0502/us-domestic-flights
- Repository: https://github.com/gaurav0502/us-domestic-flights

## Overview

##### Project Type and Purpose
- The project is a data analysis/reporting application focused on analyzing the on-time performance of NYC domestic flights in 2023. It uses R (via scripts in the data directory), Quarto (.qmd files), and JavaScript (for interactive visualizations) to process data, analyze delay factors, and present results in an online book.
- Key objectives include investigating delay reasons, geospatial patterns, and time-series patterns.

##### Key Components of the System
a. Data Acquisition & Preprocessing
- Data Collection and Raw Data Handling: In the /data directory you see scripts like rawdata.R and rawdata.sh that likely fetch and import data via the anyflights package.
- Data Consolidation: The file consolidate.R in /data is responsible for cleaning and combining data sources.
- Supplementary Data: The interactive CSV files (e.g., data/interactive/delayfactors.csv) are used for further analysis or visualizations.

b. Data Analysis and Reporting
- Analysis Scripts and Notebooks: Quarto markdown (.qmd) files (such as data.qmd, d3graph.qmd, index.qmd, results.qmd, conclusion.qmd) are used to integrate code, visualization, and narrative.
- Rendered Output: The /docs directory contains the final HTML outputs (like docs/index.html, docs/results.html, etc.) along with supportive assets, indicating the final report is presented as a rendered book.

c. Visualization & Interactive Components
- D3 Interactive Graph: The existence of d3graph.qmd and corresponding HTML output (docs/d3graph.html) suggest the use of interactive visualizations.
- JavaScript Assets: Files like scripts/myscript.js in both the root /scripts and /docs/scripts directories (with additional libraries under docs/site_libs) indicate that interactive visual components (possibly leveraging D3 and Quarto’s integration) are part of the system.

##### Architectural Relationships and Data Flow
- Data Flow: The raw data is collected (via scripts in /data), then transformed (consolidate.R) into usable formats and further analyzed in the Quarto documents.
- Analysis Integration: The analysis components (spread across multiple .qmd files) combine narrative commentary with code that accesses processed data to produce visualizations and results.
- Rendering Pipeline: Quarto rendering uses configuration (e.g., _quarto.yml) to generate the final book output, placing HTML files and supporting libraries in the /docs directory.
- Interactivity: Interactive visualizations are handled by JavaScript in the docs and scripts folders, with D3-specific files indicating additional dynamic behavior integrated into the reporting layer.

##### Important Architectural Patterns and Design Principles
- Separation of Concerns: The project clearly separates data handling (/data) from presentation (/docs & .qmd files) and interactive components (/scripts and docs/site_libs).
- Reproducible Analysis: The use of Quarto documents indicates that the same source files are responsible for both analysis and rendering, ensuring traceability.
- Modularity: Different functionalities (data acquisition, analysis, interactive visualization) are isolated in distinct directories, promoting maintainability.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Data Ingestion & Processing Layer
    subgraph "Data Ingestion & Processing"
        RDA["Raw Data Acquisition (rawdata.R, rawdata.sh)"]:::data
        DC["Data Consolidation (consolidate.R)"]:::data
        SD["Supplementary Data (delayfactors.csv)"]:::data
    end

    %% Analysis and Reporting Layer
    subgraph "Analysis and Reporting"
        QE["Quarto Engine (_quarto.yml)"]:::analysis
        QD["Quarto Documents (index.qmd, data.qmd, results.qmd, conclusion.qmd, d3graph.qmd)"]:::analysis
    end

    %% Presentation and Interactivity Layer
    subgraph "Presentation and Interactivity"
        RO["Rendered Output (index.html, data.html, results.html, conclusion.html, d3graph.html)"]:::presentation
        JS["JavaScript Assets (myscript.js)"]:::presentation
    end

    %% Data Flow
    RDA -->|"processes"| DC
    DC -->|"feeds"| QE
    SD -->|"supplies"| QE
    QE -->|"orchestrates"| QD
    QD -->|"renders to"| RO
    RO -->|"enhanced by"| JS

    %% Click Events for Data Acquisition & Preprocessing
    click RDA "https://github.com/gaurav0502/us-domestic-flights/blob/main/data/rawdata.R"
    click RDA "https://github.com/gaurav0502/us-domestic-flights/blob/main/data/rawdata.sh"
    click DC "https://github.com/gaurav0502/us-domestic-flights/blob/main/data/consolidate.R"
    click SD "https://github.com/gaurav0502/us-domestic-flights/blob/main/data/interactive/delayfactors.csv"

    %% Click Events for Data Analysis and Reporting
    click QD "https://github.com/gaurav0502/us-domestic-flights/blob/main/index.qmd"
    click QD "https://github.com/gaurav0502/us-domestic-flights/blob/main/data.qmd"
    click QD "https://github.com/gaurav0502/us-domestic-flights/blob/main/results.qmd"
    click QD "https://github.com/gaurav0502/us-domestic-flights/blob/main/conclusion.qmd"
    click QD "https://github.com/gaurav0502/us-domestic-flights/blob/main/d3graph.qmd"

    %% Click Events for Rendered Output
    click RO "https://github.com/gaurav0502/us-domestic-flights/blob/main/docs/index.html"
    click RO "https://github.com/gaurav0502/us-domestic-flights/blob/main/docs/data.html"
    click RO "https://github.com/gaurav0502/us-domestic-flights/blob/main/docs/results.html"
    click RO "https://github.com/gaurav0502/us-domestic-flights/blob/main/docs/conclusion.html"
    click RO "https://github.com/gaurav0502/us-domestic-flights/blob/main/docs/d3graph.html"

    %% Click Events for JavaScript Assets
    click JS "https://github.com/gaurav0502/us-domestic-flights/blob/main/scripts/myscript.js"
    click JS "https://github.com/gaurav0502/us-domestic-flights/blob/main/docs/scripts/myscript.js"

    %% Styles
    classDef data fill:#FFF3C4,stroke:#ED8936,stroke-width:2px;
    classDef analysis fill:#C6F6D5,stroke:#4FD1C5,stroke-width:2px;
    classDef presentation fill:#BEE3F8,stroke:#4299E1,stroke-width:2px;
```
