# connect2sazad/url_shortener architecture

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

- Interactive diagram: https://gitdiagram.com/connect2sazad/url_shortener
- Repository: https://github.com/connect2sazad/url_shortener

## Overview

#### Purpose and entry points
This is a PHP URL-shortening and QR-code management application with public short-link handling and an authenticated administration area. Public-facing entry points are `index.php`, `new_shortlink.php`, and `suspended.php`; Apache routing is likely mediated by `.htaccess`. The internal application begins at `in/index.php`, with dedicated login, registration, and logout endpoints.

#### Runtime and persistence boundary
The application runs as server-rendered PHP behind Apache (`.htaccess`, `in/.htaccess`). Shared runtime configuration, constants, database access, and common behavior are centralized in `config.php`, `constants.php`, `db.php`, and `functions.php`. Database schema/bootstrap material is supplied as `url_shortener.sql`; all durable URL, QR, user, profile, and status state is expected to cross the `db.php` boundary.

#### Authentication and account lifecycle
Authentication is separated into page rendering and form processing: `in/login/index.php` presents login while `in/login/auth.php` handles authentication. Registration follows the same shape in `in/register/index.php` and `in/register/signup.php`; the README indicates an email-to-OTP verification step is intended. Session termination is handled by `in/logout/index.php`. Account/profile mutation is exposed through `in/actions/update_profile.php`.

#### Internal portal and role-oriented views
`in/index.php` is the authenticated portal shell, routing users to dashboard and management screens. Dashboard and account views include `in/pages/dashboard.php` and `in/pages/my-account.php`. The page set distinguishes user-facing records from administrative records—for example, `in/pages/users.php`, `in/pages/users-su.php`, `in/pages/admin-su.php`, `in/pages/users-qrs.php`, and `in/pages/admin-qrs.php`—suggesting separate user/admin scopes rather than a standalone API.

#### Short-link lifecycle
Short URLs are created through `in/pages/create-short-url.php` and processed by `in/actions/shorten.php`. Existing records are listed in `in/pages/shortened-urls.php` and controlled through focused mutation actions: `in/actions/url_enable.php`, `in/actions/url_disable.php`, `in/actions/url_delete.php`, and `in/actions/url_change_validity.php`. Public requests reaching root-level handlers (`index.php`, potentially `new_shortlink.php`) resolve a short code, enforce enabled/validity state, and redirect or surface suspension behavior through `suspended.php`.

#### QR-code lifecycle
QR creation and display are centered on `in/pages/create-qr.php` and `in/pages/created-qrs.php`, with persistence performed by `in/actions/qrsaver.php`. QR records have independent status/deletion operations in `in/actions/qr_enable.php`, `in/actions/qr_disable.php`, and `in/actions/qr_delete.php`. Client-side QR rendering support is bundled at `in/assets/extensions/qrcode/qrcode.js`, so QR generation may span browser rendering plus PHP-side record management.

#### Front-end assets and dependencies
The portal uses bundled static assets under `in/assets/`, notably application scripts `in/assets/js/app.js` and styles `in/assets/css/main/app.css`. It includes packaged UI/data-table dependencies such as DataTables (`in/assets/extensions/datatables.net-bs5/`) and notification support (`in/assets/extensions/notify/notify.js`). These are local assets, not evidence of a build-time Node service or external SaaS dependency.

