# barodillah/shortlink architecture

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

- Interactive diagram: https://gitdiagram.com/barodillah/shortlink
- Repository: https://github.com/barodillah/shortlink

## Overview

SLink is a multi-user URL-shortening platform with authenticated user and superuser workflows. Requests enter through the public front controller, are routed to controllers, and produce shortlink management, analytics, account administration, settings, or public redirects. Shortlink redirects and click analytics are major product stages; the README also documents them, though some implementation details were not sampled. The graph distinguishes controller orchestration, models, and persistence. Unsampled controller-to-model links are based on the SOURCE INDEX; uncertain redirect-to-click processing is shown as unverified.

Main entry points: [`app/Core/Router.php`](https://github.com/barodillah/shortlink/blob/main/app/Core/Router.php) (Router), [`app/Core/Database.php`](https://github.com/barodillah/shortlink/blob/main/app/Core/Database.php) (PDO connection), [`app/Core/Auth.php`](https://github.com/barodillah/shortlink/blob/main/app/Core/Auth.php) (Session authentication), [`app/Models/Shortlink.php`](https://github.com/barodillah/shortlink/blob/main/app/Models/Shortlink.php) (Shortlink records)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["HTTP runtime"]
  node_front["Front controller<br/>[index.php]"]
  node_router["Router<br/>[Router.php]"]
  node_controller["Base controller<br/>[Controller.php]"]
  node_views["Application views"]
end

subgraph group_workflows["Product workflows"]
  node_authctl["Authentication<br/>[AuthController.php]"]
  node_dashboard["Dashboards"]
  node_shortctl["Shortlink management"]
  node_redirect["Public redirects"]
  node_analytics["Click analytics"]
  node_usersctl["User administration<br/>[UserController.php]"]
  node_settingsctl["Settings and logs"]
end

subgraph group_domain["Domain and access"]
  node_auth["Session authentication<br/>[Auth.php]"]
  node_middleware["Access middleware"]
  node_security["Security controls<br/>[Security.php]"]
  node_helpers["URL and parsing helpers<br/>[functions.php]"]
end

subgraph group_persistence["Persistence"]
  node_users["User records<br/>[User.php]"]
  node_shortlinks["Shortlink records<br/>[Shortlink.php]"]
  node_clicks["Click records<br/>[Click.php]"]
  node_activity["Activity records<br/>[ActivityLog.php]"]
  node_settings["Setting records<br/>[Setting.php]"]
  node_database["PDO connection<br/>[Database.php]"]
end

node_visitor(("Visitor"))
node_mysql[("MySQL or MariaDB")]

node_visitor -->|"sends request"| node_front
node_front -->|"dispatches request"| node_router
node_router -->|"routes auth"| node_authctl
node_router -->|"routes dashboard"| node_dashboard
node_router -->|"routes links"| node_shortctl
node_router -->|"routes code"| node_redirect
node_router -->|"routes analytics"| node_analytics
node_router -->|"routes users"| node_usersctl
node_router -->|"routes settings"| node_settingsctl
node_router -->|"runs middleware"| node_middleware
node_front -->|"initializes security"| node_security
node_controller -->|"renders views"| node_views
node_authctl -->|"authenticates"| node_auth
node_dashboard -->|"checks identity"| node_auth
node_shortctl -->|"manages links"| node_shortlinks
node_shortctl -->|"checks limits"| node_users
node_analytics -->|"queries analytics"| node_clicks
node_analytics -->|"loads link context"| node_shortlinks
node_usersctl -->|"manages accounts"| node_users
node_usersctl -->|"loads trends"| node_clicks
node_settingsctl -->|"updates settings"| node_settings
node_settingsctl -->|"queries logs"| node_activity
node_auth -->|"loads user"| node_users
node_auth -->|"records sign-in"| node_activity
node_auth -->|"checks login attempts"| node_database
node_middleware -->|"checks session"| node_auth
node_shortlinks -->|"generates codes"| node_security
node_shortlinks -->|"reads and writes"| node_database
node_users -->|"reads and writes"| node_database
node_clicks -->|"reads and writes"| node_database
node_activity -->|"reads and writes"| node_database
node_settings -->|"reads and writes"| node_database
node_database -->|"connects via PDO"| node_mysql
node_redirect -.->|"resolves destination"| node_shortlinks
node_redirect -.->|"records click"| node_clicks
node_helpers -->|"uses validators"| node_security

click node_front "https://github.com/barodillah/shortlink/blob/main/public/index.php"
click node_router "https://github.com/barodillah/shortlink/blob/main/app/Core/Router.php"
click node_controller "https://github.com/barodillah/shortlink/blob/main/app/Core/Controller.php"
click node_views "https://github.com/barodillah/shortlink/tree/main/app/Views"
click node_authctl "https://github.com/barodillah/shortlink/blob/main/app/Controllers/AuthController.php"
click node_dashboard "https://github.com/barodillah/shortlink/blob/main/app/Controllers/DashboardController.php"
click node_shortctl "https://github.com/barodillah/shortlink/blob/main/app/Controllers/ShortlinkController.php"
click node_redirect "https://github.com/barodillah/shortlink/blob/main/app/Controllers/RedirectController.php"
click node_analytics "https://github.com/barodillah/shortlink/blob/main/app/Controllers/AnalyticsController.php"
click node_usersctl "https://github.com/barodillah/shortlink/blob/main/app/Controllers/UserController.php"
click node_settingsctl "https://github.com/barodillah/shortlink/blob/main/app/Controllers/SettingsController.php"
click node_auth "https://github.com/barodillah/shortlink/blob/main/app/Core/Auth.php"
click node_middleware "https://github.com/barodillah/shortlink/tree/main/app/Middleware"
click node_security "https://github.com/barodillah/shortlink/blob/main/app/Core/Security.php"
click node_helpers "https://github.com/barodillah/shortlink/blob/main/app/Helpers/functions.php"
click node_users "https://github.com/barodillah/shortlink/blob/main/app/Models/User.php"
click node_shortlinks "https://github.com/barodillah/shortlink/blob/main/app/Models/Shortlink.php"
click node_clicks "https://github.com/barodillah/shortlink/blob/main/app/Models/Click.php"
click node_activity "https://github.com/barodillah/shortlink/blob/main/app/Models/ActivityLog.php"
click node_settings "https://github.com/barodillah/shortlink/blob/main/app/Models/Setting.php"
click node_database "https://github.com/barodillah/shortlink/blob/main/app/Core/Database.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_front,node_router,node_controller,node_views toneBlue
class node_authctl,node_dashboard,node_shortctl,node_redirect,node_analytics,node_usersctl,node_settingsctl,node_mysql toneAmber
class node_auth,node_middleware,node_security,node_helpers toneMint
class node_users,node_shortlinks,node_clicks,node_activity,node_settings,node_database toneRose
class node_visitor toneIndigo
```

## Components

### HTTP runtime

- [Front controller](https://github.com/barodillah/shortlink/blob/main/public/index.php): `public/index.php`
- [Router](https://github.com/barodillah/shortlink/blob/main/app/Core/Router.php): `app/Core/Router.php`
- [Base controller](https://github.com/barodillah/shortlink/blob/main/app/Core/Controller.php): `app/Core/Controller.php`
- [Application views](https://github.com/barodillah/shortlink/tree/main/app/Views): `app/Views`

### Product workflows

- [Authentication](https://github.com/barodillah/shortlink/blob/main/app/Controllers/AuthController.php): `app/Controllers/AuthController.php`
- [Dashboards](https://github.com/barodillah/shortlink/blob/main/app/Controllers/DashboardController.php): `app/Controllers/DashboardController.php`
- [Shortlink management](https://github.com/barodillah/shortlink/blob/main/app/Controllers/ShortlinkController.php): `app/Controllers/ShortlinkController.php`
- [Public redirects](https://github.com/barodillah/shortlink/blob/main/app/Controllers/RedirectController.php): `app/Controllers/RedirectController.php`
- [Click analytics](https://github.com/barodillah/shortlink/blob/main/app/Controllers/AnalyticsController.php): `app/Controllers/AnalyticsController.php`
- [User administration](https://github.com/barodillah/shortlink/blob/main/app/Controllers/UserController.php): `app/Controllers/UserController.php`
- [Settings and logs](https://github.com/barodillah/shortlink/blob/main/app/Controllers/SettingsController.php): `app/Controllers/SettingsController.php`

### Domain and access

- [Session authentication](https://github.com/barodillah/shortlink/blob/main/app/Core/Auth.php): `app/Core/Auth.php`
- [Access middleware](https://github.com/barodillah/shortlink/tree/main/app/Middleware): `app/Middleware`
- [Security controls](https://github.com/barodillah/shortlink/blob/main/app/Core/Security.php): `app/Core/Security.php`
- [URL and parsing helpers](https://github.com/barodillah/shortlink/blob/main/app/Helpers/functions.php): `app/Helpers/functions.php`

### Persistence

- [User records](https://github.com/barodillah/shortlink/blob/main/app/Models/User.php): `app/Models/User.php`
- [Shortlink records](https://github.com/barodillah/shortlink/blob/main/app/Models/Shortlink.php): `app/Models/Shortlink.php`
- [Click records](https://github.com/barodillah/shortlink/blob/main/app/Models/Click.php): `app/Models/Click.php`
- [Activity records](https://github.com/barodillah/shortlink/blob/main/app/Models/ActivityLog.php): `app/Models/ActivityLog.php`
- [Setting records](https://github.com/barodillah/shortlink/blob/main/app/Models/Setting.php): `app/Models/Setting.php`
- [PDO connection](https://github.com/barodillah/shortlink/blob/main/app/Core/Database.php): `app/Core/Database.php`

### Other components

- **Visitor**
- **MySQL or MariaDB**

## Connections

- Visitor → Front controller: sends request
- Front controller → Router: dispatches request (evidence: `public/index.php`)
- Router → Authentication: routes auth (evidence: `public/index.php`)
- Router → Dashboards: routes dashboard (evidence: `public/index.php`)
- Router → Shortlink management: routes links (evidence: `public/index.php`)
- Router → Public redirects: routes code (evidence: `public/index.php`)
- Router → Click analytics: routes analytics (evidence: `public/index.php`)
- Router → User administration: routes users (evidence: `public/index.php`)
- Router → Settings and logs: routes settings (evidence: `public/index.php`)
- Router → Access middleware: runs middleware (evidence: `public/index.php`)
- Front controller → Security controls: initializes security (evidence: `public/index.php`)
- Base controller → Application views: renders views (evidence: `app/Core/Controller.php`)
- Authentication → Session authentication: authenticates (evidence: `app/Controllers/AuthController.php`)
- Dashboards → Session authentication: checks identity (evidence: `app/Controllers/DashboardController.php`)
- Shortlink management → Shortlink records: manages links (evidence: `app/Controllers/ShortlinkController.php`)
- Shortlink management → User records: checks limits (evidence: `app/Controllers/ShortlinkController.php`)
- Click analytics → Click records: queries analytics (evidence: `app/Controllers/AnalyticsController.php`)
- Click analytics → Shortlink records: loads link context (evidence: `app/Controllers/AnalyticsController.php`)
- User administration → User records: manages accounts (evidence: `app/Controllers/UserController.php`)
- User administration → Click records: loads trends (evidence: `app/Controllers/UserController.php`)
- Settings and logs → Setting records: updates settings (evidence: `app/Controllers/SettingsController.php`)
- Settings and logs → Activity records: queries logs (evidence: `app/Controllers/SettingsController.php`)
- Session authentication → User records: loads user (evidence: `app/Core/Auth.php`)
- Session authentication → Activity records: records sign-in (evidence: `app/Core/Auth.php`)
- Session authentication → PDO connection: checks login attempts (evidence: `app/Core/Auth.php`)
- Access middleware → Session authentication: checks session (evidence: `app/Middleware/AuthMiddleware.php`)
- Shortlink records → Security controls: generates codes (evidence: `app/Models/Shortlink.php`)
- Shortlink records → PDO connection: reads and writes (evidence: `app/Models/Shortlink.php`)
- User records → PDO connection: reads and writes (evidence: `app/Models/User.php`)
- Click records → PDO connection: reads and writes (evidence: `app/Models/Click.php`)
- Activity records → PDO connection: reads and writes (evidence: `app/Models/ActivityLog.php`)
- Setting records → PDO connection: reads and writes (evidence: `app/Models/Setting.php`)
- PDO connection → MySQL or MariaDB: connects via PDO
- Public redirects → Shortlink records: resolves destination (evidence: `app/Controllers/RedirectController.php`)
- Public redirects → Click records: records click (evidence: `app/Controllers/RedirectController.php`)
- URL and parsing helpers → Security controls: uses validators (evidence: `app/Helpers/functions.php`)
