# nandichi/politiekpraat architecture

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

- Interactive diagram: https://gitdiagram.com/nandichi/politiekpraat
- Repository: https://github.com/nandichi/politiekpraat

## Overview

##### Overall Project Type and Purpose
- PolitiekPraat is a full-stack, content-driven website focused on Dutch politics.
- Its main goal is to create an accessible platform where users can read political news, blogs, comment, and interact regarding current political themes.
- It uses a typical web stack with PHP for server-side processing, MySQL for the database, and front-end technologies (CSS via Tailwind and client-side assets in the public folder).

##### Analysis of the File Structure
- Key Directories:
- controllers: Contains the logic for various pages (e.g. home, login, blogs, forum, profile, etc.). This suggests an MVC-like approach where controllers handle user requests.
- includes: Hosts core classes and configuration files (e.g. Router, Database, API integrations, configuration). These likely provide services used across multiple controllers.
- views: Contains the presentation layer – the templates and page layouts (e.g. header, footer, and specialized pages for blogs, nieuws, profiel, etc.).
- public: Holds static assets like CSS, images, and potentially JavaScript. This folder is the entry point for assets served to the client.
- database: SQL files that set up and migrate the database schema.
- admin: Has a dedicated section for admin tasks (dashboard).
- scripts & cron files: Provides auxiliary tools like sitemap generation and blog processing scripts.
- Supporting Files:
- composer.json indicates PHP dependencies.
- Build scripts (build.sh, tailwind.config.js, package.json) indicate frontend build tooling.
- Configuration and routing infrastructure via includes (e.g., Router.php, config.php) that tie components together.

##### Key Components and Their Roles
a. Frontend Components:
- Views: Separate directories for blogs, nieuws, over-mij, thema, etc.
- Public: Contains CSS and images (including party logos, profile images).
- Tailwind configuration: Indicates usage of Tailwind CSS for styling.
b. Backend Components:
- Controllers: Responsible for request handling, authentication (login, logout, register), content management (blogs, forum, comments, etc.), and special pages such as over-mij.
- Includes: Core libraries like Database, AuthController, BlogController, functions, and more; setup for API integrations (NewsAPI, OpenDataAPI, PoliticalDataAPI) to potentially pull in data from external services.
- Admin Section: For backend management with admin/dashboard.php.
c. Data Persistence:
- The database directory with SQL migration/ setup files.
- Cache folder to store JSON responses from various political data sources.
d. Auxiliary Components:
- Scripts (PHP scripts for generating blogs or political content) and cron files (automating sitemap generation).
- Routing/HTTP handling via the Router, which likely directs requests to appropriate controllers.
- Configuration and security measures in includes/config.php and auth_check.php.

##### Relationships and Interactions
- The front end (views) interacts with the backend controllers that process HTTP requests.
- Controllers call functions and methods defined in includes (like Database.php or external API integrations) to retrieve or store data.
- Data flows from the Database and cache to the controllers, then to the views.
- Public folder assets (CSS/JS/images) are loaded by the browser when rendering the views.
- Admin areas and user authentication are separated into specialized controllers and includes.

##### Architectural Patterns and Important Technologies
- MVC-like Separation: Controllers, Views, and shared business logic in includes.
- RESTful-like Routing: Managed by Router.php from the includes folder.
- Template Composition: Shared templates (header and footer) are reused across multiple view files.
- API Integration: Several includes (NewsAPI, PoliticalDataAPI, etc.) suggest external data is fetched to keep political content up-to-date.
- Security: There are dedicated controllers for authentication (login, logout) and safety checks in includes/auth_check.php.
- Build System: Use of build.sh, package.json, and Tailwind CSS setup indicate modern frontend tooling.

## Diagram (Mermaid)

