# kadirermantr/news-hub architecture

> Architecture diagram of the GitHub repository kadirermantr/news-hub, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/kadirermantr/news-hub
- Repository: https://github.com/kadirermantr/news-hub

## Overview

News Hub is a role-based news website: readers browse news and categories, read articles, comment, and follow categories; registered users can track reads, while authorized staff manage news, categories, comments, users, and access requests. Its documented JSON API exposes individual and category-filtered news. The graph follows route dispatch and sampled controller behavior; several administrative and model implementations were not sampled, so their internal wiring is shown only where routes and the tree support it.

Main entry points: [`core/Router.php`](https://github.com/kadirermantr/news-hub/blob/main/core/Router.php) (Request router), [`app/Models`](https://github.com/kadirermantr/news-hub/tree/main/app/Models) (Domain models), [`app/Controllers/HomeController.php`](https://github.com/kadirermantr/news-hub/blob/main/app/Controllers/HomeController.php) (News and categories), [`app/Controllers/Auth`](https://github.com/kadirermantr/news-hub/tree/main/app/Controllers/Auth) (Login and registration)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Web runtime"]
  node_entry["Web entry point<br/>[index.php]"]
  node_application["Application lifecycle<br/>[Application.php]"]
  node_routes["Route definitions<br/>[routes.php]"]
  node_router["Request router<br/>[Router.php]"]
end

subgraph group_reader["Reader experience"]
  node_public_pages["News and categories<br/>[HomeController.php]"]
  node_api_news["News API<br/>[NewsController.php]"]
  node_views["Rendered pages"]
end

subgraph group_identity["Accounts and access"]
  node_middleware["Request middleware"]
  node_auth_pages["Login and registration"]
  node_session["Session state<br/>[Session.php]"]
end

subgraph group_admin["Administration"]
  node_admin_news["News management<br/>[NewsController.php]"]
  node_admin_categories["Category management"]
  node_admin_comments["Comment moderation"]
  node_admin_users["User administration<br/>[UserController.php]"]
  node_admin_other["Staff and profiles"]
end

subgraph group_data["Data and activity"]
  node_models["Domain models"]
  node_model_base["Model persistence layer<br/>[Model.php]"]
  node_db_access["Database access<br/>[DB.php]"]
  node_database[("Application database")]
  node_activity_log["Activity logging<br/>[Logger.php]"]
  node_log_file[("Activity log file")]
end

node_visitor(("Reader or staff"))
node_api_client(("API client"))

node_entry -->|"starts"| node_application
node_application -->|"resolves request"| node_router
node_routes -->|"registers routes"| node_router
node_visitor -->|"sends request"| node_router
node_api_client -.->|"requests API"| node_router
node_router -->|"executes checks"| node_middleware
node_router -->|"dispatches"| node_public_pages
node_router -->|"dispatches"| node_auth_pages
node_router -->|"dispatches"| node_api_news
node_router -->|"dispatches"| node_admin_news
node_router -->|"dispatches"| node_admin_categories
node_router -->|"dispatches"| node_admin_comments
node_router -->|"dispatches"| node_admin_users
node_router -->|"dispatches"| node_admin_other
node_public_pages -->|"reads and writes"| node_models
node_auth_pages -->|"reads and writes"| node_models
node_api_news -->|"reads news"| node_models
node_admin_news -->|"manages news"| node_models
node_admin_categories -->|"manages categories"| node_models
node_admin_comments -->|"manages comments"| node_models
node_admin_users -->|"manages users"| node_models
node_admin_other -->|"manages records"| node_models
node_models -->|"uses persistence"| node_model_base
node_model_base -->|"uses database access"| node_db_access
node_db_access -->|"queries"| node_database
node_public_pages -->|"tracks session state"| node_session
node_auth_pages -->|"sets session state"| node_session
node_application -->|"renders errors"| node_views
node_public_pages -->|"renders pages"| node_router
node_auth_pages -->|"renders pages"| node_router
node_admin_news -->|"renders pages"| node_router
node_admin_categories -->|"renders pages"| node_router
node_admin_comments -->|"renders pages"| node_router
node_admin_users -->|"renders pages"| node_router
node_admin_other -->|"renders pages"| node_router
node_router -->|"includes view"| node_views
node_admin_users -->|"reads activity"| node_activity_log
node_activity_log -->|"writes log"| node_log_file

click node_entry "https://github.com/kadirermantr/news-hub/blob/main/public/index.php"
click node_application "https://github.com/kadirermantr/news-hub/blob/main/core/Application.php"
click node_routes "https://github.com/kadirermantr/news-hub/blob/main/app/routes.php"
click node_router "https://github.com/kadirermantr/news-hub/blob/main/core/Router.php"
click node_middleware "https://github.com/kadirermantr/news-hub/tree/main/app/Middlewares"
click node_public_pages "https://github.com/kadirermantr/news-hub/blob/main/app/Controllers/HomeController.php"
click node_auth_pages "https://github.com/kadirermantr/news-hub/tree/main/app/Controllers/Auth"
click node_api_news "https://github.com/kadirermantr/news-hub/blob/main/app/Controllers/Admin/NewsController.php"
click node_admin_news "https://github.com/kadirermantr/news-hub/blob/main/app/Controllers/Admin/NewsController.php"
click node_admin_categories "https://github.com/kadirermantr/news-hub/blob/main/app/Controllers/Admin/CategoryController.php"
click node_admin_comments "https://github.com/kadirermantr/news-hub/blob/main/app/Controllers/Admin/CommentController.php"
click node_admin_users "https://github.com/kadirermantr/news-hub/blob/main/app/Controllers/Admin/UserController.php"
click node_admin_other "https://github.com/kadirermantr/news-hub/tree/main/app/Controllers/Admin"
click node_models "https://github.com/kadirermantr/news-hub/tree/main/app/Models"
click node_model_base "https://github.com/kadirermantr/news-hub/blob/main/core/Model.php"
click node_db_access "https://github.com/kadirermantr/news-hub/blob/main/core/DB.php"
click node_views "https://github.com/kadirermantr/news-hub/tree/main/resources/views"
click node_session "https://github.com/kadirermantr/news-hub/blob/main/core/Session.php"
click node_activity_log "https://github.com/kadirermantr/news-hub/blob/main/core/log/Logger.php"

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_entry,node_application,node_routes,node_router,node_api_client toneBlue
class node_public_pages,node_api_news,node_views toneAmber
class node_middleware,node_auth_pages,node_session toneMint
class node_admin_news,node_admin_categories,node_admin_comments,node_admin_users,node_admin_other toneRose
class node_models,node_model_base,node_db_access,node_database,node_activity_log,node_log_file,node_visitor toneIndigo
```

## Components

### Web runtime

- [Web entry point](https://github.com/kadirermantr/news-hub/blob/main/public/index.php): `public/index.php`
- [Application lifecycle](https://github.com/kadirermantr/news-hub/blob/main/core/Application.php): `core/Application.php`
- [Route definitions](https://github.com/kadirermantr/news-hub/blob/main/app/routes.php): `app/routes.php`
- [Request router](https://github.com/kadirermantr/news-hub/blob/main/core/Router.php): `core/Router.php`

### Reader experience

- [News and categories](https://github.com/kadirermantr/news-hub/blob/main/app/Controllers/HomeController.php): `app/Controllers/HomeController.php`
- [News API](https://github.com/kadirermantr/news-hub/blob/main/app/Controllers/Admin/NewsController.php): `app/Controllers/Admin/NewsController.php`
- [Rendered pages](https://github.com/kadirermantr/news-hub/tree/main/resources/views): `resources/views`

### Accounts and access

- [Request middleware](https://github.com/kadirermantr/news-hub/tree/main/app/Middlewares): `app/Middlewares`
- [Login and registration](https://github.com/kadirermantr/news-hub/tree/main/app/Controllers/Auth): `app/Controllers/Auth`
- [Session state](https://github.com/kadirermantr/news-hub/blob/main/core/Session.php): `core/Session.php`

### Administration

- [News management](https://github.com/kadirermantr/news-hub/blob/main/app/Controllers/Admin/NewsController.php): `app/Controllers/Admin/NewsController.php`
- [Category management](https://github.com/kadirermantr/news-hub/blob/main/app/Controllers/Admin/CategoryController.php): `app/Controllers/Admin/CategoryController.php`
- [Comment moderation](https://github.com/kadirermantr/news-hub/blob/main/app/Controllers/Admin/CommentController.php): `app/Controllers/Admin/CommentController.php`
- [User administration](https://github.com/kadirermantr/news-hub/blob/main/app/Controllers/Admin/UserController.php): `app/Controllers/Admin/UserController.php`
- [Staff and profiles](https://github.com/kadirermantr/news-hub/tree/main/app/Controllers/Admin): `app/Controllers/Admin`

### Data and activity

- [Domain models](https://github.com/kadirermantr/news-hub/tree/main/app/Models): `app/Models`
- [Model persistence layer](https://github.com/kadirermantr/news-hub/blob/main/core/Model.php): `core/Model.php`
- [Database access](https://github.com/kadirermantr/news-hub/blob/main/core/DB.php): `core/DB.php`
- **Application database**
- [Activity logging](https://github.com/kadirermantr/news-hub/blob/main/core/log/Logger.php): `core/log/Logger.php`
- **Activity log file**

### Other components

- **Reader or staff**
- **API client**

## Connections

- Web entry point → Application lifecycle: starts
- Application lifecycle → Request router: resolves request
- Route definitions → Request router: registers routes
- Reader or staff → Request router: sends request
- API client → Request router: requests API
- Request router → Request middleware: executes checks
- Request router → News and categories: dispatches
- Request router → Login and registration: dispatches
- Request router → News API: dispatches
- Request router → News management: dispatches
- Request router → Category management: dispatches
- Request router → Comment moderation: dispatches
- Request router → User administration: dispatches
- Request router → Staff and profiles: dispatches
- News and categories → Domain models: reads and writes
- Login and registration → Domain models: reads and writes
- News API → Domain models: reads news
- News management → Domain models: manages news
- Category management → Domain models: manages categories
- Comment moderation → Domain models: manages comments
- User administration → Domain models: manages users
- Staff and profiles → Domain models: manages records
- Domain models → Model persistence layer: uses persistence
- Model persistence layer → Database access: uses database access
- Database access → Application database: queries
- News and categories → Session state: tracks session state
- Login and registration → Session state: sets session state
- Application lifecycle → Rendered pages: renders errors
- News and categories → Request router: renders pages
- Login and registration → Request router: renders pages
- News management → Request router: renders pages
- Category management → Request router: renders pages
- Comment moderation → Request router: renders pages
- User administration → Request router: renders pages
- Staff and profiles → Request router: renders pages
- Request router → Rendered pages: includes view
- User administration → Activity logging: reads activity
- Activity logging → Activity log file: writes log
