# kayamuhammet/urlshortener architecture

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

- Interactive diagram: https://gitdiagram.com/kayamuhammet/urlshortener
- Repository: https://github.com/kayamuhammet/urlshortener

## Overview

##### Project type and purpose
- This is a full-stack, server-rendered ASP.NET Core 7.0 MVC web application with a single SQLite database.
- Purpose: shorten URLs, track clicks, optionally generate custom slugs, and produce downloadable QR codes.

##### File structure
- Top-level Web App (“UrlShortener” folder) containing:
- Controllers (HomeController.cs)
- Models (UrlModel, ShortenUrlRequest)
- Data (AppDbContext)
- Services (IUrlService/UrlService, IQrCodeService/QrCodeService)
- Views (Razor .cshtml)
- wwwroot (static CSS/JS/lib like Bootstrap, jQuery, SweetAlert2, Clipboard.js)
- Program.cs & appsettings.json (app startup & configuration)
- EF Core migrations and DB context live in Data folder, configured to use SQLite.

##### README for additional insights
- Confirms tech stack: ASP.NET Core MVC, EF Core, SQLite, Bootstrap 5, QRCoder, Clipboard.js, SweetAlert2.
- Features: URL creation, listing, click count, QR code generation & download, responsive UI.

##### Essential elements
- Labels: component names and technology (e.g., “UrlService (C# + DI)”)
- Optional: highlight cross-cutting concerns (logging, configuration from appsettings.json)

## Diagram (Mermaid)

```mermaid
graph TD
    %% Client Layer
    subgraph "Client Browser" 
        direction TB
        Browser["Client Browser UI"]:::client
        subgraph "Static Assets" 
            direction TB
            CSS["site.css"]:::client
            JS["site.js"]:::client
            Bootstrap["bootstrap"]:::client
            jQuery["jquery"]:::client
            jQueryVal["jquery-validation"]:::client
            jQueryUnVal["jquery-validation-unobtrusive"]:::client
        end
    end

    %% Server Layer
    subgraph "ASP.NET Core Server"
        direction TB
        Program["Program.cs"]:::server
        AppSettings["appsettings.json"]:::server
        Launch["launchSettings.json"]:::server
        HomeController["HomeController"]:::server

        subgraph "Services"
            direction TB
            IUrlService["IUrlService"]:::server
            UrlService["UrlService"]:::server
            IQrCodeService["IQrCodeService"]:::server
            QrCodeService["QrCodeService"]:::server
        end

        subgraph "Data Access"
            direction TB
            AppDbContext["AppDbContext"]:::data
            UrlModel["UrlModel"]:::data
            ShortenUrlRequest["ShortenUrlRequest"]:::data
        end

        subgraph "Views"
            direction TB
            IndexView["Index.cshtml"]:::server
            LayoutView["_Layout.cshtml"]:::server
            ValidationPartial["_ValidationScriptsPartial.cshtml"]:::server
            ViewImports["_ViewImports.cshtml"]:::server
            ViewStart["_ViewStart.cshtml"]:::server
        end
    end

    %% Persistence and External
    DB["SQLite Database File"]:::data
    QRCoderLib["QRCoder (NuGet)"]:::external

    %% Relationships
    Browser -->|GET /, POST /shorten| Program
    Program -->|dependency injection| HomeController
    HomeController -->|renders view| IndexView
    HomeController -->|uses| UrlService
    HomeController -->|uses| QrCodeService
    UrlService -->|CRUD operations| AppDbContext
    AppDbContext -->|manages models| UrlModel
    AppDbContext -->|manages DTO| ShortenUrlRequest
    AppDbContext -->|persists to| DB
    QrCodeService -->|calls| QRCoderLib
    Browser -->|loads| CSS
    Browser -->|loads| JS
    Browser -->|loads| Bootstrap
    Browser -->|loads| jQuery
    Browser -->|loads| jQueryVal
    Browser -->|loads| jQueryUnVal

    %% Click Events
    click Browser "https://github.com/kayamuhammet/urlshortener/tree/main/UrlShortener/wwwroot"
    click CSS "https://github.com/kayamuhammet/urlshortener/blob/main/UrlShortener/wwwroot/css/site.css"
    click JS "https://github.com/kayamuhammet/urlshortener/blob/main/UrlShortener/wwwroot/js/site.js"
    click Bootstrap "https://github.com/kayamuhammet/urlshortener/tree/main/UrlShortener/wwwroot/lib/bootstrap"
    click jQuery "https://github.com/kayamuhammet/urlshortener/tree/main/UrlShortener/wwwroot/lib/jquery"
    click jQueryVal "https://github.com/kayamuhammet/urlshortener/tree/main/UrlShortener/wwwroot/lib/jquery-validation"
    click jQueryUnVal "https://github.com/kayamuhammet/urlshortener/tree/main/UrlShortener/wwwroot/lib/jquery-validation-unobtrusive"
    click Program "https://github.com/kayamuhammet/urlshortener/blob/main/UrlShortener/Program.cs"
    click AppSettings "https://github.com/kayamuhammet/urlshortener/blob/main/UrlShortener/appsettings.json"
    click Launch "https://github.com/kayamuhammet/urlshortener/blob/main/UrlShortener/Properties/launchSettings.json"
    click HomeController "https://github.com/kayamuhammet/urlshortener/blob/main/UrlShortener/Controllers/HomeController.cs"
    click IUrlService "https://github.com/kayamuhammet/urlshortener/blob/main/UrlShortener/Services/IUrlService.cs"
    click UrlService "https://github.com/kayamuhammet/urlshortener/blob/main/UrlShortener/Services/UrlService.cs"
    click IQrCodeService "https://github.com/kayamuhammet/urlshortener/blob/main/UrlShortener/Services/IQrCodeService.cs"
    click QrCodeService "https://github.com/kayamuhammet/urlshortener/blob/main/UrlShortener/Services/QrCodeService.cs"
    click AppDbContext "https://github.com/kayamuhammet/urlshortener/blob/main/UrlShortener/Data/AppDbContext.cs"
    click UrlModel "https://github.com/kayamuhammet/urlshortener/blob/main/UrlShortener/Models/UrlModel.cs"
    click ShortenUrlRequest "https://github.com/kayamuhammet/urlshortener/blob/main/UrlShortener/Models/ShortenUrlRequest.cs"
    click IndexView "https://github.com/kayamuhammet/urlshortener/blob/main/UrlShortener/Views/Home/Index.cshtml"
    click LayoutView "https://github.com/kayamuhammet/urlshortener/blob/main/UrlShortener/Views/Shared/_Layout.cshtml"
    click ValidationPartial "https://github.com/kayamuhammet/urlshortener/blob/main/UrlShortener/Views/Shared/_ValidationScriptsPartial.cshtml"
    click ViewImports "https://github.com/kayamuhammet/urlshortener/blob/main/UrlShortener/Views/_ViewImports.cshtml"
    click ViewStart "https://github.com/kayamuhammet/urlshortener/blob/main/UrlShortener/Views/_ViewStart.cshtml"
    click DB "https://github.com/kayamuhammet/urlshortener/blob/main/UrlShortener/appsettings.json"
    click QRCoderLib "https://github.com/kayamuhammet/urlshortener/blob/main/UrlShortener/Services/QrCodeService.cs"

    %% Styles
    classDef client fill:#cce5ff,stroke:#004085
    classDef server fill:#d4edda,stroke:#155724
    classDef data fill:#fff3cd,stroke:#856404
    classDef external fill:#e2e3e5,stroke:#d6d8db
```
