# shravanashok16/urlshortener architecture

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

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

## Overview

This is a layered .NET URL-shortening API. Users register or log in to obtain JWTs; link endpoints create and list short URLs, redirect requests record click metadata before redirecting, and deletion deactivates links. The README also documents pagination, click counts, hashed IP storage, and persistence in Neon/PostgreSQL. The excerpts show the controller, token, and EF Core interactions; database hosting and endpoint behavior beyond those excerpts are based on README documentation.

Main entry points: [`UrlShortener.Api/Controllers/LinksController.cs`](https://github.com/shravanashok16/urlshortener/blob/main/UrlShortener.Api/Controllers/LinksController.cs) (Link operations), [`UrlShortener.Infrastructure/Data/AppDbContext.cs`](https://github.com/shravanashok16/urlshortener/blob/main/UrlShortener.Infrastructure/Data/AppDbContext.cs) (EF Core context), [`UrlShortener.Api/Controllers/AuthController.cs`](https://github.com/shravanashok16/urlshortener/blob/main/UrlShortener.Api/Controllers/AuthController.cs) (Authentication), [`UrlShortener.Api/Program.cs`](https://github.com/shravanashok16/urlshortener/blob/main/UrlShortener.Api/Program.cs) (Application setup)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["HTTP API"]
  node_auth["Authentication<br/>[AuthController.cs]"]
  node_links["Link operations<br/>[LinksController.cs]"]
  node_token["JWT issuer<br/>[TokenService.cs]"]
  node_models["Request and response DTOs<br/>[Models]"]
  node_startup["Application setup<br/>[Program.cs]"]
end

subgraph group_domain["Domain"]
  node_codes["Short-code generator"]
  node_entities["User, link, click<br/>[Entities]"]
end

subgraph group_persistence["Persistence"]
  node_context["EF Core context<br/>[AppDbContext.cs]"]
  node_postgres[("Neon PostgreSQL")]
end

node_user(("API client"))

node_user -->|"register or log in"| node_auth
node_user -->|"manage links"| node_links
node_auth -->|"checks and saves users"| node_context
node_auth -->|"issues token"| node_token
node_auth -->|"uses auth DTOs"| node_models
node_links -->|"generates code"| node_codes
node_links -->|"queries and saves"| node_context
node_links -->|"uses link DTOs"| node_models
node_links -->|"creates click records"| node_entities
node_context -->|"maps entity sets"| node_entities
node_startup -->|"configures PostgreSQL"| node_context
node_startup -->|"registers service"| node_token
node_context -->|"persists application data"| node_postgres

click node_auth "https://github.com/shravanashok16/urlshortener/blob/main/UrlShortener.Api/Controllers/AuthController.cs"
click node_links "https://github.com/shravanashok16/urlshortener/blob/main/UrlShortener.Api/Controllers/LinksController.cs"
click node_token "https://github.com/shravanashok16/urlshortener/blob/main/UrlShortener.Api/Services/TokenService.cs"
click node_models "https://github.com/shravanashok16/urlshortener/tree/main/UrlShortener.Api/Models"
click node_startup "https://github.com/shravanashok16/urlshortener/blob/main/UrlShortener.Api/Program.cs"
click node_codes "https://github.com/shravanashok16/urlshortener/blob/main/UrlShortener.Core/Services/ShortCodeGenerator.cs"
click node_entities "https://github.com/shravanashok16/urlshortener/tree/main/UrlShortener.Core/Entities"
click node_context "https://github.com/shravanashok16/urlshortener/blob/main/UrlShortener.Infrastructure/Data/AppDbContext.cs"

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_links,node_token,node_models,node_startup,node_user toneBlue
class node_codes,node_entities toneAmber
class node_context,node_postgres toneMint
```

## Components

### HTTP API

- [Authentication](https://github.com/shravanashok16/urlshortener/blob/main/UrlShortener.Api/Controllers/AuthController.cs): `UrlShortener.Api/Controllers/AuthController.cs`
- [Link operations](https://github.com/shravanashok16/urlshortener/blob/main/UrlShortener.Api/Controllers/LinksController.cs): `UrlShortener.Api/Controllers/LinksController.cs`
- [JWT issuer](https://github.com/shravanashok16/urlshortener/blob/main/UrlShortener.Api/Services/TokenService.cs): `UrlShortener.Api/Services/TokenService.cs`
- [Request and response DTOs](https://github.com/shravanashok16/urlshortener/tree/main/UrlShortener.Api/Models): `UrlShortener.Api/Models`
- [Application setup](https://github.com/shravanashok16/urlshortener/blob/main/UrlShortener.Api/Program.cs): `UrlShortener.Api/Program.cs`

### Domain

- [Short-code generator](https://github.com/shravanashok16/urlshortener/blob/main/UrlShortener.Core/Services/ShortCodeGenerator.cs): `UrlShortener.Core/Services/ShortCodeGenerator.cs`
- [User, link, click](https://github.com/shravanashok16/urlshortener/tree/main/UrlShortener.Core/Entities): `UrlShortener.Core/Entities`

### Persistence

- [EF Core context](https://github.com/shravanashok16/urlshortener/blob/main/UrlShortener.Infrastructure/Data/AppDbContext.cs): `UrlShortener.Infrastructure/Data/AppDbContext.cs`
- **Neon PostgreSQL**

### Other components

- **API client**

## Connections

- API client → Authentication: register or log in (evidence: `README.md`)
- API client → Link operations: manage links (evidence: `README.md`)
- Authentication → EF Core context: checks and saves users (evidence: `UrlShortener.Api/Controllers/AuthController.cs`)
- Authentication → JWT issuer: issues token (evidence: `UrlShortener.Api/Controllers/AuthController.cs`)
- Authentication → Request and response DTOs: uses auth DTOs (evidence: `UrlShortener.Api/Controllers/AuthController.cs`)
- Link operations → Short-code generator: generates code (evidence: `UrlShortener.Api/Controllers/LinksController.cs`)
- Link operations → EF Core context: queries and saves (evidence: `UrlShortener.Api/Controllers/LinksController.cs`)
- Link operations → Request and response DTOs: uses link DTOs (evidence: `UrlShortener.Api/Controllers/LinksController.cs`)
- Link operations → User, link, click: creates click records (evidence: `UrlShortener.Api/Controllers/LinksController.cs`)
- EF Core context → User, link, click: maps entity sets (evidence: `UrlShortener.Infrastructure/Data/AppDbContext.cs`)
- Application setup → EF Core context: configures PostgreSQL (evidence: `UrlShortener.Api/Program.cs`)
- Application setup → JWT issuer: registers service (evidence: `UrlShortener.Api/Program.cs`)
- EF Core context → Neon PostgreSQL: persists application data (evidence: `README.md`)
