# miccaaz/url-shortener-api architecture

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

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

## Overview

This is a small ASP.NET URL-shortening service. A client submits a URL to the shorten endpoint; the endpoint validates it, asks the code-generation service for an unused code, and stores a shortened-URL record. A later request looks up that code and redirects the client to the original URL. The excerpts show EF Core persistence configured for PostgreSQL and development-time migration application. The README documents no additional capabilities; migrations and configuration files were not sampled.

Main entry points: [`UrlShortener.API/Program.cs`](https://github.com/miccaaz/url-shortener-api/blob/main/UrlShortener.API/Program.cs) (Shorten endpoint), [`UrlShortener.API/Infrastructure/AppDbContext.cs`](https://github.com/miccaaz/url-shortener-api/blob/main/UrlShortener.API/Infrastructure/AppDbContext.cs) (EF context), [`UrlShortener.API/Services/UrlShortenerService.cs`](https://github.com/miccaaz/url-shortener-api/blob/main/UrlShortener.API/Services/UrlShortenerService.cs) (Code generator), [`UrlShortener.API/Extensions/MigrationExtension.cs`](https://github.com/miccaaz/url-shortener-api/blob/main/UrlShortener.API/Extensions/MigrationExtension.cs) (Migration extension)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["HTTP API"]
  node_shorten["Shorten endpoint<br/>[Program.cs]"]
  node_validate["URL validation<br/>[Program.cs]"]
  node_redirect["Redirect endpoint<br/>[Program.cs]"]
end

subgraph group_domain["Shortening"]
  node_request["Shorten request"]
  node_generator["Code generator"]
  node_url_record["Short URL record<br/>[ShortenedUrl.cs]"]
end

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

node_client(("Client"))

node_client -->|"submits URL"| node_shorten
node_shorten -->|"binds request"| node_request
node_shorten -->|"validates URL"| node_validate
node_shorten -->|"requests code"| node_generator
node_generator -->|"checks code"| node_context
node_shorten -->|"creates record"| node_url_record
node_shorten -->|"saves record"| node_context
node_redirect -->|"looks up code"| node_context
node_redirect -->|"redirects"| node_client
node_context -->|"maps entity"| node_url_record
node_shorten -->|"returns short URL"| node_client
node_shorten -->|"configures provider"| node_postgres
node_shorten -->|"applies in development"| node_migrations
node_migrations -->|"runs migrations"| node_context
node_client -->|"requests code"| node_redirect

click node_shorten "https://github.com/miccaaz/url-shortener-api/blob/main/UrlShortener.API/Program.cs"
click node_validate "https://github.com/miccaaz/url-shortener-api/blob/main/UrlShortener.API/Program.cs"
click node_redirect "https://github.com/miccaaz/url-shortener-api/blob/main/UrlShortener.API/Program.cs"
click node_request "https://github.com/miccaaz/url-shortener-api/blob/main/UrlShortener.API/Models/ShortenedUrlRequest.cs"
click node_generator "https://github.com/miccaaz/url-shortener-api/blob/main/UrlShortener.API/Services/UrlShortenerService.cs"
click node_url_record "https://github.com/miccaaz/url-shortener-api/blob/main/UrlShortener.API/Entities/ShortenedUrl.cs"
click node_context "https://github.com/miccaaz/url-shortener-api/blob/main/UrlShortener.API/Infrastructure/AppDbContext.cs"
click node_migrations "https://github.com/miccaaz/url-shortener-api/blob/main/UrlShortener.API/Extensions/MigrationExtension.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_shorten,node_validate,node_redirect,node_client toneBlue
class node_request,node_generator,node_url_record toneAmber
class node_context,node_postgres,node_migrations toneMint
```

## Components

### HTTP API

- [Shorten endpoint](https://github.com/miccaaz/url-shortener-api/blob/main/UrlShortener.API/Program.cs): `UrlShortener.API/Program.cs`
- [URL validation](https://github.com/miccaaz/url-shortener-api/blob/main/UrlShortener.API/Program.cs): `UrlShortener.API/Program.cs`
- [Redirect endpoint](https://github.com/miccaaz/url-shortener-api/blob/main/UrlShortener.API/Program.cs): `UrlShortener.API/Program.cs`

### Shortening

- [Shorten request](https://github.com/miccaaz/url-shortener-api/blob/main/UrlShortener.API/Models/ShortenedUrlRequest.cs): `UrlShortener.API/Models/ShortenedUrlRequest.cs`
- [Code generator](https://github.com/miccaaz/url-shortener-api/blob/main/UrlShortener.API/Services/UrlShortenerService.cs): `UrlShortener.API/Services/UrlShortenerService.cs`
- [Short URL record](https://github.com/miccaaz/url-shortener-api/blob/main/UrlShortener.API/Entities/ShortenedUrl.cs): `UrlShortener.API/Entities/ShortenedUrl.cs`

### Persistence

- [EF context](https://github.com/miccaaz/url-shortener-api/blob/main/UrlShortener.API/Infrastructure/AppDbContext.cs): `UrlShortener.API/Infrastructure/AppDbContext.cs`
- **PostgreSQL**
- [Migration extension](https://github.com/miccaaz/url-shortener-api/blob/main/UrlShortener.API/Extensions/MigrationExtension.cs): `UrlShortener.API/Extensions/MigrationExtension.cs`

### Other components

- **Client**

## Connections

- Client → Shorten endpoint: submits URL (evidence: `UrlShortener.API/Program.cs`)
- Shorten endpoint → Shorten request: binds request (evidence: `UrlShortener.API/Program.cs`)
- Shorten endpoint → URL validation: validates URL (evidence: `UrlShortener.API/Program.cs`)
- Shorten endpoint → Code generator: requests code (evidence: `UrlShortener.API/Program.cs`)
- Code generator → EF context: checks code (evidence: `UrlShortener.API/Services/UrlShortenerService.cs`)
- Shorten endpoint → Short URL record: creates record (evidence: `UrlShortener.API/Program.cs`)
- Shorten endpoint → EF context: saves record (evidence: `UrlShortener.API/Program.cs`)
- Redirect endpoint → EF context: looks up code (evidence: `UrlShortener.API/Program.cs`)
- Redirect endpoint → Client: redirects (evidence: `UrlShortener.API/Program.cs`)
- EF context → Short URL record: maps entity (evidence: `UrlShortener.API/Infrastructure/AppDbContext.cs`)
- Shorten endpoint → Client: returns short URL (evidence: `UrlShortener.API/Program.cs`)
- Shorten endpoint → PostgreSQL: configures provider (evidence: `UrlShortener.API/Program.cs`)
- Shorten endpoint → Migration extension: applies in development (evidence: `UrlShortener.API/Program.cs`)
- Migration extension → EF context: runs migrations (evidence: `UrlShortener.API/Extensions/MigrationExtension.cs`)
- Client → Redirect endpoint: requests code (evidence: `UrlShortener.API/Program.cs`)