Main entry points: [`in/index.php`](https://github.com/connect2sazad/url_shortener/blob/master/in/index.php) (Portal shell), [`db.php`](https://github.com/connect2sazad/url_shortener/blob/master/db.php) (Database adapter), [`index.php`](https://github.com/connect2sazad/url_shortener/blob/master/index.php) (Public link handlers), [`in/login/auth.php`](https://github.com/connect2sazad/url_shortener/blob/master/in/login/auth.php) (Login and registration)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_public["Public Link Handling"]
  node_apache{{"Apache routing<br/>web server<br/>[.htaccess]"}}
  node_public_handlers["Public link handlers<br/>PHP endpoints<br/>[index.php]"]
  node_suspended["Suspension page<br/>PHP page<br/>[suspended.php]"]
end

subgraph group_runtime["PHP Runtime"]
  node_runtime_bootstrap["Runtime bootstrap<br/>shared PHP<br/>[config.php]"]
  node_db_adapter["Database adapter<br/>PHP persistence<br/>[db.php]"]
end

subgraph group_portal["Authenticated Portal"]
  node_portal_shell["Portal shell<br/>authenticated PHP<br/>[index.php]"]
  node_auth["Login and registration<br/>account endpoints<br/>[auth.php]"]
  node_logout["Logout<br/>session endpoint<br/>[index.php]"]
  node_dashboard_account["Dashboard and account<br/>portal pages<br/>[dashboard.php]"]
  node_profile_update["Profile update<br/>mutation action<br/>[update_profile.php]"]
  node_url_management["Short-link management<br/>portal pages"]
  node_url_actions["Short-link actions<br/>mutation actions<br/>[shorten.php]"]
  node_qr_management["QR management<br/>portal pages<br/>[create-qr.php]"]
  node_qr_actions["QR actions<br/>mutation actions<br/>[qrsaver.php]"]
  node_portal_assets["Portal assets<br/>local browser assets<br/>[app.js]"]
end

subgraph group_persistence["Persistence"]
  node_database[("Application database<br/>relational database<br/>[url_shortener.sql]")]
end

node_apache -->|"routes public requests"| node_public_handlers
node_apache -->|"routes internal requests"| node_portal_shell
node_public_handlers -->|"boots shared runtime"| node_runtime_bootstrap
node_public_handlers -->|"shows when unavailable"| node_suspended
node_portal_shell -->|"boots shared runtime"| node_runtime_bootstrap
node_portal_shell -.->|"requires session"| node_auth
node_auth -.->|"establishes session"| node_logout
node_portal_shell -->|"renders"| node_dashboard_account
node_dashboard_account -->|"submits changes"| node_profile_update
node_portal_shell -->|"renders"| node_url_management
node_url_management -->|"submits mutations"| node_url_actions
node_portal_shell -->|"renders"| node_qr_management
node_qr_management -->|"submits mutations"| node_qr_actions
node_portal_shell -->|"serves UI assets"| node_portal_assets
node_runtime_bootstrap -->|"uses"| node_db_adapter
node_db_adapter -->|"reads and writes"| node_database
node_url_actions -->|"persists link state"| node_db_adapter
node_qr_actions -->|"persists QR state"| node_db_adapter
node_profile_update -->|"persists profile"| node_db_adapter
node_auth -->|"validates accounts"| node_db_adapter

click node_apache "https://github.com/connect2sazad/url_shortener/blob/master/.htaccess"
click node_public_handlers "https://github.com/connect2sazad/url_shortener/blob/master/index.php"
click node_suspended "https://github.com/connect2sazad/url_shortener/blob/master/suspended.php"
click node_runtime_bootstrap "https://github.com/connect2sazad/url_shortener/blob/master/config.php"
click node_db_adapter "https://github.com/connect2sazad/url_shortener/blob/master/db.php"
click node_portal_shell "https://github.com/connect2sazad/url_shortener/blob/master/in/index.php"
click node_auth "https://github.com/connect2sazad/url_shortener/blob/master/in/login/auth.php"
click node_logout "https://github.com/connect2sazad/url_shortener/blob/master/in/logout/index.php"
click node_dashboard_account "https://github.com/connect2sazad/url_shortener/blob/master/in/pages/dashboard.php"
click node_profile_update "https://github.com/connect2sazad/url_shortener/blob/master/in/actions/update_profile.php"
click node_url_management "https://github.com/connect2sazad/url_shortener/blob/master/in/pages/create-short-url.php"
click node_url_actions "https://github.com/connect2sazad/url_shortener/blob/master/in/actions/shorten.php"
click node_qr_management "https://github.com/connect2sazad/url_shortener/blob/master/in/pages/create-qr.php"
click node_qr_actions "https://github.com/connect2sazad/url_shortener/blob/master/in/actions/qrsaver.php"
click node_portal_assets "https://github.com/connect2sazad/url_shortener/blob/master/in/assets/js/app.js"
click node_database "https://github.com/connect2sazad/url_shortener/blob/master/url_shortener.sql"

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_apache,node_public_handlers,node_suspended toneBlue
class node_runtime_bootstrap,node_db_adapter toneAmber
class node_portal_shell,node_auth,node_logout,node_dashboard_account,node_profile_update,node_url_management,node_url_actions,node_qr_management,node_qr_actions,node_portal_assets toneMint
class node_database toneRose
```

## Components

### Public Link Handling

- [Apache routing](https://github.com/connect2sazad/url_shortener/blob/master/.htaccess): web server · Routes public and internal PHP requests. · `.htaccess`
- [Public link handlers](https://github.com/connect2sazad/url_shortener/blob/master/index.php): PHP endpoints · Resolve short codes, redirect targets, or show suspension. · `index.php`
- [Suspension page](https://github.com/connect2sazad/url_shortener/blob/master/suspended.php): PHP page · `suspended.php`

### PHP Runtime

- [Runtime bootstrap](https://github.com/connect2sazad/url_shortener/blob/master/config.php): shared PHP · Provides configuration, constants, shared behavior, and database access. · `config.php`
- [Database adapter](https://github.com/connect2sazad/url_shortener/blob/master/db.php): PHP persistence · Durable state crosses this database boundary. · `db.php`

### Authenticated Portal

- [Portal shell](https://github.com/connect2sazad/url_shortener/blob/master/in/index.php): authenticated PHP · Entry point for dashboard and management screens. · `in/index.php`
- [Login and registration](https://github.com/connect2sazad/url_shortener/blob/master/in/login/auth.php): account endpoints · Renders credentials forms and processes authentication and signup. · `in/login/auth.php`
- [Logout](https://github.com/connect2sazad/url_shortener/blob/master/in/logout/index.php): session endpoint · `in/logout/index.php`
- [Dashboard and account](https://github.com/connect2sazad/url_shortener/blob/master/in/pages/dashboard.php): portal pages · Shows dashboard/account views and profile updates. · `in/pages/dashboard.php`
- [Profile update](https://github.com/connect2sazad/url_shortener/blob/master/in/actions/update_profile.php): mutation action · `in/actions/update_profile.php`
- [Short-link management](https://github.com/connect2sazad/url_shortener/blob/master/in/pages/create-short-url.php): portal pages · Creates and lists user or administrative short-link records. · `in/pages/create-short-url.php`
- [Short-link actions](https://github.com/connect2sazad/url_shortener/blob/master/in/actions/shorten.php): mutation actions · Creates links and changes enabled, validity, or deletion state. · `in/actions/shorten.php`
- [QR management](https://github.com/connect2sazad/url_shortener/blob/master/in/pages/create-qr.php): portal pages · Creates and lists QR records across user and admin scopes. · `in/pages/create-qr.php`
- [QR actions](https://github.com/connect2sazad/url_shortener/blob/master/in/actions/qrsaver.php): mutation actions · Persists QR records and changes enabled or deletion state. · `in/actions/qrsaver.php`
- [Portal assets](https://github.com/connect2sazad/url_shortener/blob/master/in/assets/js/app.js): local browser assets · Provides application UI, data tables, notifications, and QR rendering. · `in/assets/js/app.js`

### Persistence

- [Application database](https://github.com/connect2sazad/url_shortener/blob/master/url_shortener.sql): relational database · Stores URLs, QR codes, users, profiles, and status. · `url_shortener.sql`

## Connections

- Apache routing → Public link handlers: routes public requests
- Apache routing → Portal shell: routes internal requests
- Public link handlers → Runtime bootstrap: boots shared runtime
- Public link handlers → Suspension page: shows when unavailable
- Portal shell → Runtime bootstrap: boots shared runtime
- Portal shell → Login and registration: requires session
- Login and registration → Logout: establishes session
- Portal shell → Dashboard and account: renders
- Dashboard and account → Profile update: submits changes
- Portal shell → Short-link management: renders
- Short-link management → Short-link actions: submits mutations
- Portal shell → QR management: renders
- QR management → QR actions: submits mutations
- Portal shell → Portal assets: serves UI assets
- Runtime bootstrap → Database adapter: uses
- Database adapter → Application database: reads and writes
- Short-link actions → Database adapter: persists link state
- QR actions → Database adapter: persists QR state
- Profile update → Database adapter: persists profile
- Login and registration → Database adapter: validates accounts
