# sunnyenglishh/url-shortener architecture

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

- Interactive diagram: https://gitdiagram.com/sunnyenglishh/url-shortener
- Repository: https://github.com/sunnyenglishh/url-shortener

## Overview

This Laravel application manages company-scoped URL shortening: users create links, access is filtered by role and company, and visitors follow public short links to their destinations. Separate flows cover company administration and invitations, with registration/authentication supporting membership. The graph reflects the README and sampled controllers; route wiring and several unsampled subsystems are represented only where their paths or capabilities are evident.

Main entry points: [`routes/web.php`](https://github.com/sunnyenglishh/url-shortener/blob/main/routes/web.php) (HTTP routes), [`app/Http/Controllers/CompanyController.php`](https://github.com/sunnyenglishh/url-shortener/blob/main/app/Http/Controllers/CompanyController.php) (Company management), [`app/Http/Controllers/DashboardController.php`](https://github.com/sunnyenglishh/url-shortener/blob/main/app/Http/Controllers/DashboardController.php) (Role dashboard), [`app/Http/Controllers/InvitationController.php`](https://github.com/sunnyenglishh/url-shortener/blob/main/app/Http/Controllers/InvitationController.php) (Invitation registration)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_access["Access and membership"]
  node_auth["Authentication setup"]
  node_registration["User registration<br/>[CreateNewUser.php]"]
  node_role["Role checks<br/>[RoleMiddleware.php]"]
  node_invitation_controller["Invitation registration"]
  node_user_model["Users<br/>[User.php]"]
  node_api_tokens["API token screens"]
end

subgraph group_links["Short URL lifecycle"]
  node_short_controller["Short URL actions"]
  node_dashboard["Role dashboard"]
  node_short_model["Short links<br/>[ShortUrl.php]"]
  node_dashboard_view["Dashboard screens"]
end

subgraph group_companies["Company administration"]
  node_companies_controller["Company management"]
  node_invitation_mail["Invitation email"]
  node_company_model["Companies<br/>[Company.php]"]
  node_invitation_model["Invitations<br/>[Invitation.php]"]
  node_company_views["Company screens<br/>[index.blade.php]"]
end

subgraph group_platform["Persistence and UI"]
  node_routes["HTTP routes<br/>[web.php]"]
  node_database[("Application database<br/>[database.php]")]
end

node_user(("User"))
node_destination(("Original URL"))
node_mail_service(("Mail service"))

node_user -->|"sends request"| node_routes
node_routes -->|"authenticates"| node_auth
node_auth -->|"registers users"| node_registration
node_routes -->|"checks role"| node_role
node_routes -->|"dispatches"| node_short_controller
node_short_controller -->|"creates and queries"| node_short_model
node_short_model -->|"persists links"| node_database
node_short_controller -->|"redirects visitor"| node_destination
node_routes -->|"dispatches"| node_companies_controller
node_companies_controller -->|"manages companies"| node_company_model
node_companies_controller -->|"creates invitations"| node_invitation_model
node_companies_controller -->|"sends invitation"| node_invitation_mail
node_invitation_mail -->|"delivers email"| node_mail_service
node_routes -->|"dispatches"| node_invitation_controller
node_invitation_controller -->|"uses invitation"| node_invitation_model
node_invitation_controller -->|"registers member"| node_user_model
node_companies_controller -->|"lists company users"| node_user_model
node_routes -->|"dispatches"| node_dashboard
node_dashboard -->|"loads companies"| node_company_model
node_dashboard -->|"loads links"| node_short_model
node_dashboard -->|"loads team"| node_user_model
node_companies_controller -->|"renders screens"| node_company_views
node_dashboard -->|"renders dashboard"| node_dashboard_view

click node_routes "https://github.com/sunnyenglishh/url-shortener/blob/main/routes/web.php"
click node_auth "https://github.com/sunnyenglishh/url-shortener/blob/main/app/Providers/FortifyServiceProvider.php"
click node_registration "https://github.com/sunnyenglishh/url-shortener/blob/main/app/Actions/Fortify/CreateNewUser.php"
click node_role "https://github.com/sunnyenglishh/url-shortener/blob/main/app/Http/Middleware/RoleMiddleware.php"
click node_companies_controller "https://github.com/sunnyenglishh/url-shortener/blob/main/app/Http/Controllers/CompanyController.php"
click node_invitation_controller "https://github.com/sunnyenglishh/url-shortener/blob/main/app/Http/Controllers/InvitationController.php"
click node_invitation_mail "https://github.com/sunnyenglishh/url-shortener/blob/main/app/Mail/UserInvitationMail.php"
click node_short_controller "https://github.com/sunnyenglishh/url-shortener/blob/main/app/Http/Controllers/ShortUrlController.php"
click node_dashboard "https://github.com/sunnyenglishh/url-shortener/blob/main/app/Http/Controllers/DashboardController.php"
click node_company_model "https://github.com/sunnyenglishh/url-shortener/blob/main/app/Models/Company.php"
click node_invitation_model "https://github.com/sunnyenglishh/url-shortener/blob/main/app/Models/Invitation.php"
click node_user_model "https://github.com/sunnyenglishh/url-shortener/blob/main/app/Models/User.php"
click node_short_model "https://github.com/sunnyenglishh/url-shortener/blob/main/app/Models/ShortUrl.php"
click node_database "https://github.com/sunnyenglishh/url-shortener/blob/main/config/database.php"
click node_company_views "https://github.com/sunnyenglishh/url-shortener/blob/main/resources/views/companies/index.blade.php"
click node_dashboard_view "https://github.com/sunnyenglishh/url-shortener/blob/main/resources/views/dashboard.blade.php"
click node_api_tokens "https://github.com/sunnyenglishh/url-shortener/blob/main/resources/views/api/api-token-manager.blade.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_auth,node_registration,node_role,node_invitation_controller,node_user_model,node_api_tokens,node_user toneBlue
class node_short_controller,node_dashboard,node_short_model,node_dashboard_view toneAmber
class node_companies_controller,node_invitation_mail,node_company_model,node_invitation_model,node_company_views toneMint
class node_routes,node_database toneRose
class node_destination,node_mail_service toneIndigo
```

## Components

### Access and membership

- [Authentication setup](https://github.com/sunnyenglishh/url-shortener/blob/main/app/Providers/FortifyServiceProvider.php): `app/Providers/FortifyServiceProvider.php`
- [User registration](https://github.com/sunnyenglishh/url-shortener/blob/main/app/Actions/Fortify/CreateNewUser.php): `app/Actions/Fortify/CreateNewUser.php`
- [Role checks](https://github.com/sunnyenglishh/url-shortener/blob/main/app/Http/Middleware/RoleMiddleware.php): `app/Http/Middleware/RoleMiddleware.php`
- [Invitation registration](https://github.com/sunnyenglishh/url-shortener/blob/main/app/Http/Controllers/InvitationController.php): `app/Http/Controllers/InvitationController.php`
- [Users](https://github.com/sunnyenglishh/url-shortener/blob/main/app/Models/User.php): `app/Models/User.php`
- [API token screens](https://github.com/sunnyenglishh/url-shortener/blob/main/resources/views/api/api-token-manager.blade.php): `resources/views/api/api-token-manager.blade.php`

### Short URL lifecycle

- [Short URL actions](https://github.com/sunnyenglishh/url-shortener/blob/main/app/Http/Controllers/ShortUrlController.php): `app/Http/Controllers/ShortUrlController.php`
- [Role dashboard](https://github.com/sunnyenglishh/url-shortener/blob/main/app/Http/Controllers/DashboardController.php): `app/Http/Controllers/DashboardController.php`
- [Short links](https://github.com/sunnyenglishh/url-shortener/blob/main/app/Models/ShortUrl.php): `app/Models/ShortUrl.php`
- [Dashboard screens](https://github.com/sunnyenglishh/url-shortener/blob/main/resources/views/dashboard.blade.php): `resources/views/dashboard.blade.php`

### Company administration

- [Company management](https://github.com/sunnyenglishh/url-shortener/blob/main/app/Http/Controllers/CompanyController.php): `app/Http/Controllers/CompanyController.php`
- [Invitation email](https://github.com/sunnyenglishh/url-shortener/blob/main/app/Mail/UserInvitationMail.php): `app/Mail/UserInvitationMail.php`
- [Companies](https://github.com/sunnyenglishh/url-shortener/blob/main/app/Models/Company.php): `app/Models/Company.php`
- [Invitations](https://github.com/sunnyenglishh/url-shortener/blob/main/app/Models/Invitation.php): `app/Models/Invitation.php`
- [Company screens](https://github.com/sunnyenglishh/url-shortener/blob/main/resources/views/companies/index.blade.php): `resources/views/companies/index.blade.php`

### Persistence and UI

- [HTTP routes](https://github.com/sunnyenglishh/url-shortener/blob/main/routes/web.php): `routes/web.php`
- [Application database](https://github.com/sunnyenglishh/url-shortener/blob/main/config/database.php): `config/database.php`

### Other components

- **User**
- **Original URL**
- **Mail service**

## Connections

- User → HTTP routes: sends request
- HTTP routes → Authentication setup: authenticates
- Authentication setup → User registration: registers users
- HTTP routes → Role checks: checks role
- HTTP routes → Short URL actions: dispatches
- Short URL actions → Short links: creates and queries
- Short links → Application database: persists links
- Short URL actions → Original URL: redirects visitor
- HTTP routes → Company management: dispatches
- Company management → Companies: manages companies
- Company management → Invitations: creates invitations
- Company management → Invitation email: sends invitation
- Invitation email → Mail service: delivers email
- HTTP routes → Invitation registration: dispatches
- Invitation registration → Invitations: uses invitation
- Invitation registration → Users: registers member
- Company management → Users: lists company users
- HTTP routes → Role dashboard: dispatches
- Role dashboard → Companies: loads companies
- Role dashboard → Short links: loads links
- Role dashboard → Users: loads team
- Company management → Company screens: renders screens
- Role dashboard → Dashboard screens: renders dashboard
