# realodix/urlhub architecture

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

- Interactive diagram: https://gitdiagram.com/realodix/urlhub
- Repository: https://github.com/realodix/urlhub

## Overview

UrlHub is a self-hosted URL shortener. Users submit long URLs to create generated or custom short links, then resolve those links through redirect handling and visit tracking. Authenticated users and administrators can manage links and users and inspect visit analytics. The graph includes the documented QR-code, password, expiration, device-aware redirect, and configuration capabilities; their detailed implementations were not all sampled, so only directly supported relationships are shown.

Main entry points: [`app/Models/Url.php`](https://github.com/realodix/urlhub/blob/master/app/Models/Url.php) (Short links), [`app/Actions/RedirectToDestination.php`](https://github.com/realodix/urlhub/blob/master/app/Actions/RedirectToDestination.php) (Redirect action), [`app/Actions/RecordVisit.php`](https://github.com/realodix/urlhub/blob/master/app/Actions/RecordVisit.php) (Record visit), [`routes/web.php`](https://github.com/realodix/urlhub/blob/master/routes/web.php) (Web routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_link["Link lifecycle"]
  node_link_controller["Link controller<br/>[LinkController.php]"]
  node_request_validation["Link validation"]
  node_link_rules["Link rules<br/>[LinkRules.php]"]
  node_link_service["Link service<br/>[LinkService.php]"]
  node_key_generator["Key generator"]
  node_blocked_strings["Blocked strings"]
  node_url_model[("Short links<br/>[Url.php]")]
  node_redirect_controller["Redirect controller"]
  node_redirect_action["Redirect action"]
  node_qr["QR generation<br/>[GenerateQrCode.php]"]
end

subgraph group_analytics["Visits and analytics"]
  node_visit_action["Record visit<br/>[RecordVisit.php]"]
  node_visit_service["Visit analytics<br/>[VisitService.php]"]
  node_visit_model[("Visit records<br/>[Visit.php]")]
  node_charts["Visit charts<br/>[LinkVisitChart.php]"]
end

subgraph group_management["Dashboard and identity"]
  node_user_model[("Users<br/>[User.php]")]
  node_user_service["User service<br/>[UserService.php]"]
  node_user_controller["User administration<br/>[UserController.php]"]
  node_dashboard["Dashboard"]
end

subgraph group_domain["Domain services"]
  node_settings["General settings"]
  node_device_detection["Device detection"]
end

node_visitor(("Visitor"))
node_web["Web routes<br/>[web.php]"]

node_visitor -->|"requests routes"| node_web
node_web -->|"routes requests"| node_link_controller
node_web -->|"routes short links"| node_redirect_controller
node_web -->|"routes dashboard"| node_dashboard
node_web -->|"routes user admin"| node_user_controller
node_link_controller -->|"validates input"| node_request_validation
node_request_validation -->|"uses rules"| node_link_rules
node_link_controller -->|"creates links"| node_link_service
node_link_service -->|"generates keys"| node_key_generator
node_key_generator -->|"checks blocked keys"| node_blocked_strings
node_key_generator -->|"checks key availability"| node_url_model
node_link_service -->|"stores links"| node_url_model
node_link_service -->|"reads configuration"| node_settings
node_link_controller -->|"generates QR"| node_qr
node_redirect_controller -->|"dispatches redirect"| node_redirect_action
node_redirect_action -->|"records visit"| node_visit_action
node_redirect_action -->|"resolves destination"| node_url_model
node_redirect_action -->|"reads configuration"| node_settings
node_visit_action -->|"records metrics"| node_visit_service
node_visit_action -->|"writes visit"| node_visit_model
node_visit_action -->|"updates link stats"| node_url_model
node_visit_service -->|"queries visits"| node_visit_model
node_charts -->|"reads visit data"| node_visit_model
node_dashboard -->|"provides analytics"| node_visit_service
node_dashboard -->|"provides link data"| node_link_service
node_user_controller -->|"manages accounts"| node_user_model
node_user_service -->|"uses account data"| node_user_model
node_visit_action -->|"identifies visitor"| node_user_service
node_user_model -->|"owns links"| node_url_model
node_url_model -->|"has visits"| node_visit_model
node_redirect_action -.->|"detects device"| node_device_detection

click node_web "https://github.com/realodix/urlhub/blob/master/routes/web.php"
click node_link_controller "https://github.com/realodix/urlhub/blob/master/app/Http/Controllers/LinkController.php"
click node_request_validation "https://github.com/realodix/urlhub/blob/master/app/Http/Requests/StoreUrlRequest.php"
click node_link_rules "https://github.com/realodix/urlhub/blob/master/app/Rules/LinkRules.php"
click node_link_service "https://github.com/realodix/urlhub/blob/master/app/Services/LinkService.php"
click node_key_generator "https://github.com/realodix/urlhub/blob/master/app/Services/KeyGeneratorService.php"
click node_blocked_strings "https://github.com/realodix/urlhub/blob/master/app/Services/BlockedStringService.php"
click node_url_model "https://github.com/realodix/urlhub/blob/master/app/Models/Url.php"
click node_redirect_controller "https://github.com/realodix/urlhub/blob/master/app/Http/Controllers/RedirectController.php"
click node_redirect_action "https://github.com/realodix/urlhub/blob/master/app/Actions/RedirectToDestination.php"
click node_qr "https://github.com/realodix/urlhub/blob/master/app/Actions/GenerateQrCode.php"
click node_settings "https://github.com/realodix/urlhub/blob/master/app/Settings/GeneralSettings.php"
click node_user_model "https://github.com/realodix/urlhub/blob/master/app/Models/User.php"
click node_user_service "https://github.com/realodix/urlhub/blob/master/app/Services/UserService.php"
click node_user_controller "https://github.com/realodix/urlhub/blob/master/app/Http/Controllers/Dashboard/User/UserController.php"
click node_dashboard "https://github.com/realodix/urlhub/blob/master/app/Http/Controllers/Dashboard/DashboardController.php"
click node_visit_action "https://github.com/realodix/urlhub/blob/master/app/Actions/RecordVisit.php"
click node_visit_service "https://github.com/realodix/urlhub/blob/master/app/Services/VisitService.php"
click node_visit_model "https://github.com/realodix/urlhub/blob/master/app/Models/Visit.php"
click node_charts "https://github.com/realodix/urlhub/blob/master/app/Livewire/Chart/LinkVisitChart.php"
click node_device_detection "https://github.com/realodix/urlhub/blob/master/app/Services/DeviceDetectorService.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_link_controller,node_request_validation,node_link_rules,node_link_service,node_key_generator,node_blocked_strings,node_url_model,node_redirect_controller,node_redirect_action,node_qr toneBlue
class node_visit_action,node_visit_service,node_visit_model,node_charts toneAmber
class node_user_model,node_user_service,node_user_controller,node_dashboard,node_web toneMint
class node_settings,node_device_detection toneRose
class node_visitor toneIndigo
```

## Components

### Link lifecycle

- [Link controller](https://github.com/realodix/urlhub/blob/master/app/Http/Controllers/LinkController.php): `app/Http/Controllers/LinkController.php`
- [Link validation](https://github.com/realodix/urlhub/blob/master/app/Http/Requests/StoreUrlRequest.php): `app/Http/Requests/StoreUrlRequest.php`
- [Link rules](https://github.com/realodix/urlhub/blob/master/app/Rules/LinkRules.php): `app/Rules/LinkRules.php`
- [Link service](https://github.com/realodix/urlhub/blob/master/app/Services/LinkService.php): `app/Services/LinkService.php`
- [Key generator](https://github.com/realodix/urlhub/blob/master/app/Services/KeyGeneratorService.php): `app/Services/KeyGeneratorService.php`
- [Blocked strings](https://github.com/realodix/urlhub/blob/master/app/Services/BlockedStringService.php): `app/Services/BlockedStringService.php`
- [Short links](https://github.com/realodix/urlhub/blob/master/app/Models/Url.php): `app/Models/Url.php`
- [Redirect controller](https://github.com/realodix/urlhub/blob/master/app/Http/Controllers/RedirectController.php): `app/Http/Controllers/RedirectController.php`
- [Redirect action](https://github.com/realodix/urlhub/blob/master/app/Actions/RedirectToDestination.php): `app/Actions/RedirectToDestination.php`
- [QR generation](https://github.com/realodix/urlhub/blob/master/app/Actions/GenerateQrCode.php): `app/Actions/GenerateQrCode.php`

### Visits and analytics

- [Record visit](https://github.com/realodix/urlhub/blob/master/app/Actions/RecordVisit.php): `app/Actions/RecordVisit.php`
- [Visit analytics](https://github.com/realodix/urlhub/blob/master/app/Services/VisitService.php): `app/Services/VisitService.php`
- [Visit records](https://github.com/realodix/urlhub/blob/master/app/Models/Visit.php): `app/Models/Visit.php`
- [Visit charts](https://github.com/realodix/urlhub/blob/master/app/Livewire/Chart/LinkVisitChart.php): `app/Livewire/Chart/LinkVisitChart.php`

### Dashboard and identity

- [Users](https://github.com/realodix/urlhub/blob/master/app/Models/User.php): `app/Models/User.php`
- [User service](https://github.com/realodix/urlhub/blob/master/app/Services/UserService.php): `app/Services/UserService.php`
- [User administration](https://github.com/realodix/urlhub/blob/master/app/Http/Controllers/Dashboard/User/UserController.php): `app/Http/Controllers/Dashboard/User/UserController.php`
- [Dashboard](https://github.com/realodix/urlhub/blob/master/app/Http/Controllers/Dashboard/DashboardController.php): `app/Http/Controllers/Dashboard/DashboardController.php`

### Domain services

- [General settings](https://github.com/realodix/urlhub/blob/master/app/Settings/GeneralSettings.php): `app/Settings/GeneralSettings.php`
- [Device detection](https://github.com/realodix/urlhub/blob/master/app/Services/DeviceDetectorService.php): `app/Services/DeviceDetectorService.php`

### Other components

- **Visitor**
- [Web routes](https://github.com/realodix/urlhub/blob/master/routes/web.php): `routes/web.php`

## Connections

- Visitor → Web routes: requests routes (evidence: `routes/web.php`)
- Web routes → Link controller: routes requests (evidence: `routes/web.php`)
- Web routes → Redirect controller: routes short links (evidence: `routes/web.php`)
- Web routes → Dashboard: routes dashboard (evidence: `routes/web.php`)
- Web routes → User administration: routes user admin (evidence: `routes/web.php`)
- Link controller → Link validation: validates input (evidence: `app/Http/Controllers/LinkController.php`)
- Link validation → Link rules: uses rules (evidence: `app/Http/Requests/StoreUrlRequest.php`)
- Link controller → Link service: creates links (evidence: `app/Http/Controllers/LinkController.php`)
- Link service → Key generator: generates keys (evidence: `app/Services/LinkService.php`)
- Key generator → Blocked strings: checks blocked keys (evidence: `app/Services/KeyGeneratorService.php`)
- Key generator → Short links: checks key availability (evidence: `app/Services/KeyGeneratorService.php`)
- Link service → Short links: stores links (evidence: `app/Services/LinkService.php`)
- Link service → General settings: reads configuration (evidence: `app/Services/LinkService.php`)
- Link controller → QR generation: generates QR (evidence: `app/Http/Controllers/LinkController.php`)
- Redirect controller → Redirect action: dispatches redirect (evidence: `app/Http/Controllers/RedirectController.php`)
- Redirect action → Record visit: records visit (evidence: `app/Actions/RedirectToDestination.php`)
- Redirect action → Short links: resolves destination (evidence: `app/Actions/RedirectToDestination.php`)
- Redirect action → General settings: reads configuration (evidence: `app/Actions/RedirectToDestination.php`)
- Record visit → Visit analytics: records metrics (evidence: `app/Actions/RecordVisit.php`)
- Record visit → Visit records: writes visit (evidence: `app/Actions/RecordVisit.php`)
- Record visit → Short links: updates link stats (evidence: `app/Actions/RecordVisit.php`)
- Visit analytics → Visit records: queries visits (evidence: `app/Services/VisitService.php`)
- Visit charts → Visit records: reads visit data (evidence: `app/Livewire/Chart/LinkVisitChart.php`)
- Dashboard → Visit analytics: provides analytics (evidence: `app/Http/Controllers/Dashboard/DashboardController.php`)
- Dashboard → Link service: provides link data (evidence: `app/Http/Controllers/Dashboard/DashboardController.php`)
- User administration → Users: manages accounts (evidence: `app/Http/Controllers/Dashboard/User/UserController.php`)
- User service → Users: uses account data (evidence: `app/Services/UserService.php`)
- Record visit → User service: identifies visitor (evidence: `app/Actions/RecordVisit.php`)
- Users → Short links: owns links (evidence: `app/Models/User.php`)
- Short links → Visit records: has visits (evidence: `app/Models/Url.php`)
- Redirect action → Device detection: detects device
