# fredzj/rijksoverheid-opendata architecture

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

- Interactive diagram: https://gitdiagram.com/fredzj/rijksoverheid-opendata
- Repository: https://github.com/fredzj/rijksoverheid-opendata

## Overview

##### Main Components
- Configurations – The “config” folder contains the db.ini file (holding database credentials).
- Database – The “database” directory provides SQL schema files that initialize tables needed by the application.
- Import Jobs – The “jobs” directory includes PHP scripts (importSchoolHolidays.php and importTravelAdvice.php) and supporting classes (like Database.php, SchoolHoliday.php, TravelAdvice.php, etc.). These scripts are designed to be executed via cron jobs, which periodically pull updated data and store it in the database.
- Web Dashboard – The “public” folder contains the web-accessible part of the project. Here, the rijksoverheid.php script and its associated dashboard classes/templates (like RijksoverheidDashboard.php and the relevant template) provide a user interface for viewing the data.

##### Relationships and Interactions
- Cron Job Triggering: The import scripts (from the “jobs” folder) are scheduled to run at regular intervals (e.g., via cron) as detailed in the README. These jobs read data from the government endpoints, process the data using various helper classes, and then store the results in the database.
- Data Flow: The import jobs send processed data to the database, and the web dashboard retrieves data from the database to display on the browser.

##### Architectural Patterns and Technologies
- Two-Tier / Multi-Tier Separation: Separate the backend processing (import jobs and database) from the frontend display (web dashboard).
- Scheduling and Asynchronous Processing: Emphasize the use of scheduled scripts (cron jobs) for importing data.
- Technology Stack: Label that the backend is built using PHP, that the persistence layer is MySQL/MariaDB, and that the web server used can be Apache or Nginx.

- Interaction Details: For example, the configuration file (db.ini) should be shown as feeding into both the import scripts and the public web classes, ensuring database connectivity is clearly depicted.

## Diagram (Mermaid)

```mermaid
graph TD
    %% External Data & Config
    A("External Government Data Source"):::external
    B("Configurations (db.ini)"):::config
    H("Database Schema"):::config

    %% Import Jobs Layer
    subgraph "Import Jobs Layer"
        C("Import Jobs - School Holidays"):::import
        D("Import Jobs - Travel Advice"):::import
        E("Jobs DB Connector"):::import
    end

    %% Data Storage
    I("Database (MySQL/MariaDB)"):::db

    %% Web Dashboard Layer
    subgraph "Web Dashboard Layer"
        F("Web Dashboard"):::dashboard
        G("Dashboard DB Connector"):::dashboard
    end

    %% Relationships
    A -->|"feeds"| C
    A -->|"feeds"| D
    B -->|"configures"| E
    B -->|"configures"| G
    C -->|"processes"| E
    D -->|"processes"| E
    E -->|"stores data in"| I
    H -->|"initializes"| I
    I -->|"retrieved by"| G
    G -->|"serves"| F

    %% Click Events for Configurations
    click B "https://github.com/fredzj/rijksoverheid-opendata/blob/main/config/db.ini"

    %% Click Events for Database Schema
    click H "https://github.com/fredzj/rijksoverheid-opendata/tree/main/database/"

    %% Click Events for Import Jobs - School Holidays
    click C "https://github.com/fredzj/rijksoverheid-opendata/blob/main/jobs/importSchoolHolidays.php"
    click C "https://github.com/fredzj/rijksoverheid-opendata/blob/main/jobs/classes/SchoolHoliday.php"
    click C "https://github.com/fredzj/rijksoverheid-opendata/blob/main/jobs/classes/SchoolHolidayImporter.php"

    %% Click Events for Import Jobs - Travel Advice
    click D "https://github.com/fredzj/rijksoverheid-opendata/blob/main/jobs/importTravelAdvice.php"
    click D "https://github.com/fredzj/rijksoverheid-opendata/blob/main/jobs/classes/TravelAdvice.php"
    click D "https://github.com/fredzj/rijksoverheid-opendata/blob/main/jobs/classes/TravelAdviceImporter.php"
    click D "https://github.com/fredzj/rijksoverheid-opendata/blob/main/jobs/classes/TravelAdviceContentBlock.php"
    click D "https://github.com/fredzj/rijksoverheid-opendata/blob/main/jobs/classes/TravelAdviceFile.php"

    %% Click Event for Jobs DB Connector
    click E "https://github.com/fredzj/rijksoverheid-opendata/blob/main/jobs/classes/Database.php"

    %% Click Events for Web Dashboard
    click F "https://github.com/fredzj/rijksoverheid-opendata/blob/main/public/rijksoverheid.php"
    click F "https://github.com/fredzj/rijksoverheid-opendata/blob/main/public/classes/RijksoverheidDashboard.php"
    click F "https://github.com/fredzj/rijksoverheid-opendata/blob/main/public/templates/rijksoverheid.php"

    %% Click Event for Dashboard DB Connector
    click G "https://github.com/fredzj/rijksoverheid-opendata/blob/main/public/classes/Database.php"

    %% Styles
    classDef config fill:#FFD700,stroke:#DAA520,stroke-width:2px
    classDef import fill:#87CEFA,stroke:#4682B4,stroke-width:2px
    classDef db fill:#98FB98,stroke:#2E8B57,stroke-width:2px
    classDef dashboard fill:#FFB6C1,stroke:#FF69B4,stroke-width:2px
    classDef external fill:#D3D3D3,stroke:#696969,stroke-width:2px
```
