# jorge-sarmiento/mena-nowcasting architecture

> Architecture diagram of the GitHub repository jorge-sarmiento/mena-nowcasting, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-18). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/jorge-sarmiento/mena-nowcasting
- Repository: https://github.com/jorge-sarmiento/mena-nowcasting

## Overview

MENA Nowcasting Engine estimates quarterly GDP growth for Saudi Arabia and the UAE from high-frequency financial and alternative indicators. The principal workflow runs from a country-level request through indicator ingestion, feature preparation and model forecasts to expanding-window evaluation, statistical validation and nowcasts. The README also documents optional structural-shock robustness runs and six formal validation tests. Edges reflect the excerpts, SOURCE INDEX references or README; unsampled implementation details are not inferred.

Main entry points: [`main.py`](https://github.com/jorge-sarmiento/mena-nowcasting/blob/main/main.py) (Run orchestration), [`src/config.py`](https://github.com/jorge-sarmiento/mena-nowcasting/blob/main/src/config.py) (Country configuration), [`src/data_loader.py`](https://github.com/jorge-sarmiento/mena-nowcasting/blob/main/src/data_loader.py) (Market data ingestion), [`src/google_trends.py`](https://github.com/jorge-sarmiento/mena-nowcasting/blob/main/src/google_trends.py) (Google Trends loader)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_orchestration["Run orchestration"]
  node_runner["Run orchestration<br/>[main.py]"]
  node_config["Country configuration<br/>[config.py]"]
  node_extension["Shock extension<br/>[main.py]"]
end

subgraph group_indicators["Indicator preparation"]
  node_ingest["Market data ingestion<br/>[data_loader.py]"]
  node_trends["Google Trends loader<br/>[google_trends.py]"]
  node_features["Feature engineering<br/>[features.py]"]
  node_alignment["Lead-lag alignment<br/>[utils.py]"]
  node_cycle["Cycle extraction<br/>[filters.py]"]
end

subgraph group_forecasting["Forecasting"]
  node_gdp[("GDP ground truth<br/>[validation.py]")]
  node_models["Five-model forecasts<br/>[models.py]"]
end

subgraph group_assessment["Validation and diagnostics"]
  node_evaluation["Expanding-window evaluation<br/>[validation.py]"]
  node_tests["Statistical tests<br/>[validation.py]"]
  node_diagnostics["Integration diagnostics"]
end

node_user(("Analyst"))
node_yahoo(("Yahoo Finance"))
node_google(("Google Trends service"))

node_user -->|"starts run"| node_runner
node_runner -->|"reads settings"| node_config
node_runner -->|"loads indicators"| node_ingest
node_runner -->|"uses features"| node_features
node_runner -->|"aligns indicators"| node_alignment
node_runner -.->|"uses cycles"| node_cycle
node_runner -->|"gets GDP"| node_gdp
node_runner -->|"runs models"| node_models
node_runner -->|"evaluates forecasts"| node_evaluation
node_runner -->|"runs tests"| node_tests
node_runner -->|"enables extension"| node_extension
node_ingest -->|"reads tickers"| node_config
node_ingest -->|"downloads prices"| node_yahoo
node_ingest -->|"fetches sentiment"| node_trends
node_trends -->|"queries trends"| node_google
node_trends -->|"reads settings"| node_config
node_alignment -->|"reads lead limit"| node_config
node_cycle -->|"reads filter settings"| node_config
node_runner -.->|"runs separately"| node_diagnostics
node_diagnostics -->|"uses loaded data"| node_ingest
node_diagnostics -->|"reads settings"| node_config

click node_runner "https://github.com/jorge-sarmiento/mena-nowcasting/blob/main/main.py"
click node_config "https://github.com/jorge-sarmiento/mena-nowcasting/blob/main/src/config.py"
click node_extension "https://github.com/jorge-sarmiento/mena-nowcasting/blob/main/main.py"
click node_ingest "https://github.com/jorge-sarmiento/mena-nowcasting/blob/main/src/data_loader.py"
click node_trends "https://github.com/jorge-sarmiento/mena-nowcasting/blob/main/src/google_trends.py"
click node_features "https://github.com/jorge-sarmiento/mena-nowcasting/blob/main/src/features.py"
click node_alignment "https://github.com/jorge-sarmiento/mena-nowcasting/blob/main/src/utils.py"
click node_cycle "https://github.com/jorge-sarmiento/mena-nowcasting/blob/main/src/filters.py"
click node_gdp "https://github.com/jorge-sarmiento/mena-nowcasting/blob/main/src/validation.py"
click node_models "https://github.com/jorge-sarmiento/mena-nowcasting/blob/main/src/models.py"
click node_evaluation "https://github.com/jorge-sarmiento/mena-nowcasting/blob/main/src/validation.py"
click node_tests "https://github.com/jorge-sarmiento/mena-nowcasting/blob/main/src/validation.py"
click node_diagnostics "https://github.com/jorge-sarmiento/mena-nowcasting/blob/main/integration_diagnostics.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_runner,node_config,node_extension toneBlue
class node_ingest,node_trends,node_features,node_alignment,node_cycle toneAmber
class node_gdp,node_models toneMint
class node_evaluation,node_tests,node_diagnostics toneRose
class node_user,node_yahoo,node_google toneIndigo
```

## Components

### Run orchestration

- [Run orchestration](https://github.com/jorge-sarmiento/mena-nowcasting/blob/main/main.py): `main.py`
- [Country configuration](https://github.com/jorge-sarmiento/mena-nowcasting/blob/main/src/config.py): `src/config.py`
- [Shock extension](https://github.com/jorge-sarmiento/mena-nowcasting/blob/main/main.py): `main.py`

### Indicator preparation

- [Market data ingestion](https://github.com/jorge-sarmiento/mena-nowcasting/blob/main/src/data_loader.py): `src/data_loader.py`
- [Google Trends loader](https://github.com/jorge-sarmiento/mena-nowcasting/blob/main/src/google_trends.py): `src/google_trends.py`
- [Feature engineering](https://github.com/jorge-sarmiento/mena-nowcasting/blob/main/src/features.py): `src/features.py`
- [Lead-lag alignment](https://github.com/jorge-sarmiento/mena-nowcasting/blob/main/src/utils.py): `src/utils.py`
- [Cycle extraction](https://github.com/jorge-sarmiento/mena-nowcasting/blob/main/src/filters.py): `src/filters.py`

### Forecasting

- [GDP ground truth](https://github.com/jorge-sarmiento/mena-nowcasting/blob/main/src/validation.py): `src/validation.py`
- [Five-model forecasts](https://github.com/jorge-sarmiento/mena-nowcasting/blob/main/src/models.py): `src/models.py`

### Validation and diagnostics

- [Expanding-window evaluation](https://github.com/jorge-sarmiento/mena-nowcasting/blob/main/src/validation.py): `src/validation.py`
- [Statistical tests](https://github.com/jorge-sarmiento/mena-nowcasting/blob/main/src/validation.py): `src/validation.py`
- [Integration diagnostics](https://github.com/jorge-sarmiento/mena-nowcasting/blob/main/integration_diagnostics.py): `integration_diagnostics.py`

### Other components

- **Analyst**
- **Yahoo Finance**
- **Google Trends service**

## Connections

- Analyst → Run orchestration: starts run (evidence: `README.md`)
- Run orchestration → Country configuration: reads settings (evidence: `main.py`)
- Run orchestration → Market data ingestion: loads indicators (evidence: `main.py`)
- Run orchestration → Feature engineering: uses features (evidence: `main.py`)
- Run orchestration → Lead-lag alignment: aligns indicators (evidence: `main.py`)
- Run orchestration → Cycle extraction: uses cycles
- Run orchestration → GDP ground truth: gets GDP (evidence: `main.py`)
- Run orchestration → Five-model forecasts: runs models (evidence: `main.py`)
- Run orchestration → Expanding-window evaluation: evaluates forecasts (evidence: `main.py`)
- Run orchestration → Statistical tests: runs tests (evidence: `README.md`)
- Run orchestration → Shock extension: enables extension (evidence: `README.md`)
- Market data ingestion → Country configuration: reads tickers (evidence: `src/data_loader.py`)
- Market data ingestion → Yahoo Finance: downloads prices (evidence: `src/data_loader.py`)
- Market data ingestion → Google Trends loader: fetches sentiment (evidence: `src/data_loader.py`)
- Google Trends loader → Google Trends service: queries trends (evidence: `src/google_trends.py`)
- Google Trends loader → Country configuration: reads settings (evidence: `src/google_trends.py`)
- Lead-lag alignment → Country configuration: reads lead limit (evidence: `src/utils.py`)
- Cycle extraction → Country configuration: reads filter settings (evidence: `src/filters.py`)
- Run orchestration → Integration diagnostics: runs separately
- Integration diagnostics → Market data ingestion: uses loaded data (evidence: `integration_diagnostics.py`)
- Integration diagnostics → Country configuration: reads settings (evidence: `integration_diagnostics.py`)