```mermaid
flowchart TD

    %% Global User
    U["User"]:::frontend

    %% Frontend/Presentation Layer
    subgraph "Frontend/Presentation Layer"
        UI["User Interface (Views)"]:::frontend
        PA["Static Assets (Public)"]:::frontend
    end

    %% Build and Styling Configuration
    subgraph "Build and Styling"
        BS1["Build Script (build.sh)"]:::build
        BS2["Tailwind Config (tailwind.config.js)"]:::build
        BS3["Dependency Config (package.json)"]:::build
    end

    %% Application Layer (Controllers)
    subgraph "Application Layer (Controllers)"
        CTG["General Controller"]:::backend
        CTA["Auth Controller"]:::backend
        CTB["Blog Controller"]:::backend
        CTF["Forum Controller"]:::backend
        CTP["Profile Controller"]:::backend
    end

    %% Core Services and Business Logic (Includes)
    subgraph "Core Services (Includes)"
        R["Router"]:::backend
        DS["Database Service"]:::backend
        AL["Auth Logic"]:::backend
        BL["Blog Logic"]:::backend
        NA["News API"]:::backend
        OA["OpenData API"]:::backend
        PAAPI["Political Data API"]:::backend
        CFG["Configuration"]:::backend
    end

    %% Data Persistence
    subgraph "Data Persistence"
        SQL["SQL Database"]:::database
        JC["JSON Cache"]:::database
    end

    %% Administration Module
    subgraph "Administration Module"
        AD["Admin Dashboard"]:::backend
    end

    %% Auxiliary Services
    subgraph "Auxiliary Services"
        SC["Scripts"]:::aux
        CR1["Cron: Sitemap Generation"]:::aux
        CR2["Cron: Sitemap Alternate"]:::aux
    end

    %% Connections
    U -->|"accesses"| UI
    U -->|"retrieves"| PA

    %% Build & Styling influence Public Assets
    BS1 -->|"builds"| PA
    BS2 -->|"styles"| PA
    BS3 -->|"manages"| PA

    %% Frontend to Controllers
    UI -->|"requests"| CTG
    UI -->|"requests"| CTA
    UI -->|"requests"| CTB
    UI -->|"requests"| CTF
    UI -->|"requests"| CTP

    %% Controllers delegate to Router (via Includes)
    CTG -->|"routes"| R
    CTA -->|"routes"| R
    CTB -->|"routes"| R
    CTF -->|"routes"| R
    CTP -->|"routes"| R

    %% Specific Controller Logic
    CTA -->|"calls"| AL
    CTB -->|"calls"| BL

    %% Router interactions with Core Services
    R -->|"invokes"| DS
    R -->|"reads"| CFG

    %% External API Integration (dotted arrows)
    BL -.->|"fetches"| NA
    R -.->|"fetches"| OA
    R -.->|"fetches"| PAAPI

    %% Data layer interactions
    DS -->|"queries"| SQL
    DS -->|"caches"| JC

    %% Admin Module Flow
    AD -->|"uses"| R

    %% Auxiliary services interactions
    SC -->|"updates"| SQL
    CR1 -->|"updates"| JC
    CR2 -->|"updates"| SQL

    %% Click Events
    click UI "https://github.com/nandichi/politiekpraat/tree/main/views/"
    click PA "https://github.com/nandichi/politiekpraat/tree/main/public/"
    click BS1 "https://github.com/nandichi/politiekpraat/blob/main/build.sh"
    click BS2 "https://github.com/nandichi/politiekpraat/blob/main/tailwind.config.js"
    click BS3 "https://github.com/nandichi/politiekpraat/blob/main/package.json"
    click CTG "https://github.com/nandichi/politiekpraat/tree/main/controllers/"
    click CTA "https://github.com/nandichi/politiekpraat/tree/main/controllers/auth/"
    click CTB "https://github.com/nandichi/politiekpraat/tree/main/controllers/blogs/"
    click CTF "https://github.com/nandichi/politiekpraat/tree/main/controllers/forum/"
    click CTP "https://github.com/nandichi/politiekpraat/tree/main/controllers/profile/"
    click R "https://github.com/nandichi/politiekpraat/blob/main/includes/Router.php"
    click DS "https://github.com/nandichi/politiekpraat/blob/main/includes/Database.php"
    click AL "https://github.com/nandichi/politiekpraat/blob/main/includes/AuthController.php"
    click BL "https://github.com/nandichi/politiekpraat/blob/main/includes/BlogController.php"
    click NA "https://github.com/nandichi/politiekpraat/blob/main/includes/NewsAPI.php"
    click OA "https://github.com/nandichi/politiekpraat/blob/main/includes/OpenDataAPI.php"
    click PAAPI "https://github.com/nandichi/politiekpraat/blob/main/includes/PoliticalDataAPI.php"
    click CFG "https://github.com/nandichi/politiekpraat/blob/main/includes/config.php"
    click SQL "https://github.com/nandichi/politiekpraat/tree/main/database/"
    click JC "https://github.com/nandichi/politiekpraat/tree/main/cache/"
    click AD "https://github.com/nandichi/politiekpraat/blob/main/admin/dashboard.php"
    click SC "https://github.com/nandichi/politiekpraat/tree/main/scripts/"
    click CR1 "https://github.com/nandichi/politiekpraat/blob/main/cron-generate-sitemap.php"
    click CR2 "https://github.com/nandichi/politiekpraat/blob/main/generate-sitemap.php"

    %% Styles
    classDef frontend fill:#AEDFF7,stroke:#333,stroke-width:2px;
    classDef backend fill:#FFCAB1,stroke:#333,stroke-width:2px;
    classDef database fill:#C7F3C7,stroke:#333,stroke-width:2px;
    classDef aux fill:#F3E1FF,stroke:#333,stroke-width:2px;
    classDef build fill:#FFF5BA,stroke:#333,stroke-width:2px;
```
