# samuxarick/league-tables architecture

> Architecture diagram of the GitHub repository samuxarick/league-tables, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/samuxarick/league-tables
- Repository: https://github.com/samuxarick/league-tables

## Overview

##### Main Components Structure

a) Entry Point Layer

b) League Table Categories
Create two main groupings:

##### Company Performance Tables
- Company Value Table
- Most Profitable Vehicle (Generic)

##### Infrastructure Efficiency Tables
- Rail Infrastructure
- Road Infrastructure
- Canal Infrastructure
- Airport Infrastructure

c) Vehicle-Specific Tables
- Train Profitability
- Road Vehicle Profitability
- Ship Profitability
- Aircraft Profitability

##### Component Relationships

a) Data Flow
- Main.nut → League Table Categories
- Vehicle-specific data feeding into the general "Most Profitable Vehicle" table

b) Dependencies
- How infrastructure efficiency calculations depend on both vehicle profit data and infrastructure count

##### Specific Implementation Details

Key elements:

- How each .nut file processes its specific metrics
- Input parameters and output format

b) Language Support
- A small component showing language file integration (lang/english.txt)

##### Support systems (language, info) on the side

This structure will effectively communicate how the script integrates with OpenTTD while maintaining separation of concerns between different league table implementations.

Key Relationships to Highlight:
- How vehicle profit calculations feed into both specific and general rankings
- How infrastructure metrics combine with profit data
- The centralized control flow from main.nut

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Styles
    classDef core fill:#2b4b6b,color:white
    classDef profit fill:#2d8659,color:white
    classDef infra fill:#c66a3d,color:white
    classDef support fill:#808080,color:white
    
    %% Entry Point
    Main["Main Controller"]:::core
    click Main "https://github.com/SamuXarick/League-Tables/blob/main/main.nut"
    Info["Script Info"]:::support
    click Info "https://github.com/SamuXarick/League-Tables/blob/main/info.nut"
    Lang["Language Support"]:::support
    click Lang "https://github.com/SamuXarick/League-Tables/blob/main/lang/english.txt"

    %% Main Categories
    subgraph CompanyPerformance["Company Performance Tables"]
        CompVal["Company Value Table"]:::profit
        click CompVal "https://github.com/SamuXarick/League-Tables/blob/main/company_value_table.nut"
        MostProfit["Most Profitable Vehicle"]:::profit
        click MostProfit "https://github.com/SamuXarick/League-Tables/blob/main/most_profitable_vehicle.nut"
    end

    subgraph Infrastructure["Infrastructure Efficiency Tables"]
        RailInfra["Rail Infrastructure"]:::infra
        click RailInfra "https://github.com/SamuXarick/League-Tables/blob/main/rail_infrastructure_efficiency.nut"
        RoadInfra["Road Infrastructure"]:::infra
        click RoadInfra "https://github.com/SamuXarick/League-Tables/blob/main/road_infrastructure_efficiency.nut"
        CanalInfra["Canal Infrastructure"]:::infra
        click CanalInfra "https://github.com/SamuXarick/League-Tables/blob/main/canal_infrastructure_efficiency.nut"
        AirInfra["Airport Infrastructure"]:::infra
        click AirInfra "https://github.com/SamuXarick/League-Tables/blob/main/airport_infrastructure_efficiency.nut"
    end

    subgraph VehicleProfits["Vehicle-Specific Profitability"]
        TrainProfit["Train Profitability"]:::profit
        click TrainProfit "https://github.com/SamuXarick/League-Tables/blob/main/most_profitable_train.nut"
        RoadProfit["Road Vehicle Profitability"]:::profit
        click RoadProfit "https://github.com/SamuXarick/League-Tables/blob/main/most_profitable_roadvehicle.nut"
        ShipProfit["Ship Profitability"]:::profit
        click ShipProfit "https://github.com/SamuXarick/League-Tables/blob/main/most_profitable_ship.nut"
        AirProfit["Aircraft Profitability"]:::profit
        click AirProfit "https://github.com/SamuXarick/League-Tables/blob/main/most_profitable_aircraft.nut"
    end

    %% Relationships
    Main --> CompanyPerformance
    Main --> Infrastructure
    Main --> VehicleProfits
    Info -.-> Main
    Lang -.-> Main

    TrainProfit --> MostProfit
    RoadProfit --> MostProfit
    ShipProfit --> MostProfit
    AirProfit --> MostProfit

    TrainProfit -.-> RailInfra
    RoadProfit -.-> RoadInfra
    ShipProfit -.-> CanalInfra
    AirProfit -.-> AirInfra

    %% Legend
    subgraph Legend
        CoreComp["Core Component"]:::core
        ProfitComp["Profit-Related"]:::profit
        InfraComp["Infrastructure-Related"]:::infra
        SupportComp["Support Files"]:::support
        Flow["--> Data Flow"]
        Dep["-.-> Dependency"]
    end
```
