# azizulbsc/url_shortener architecture

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

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

## Overview

##### Main Components

a. Client Layer:
- Web Browser Interface (Frontend)
- API Clients (Postman as mentioned in the README)

b. Web Server Layer:
- Nginx Server (evident from .docker/nginx configuration)
- SSL/HTTPS Support (shown by self-signed certificates)

c. Application Layer:
- Laravel Framework Components
- Authentication System
- URL Shortener Service
- Route Handlers
- Middleware Stack

d. Database Layer:
- MySQL/PostgreSQL (based on Laravel's typical setup)
- Key Tables:
- users
- urls
- personal_access_tokens
- failed_jobs

##### Component Relationships

- Client → Nginx → Laravel Application
- Laravel Application ↔ Database
- Authentication Flow: Client → Auth Controller → Users Table
- URL Shortening Flow: Client → URL Controller → URLs Table

##### Architectural Patterns to Highlight

- MVC Pattern:
- Models: app/Models/
- Views: resources/views/
- Controllers: app/Http/Controllers/

- Service Layer:
- Auth Services
- URL Shortening Services

##### Specific Implementation Details

a. Frontend Components:
- Authentication Views (login, register)
- URL Management Views (create, edit, index, show)
- Layout Templates

b. Backend Components:
- Route Handlers (web.php, api.php)
- Controllers (AuthController, UrlController)
- Middleware Stack
- Database Models (User, Url)

##### Additional Elements

Annotations for:
- Docker containerization
- API endpoints
- Authentication flows
- URL shortening process
- Database relationships

##### Technical Specifications

Technical aspects:
- Laravel Framework
- Docker Containerization
- Nginx Web Server
- Database System
- API Authentication (Sanctum)

- System boundaries
- Data flow
- Security measures
- Key business logic components
- Infrastructure setup

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client
        Browser["Web Browser"]:::frontend
        APIClient["API Client\n(Postman)"]:::api
    end

    subgraph WebServer
        Nginx["Nginx Server"]:::server
        SSL["SSL/HTTPS"]:::security
    end
    
    subgraph Application
        direction TB
        Routes["Route Handlers"]:::backend
        Auth["Authentication System"]:::security
        URLService["URL Shortener Service"]:::backend
        Middleware["Middleware Stack"]:::security
        
        subgraph Views
            AuthViews["Authentication Views"]:::frontend
            URLViews["URL Management Views"]:::frontend
            Layouts["Layout Templates"]:::frontend
        end
        
        subgraph Controllers
            AuthController["Auth Controller"]:::backend
            URLController["URL Controller"]:::backend
        end
        
        subgraph Models
            UserModel["User Model"]:::model
            URLModel["URL Model"]:::model
        end
    end
    
    subgraph Database
        Users[(Users Table)]:::database
        URLs[(URLs Table)]:::database
        PAT[(Personal Access Tokens)]:::database
        FailedJobs[(Failed Jobs)]:::database
    end

    Browser --> Nginx
    APIClient --> Nginx
    Nginx --> SSL
    SSL --> Routes
    
    Routes --> Auth
    Routes --> URLService
    Routes --> Middleware
    
    Auth --> AuthController
    URLService --> URLController
    
    AuthController --> UserModel
    URLController --> URLModel
    
    UserModel --> Users
    URLModel --> URLs
    Auth --> PAT
    
    AuthController --> AuthViews
    URLController --> URLViews
    
    %% Click Events
    click Nginx "https://github.com/AzizulBSc/url_shortener/blob/main/.docker/nginx/default.conf"
    click SSL "https://github.com/AzizulBSc/url_shortener/tree/main/.docker/nginx/ssl/"
    click Auth "https://github.com/AzizulBSc/url_shortener/blob/main/app/Http/Controllers/AuthController.php"
    click AuthViews "https://github.com/AzizulBSc/url_shortener/tree/main/resources/views/auth/"
    click Users "https://github.com/AzizulBSc/url_shortener/blob/main/database/migrations/2014_10_12_000000_create_users_table.php"
    click UserModel "https://github.com/AzizulBSc/url_shortener/blob/main/app/Models/User.php"
    click URLController "https://github.com/AzizulBSc/url_shortener/blob/main/app/Http/Controllers/UrlController.php"
    click URLModel "https://github.com/AzizulBSc/url_shortener/blob/main/app/Models/Url.php"
    click URLs "https://github.com/AzizulBSc/url_shortener/blob/main/database/migrations/2024_01_16_100403_create_urls_table.php"
    click URLViews "https://github.com/AzizulBSc/url_shortener/tree/main/resources/views/backend/urls/"
    click Layouts "https://github.com/AzizulBSc/url_shortener/blob/main/resources/views/auth/layouts.blade.php"
    click Routes "https://github.com/AzizulBSc/url_shortener/blob/main/routes/web.php"
    click Middleware "https://github.com/AzizulBSc/url_shortener/tree/main/app/Http/Middleware/"
    click APIClient "https://github.com/AzizulBSc/url_shortener/blob/main/Url_Shortner.postman_collection.json"
    
    %% Styles
    classDef frontend fill:#3498db,stroke:#2980b9,color:white
    classDef backend fill:#2ecc71,stroke:#27ae60,color:white
    classDef database fill:#f1c40f,stroke:#f39c12,color:black
    classDef security fill:#e74c3c,stroke:#c0392b,color:white
    classDef server fill:#95a5a6,stroke:#7f8c8d,color:white
    classDef api fill:#9b59b6,stroke:#8e44ad,color:white
    classDef model fill:#1abc9c,stroke:#16a085,color:white
```
