# etrupja/shortly architecture

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

- Interactive diagram: https://gitdiagram.com/etrupja/shortly
- Repository: https://github.com/etrupja/shortly

## Overview

Shortly is an ASP.NET URL-shortening application with a separate redirect executable. Users register or sign in, manage short links, and use the redirect service to resolve links; administrators can also view users and links. Authentication includes email confirmation, phone-based two-factor verification, and external providers. The source excerpts establish the client’s dependency wiring and data-service behavior, but the Home and URL controller implementations and redirect program were not excerpted, so their runtime links remain unverified.

Main entry points: [`Shortly.Client/Program.cs`](https://github.com/etrupja/shortly/blob/master/Shortly.Client/Program.cs) (MVC application), [`Shortly.Client/Controllers/AuthenticationController.cs`](https://github.com/etrupja/shortly/blob/master/Shortly.Client/Controllers/AuthenticationController.cs) (Authentication routes), [`Shortly.Data/Services/UrlsService.cs`](https://github.com/etrupja/shortly/blob/master/Shortly.Data/Services/UrlsService.cs) (URL operations), [`Shortly.Data/AppDbContext.cs`](https://github.com/etrupja/shortly/blob/master/Shortly.Data/AppDbContext.cs) (SQL database context)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Web client"]
  node_client_app["MVC application<br/>[Program.cs]"]
  node_home["Home pages<br/>[HomeController.cs]"]
  node_url_routes["URL routes<br/>[UrlController.cs]"]
end

subgraph group_identity["Identity and access"]
  node_auth_routes["Authentication routes"]
  node_identity_seed["Role and user seeding<br/>[DbInitializer.cs]"]
  node_identity_models["Identity models<br/>[AppUser.cs]"]
  node_users_service["User queries<br/>[UsersService.cs]"]
  node_users_contract["User service contract<br/>[IUsersService.cs]"]
  node_email_validator["Email validation"]
  node_role_names["Role names<br/>[Role.cs]"]
end

subgraph group_links["Short-link management"]
  node_url_model["Short-link records<br/>[Url.cs]"]
  node_url_service["URL operations<br/>[UrlsService.cs]"]
  node_url_contract["URL service contract<br/>[IUrlsService.cs]"]
  node_redirect_app["Redirect executable<br/>[Program.cs]"]
end

subgraph group_persistence["Data persistence"]
  node_database[("SQL database context<br/>[AppDbContext.cs]")]
end

node_visitor(("Visitor"))
node_sendgrid["SendGrid email"]
node_twilio["Twilio SMS"]
node_external_login["Google / GitHub"]

node_visitor -->|"uses"| node_client_app
node_client_app -.->|"routes"| node_home
node_client_app -.->|"routes"| node_url_routes
node_client_app -.->|"routes"| node_auth_routes
node_client_app -->|"configures"| node_database
node_client_app -->|"registers"| node_url_service
node_client_app -->|"registers"| node_users_service
node_client_app -->|"seeds"| node_identity_seed
node_auth_routes -->|"gets users"| node_users_service
node_auth_routes -->|"creates users"| node_identity_models
node_auth_routes -->|"sends email"| node_sendgrid
node_auth_routes -->|"sends codes"| node_twilio
node_auth_routes -.->|"supports login"| node_external_login
node_users_service -->|"queries"| node_database
node_users_service -->|"loads"| node_identity_models
node_url_routes -.->|"uses"| node_url_service
node_home -.->|"uses"| node_database
node_url_service -->|"reads and writes"| node_database
node_url_service -->|"handles"| node_url_model
node_url_service -->|"implements"| node_url_contract
node_users_service -->|"implements"| node_users_contract
node_database -->|"stores"| node_identity_models
node_database -->|"stores"| node_url_model
node_redirect_app -.->|"uses"| node_url_service
node_identity_seed -->|"creates accounts"| node_identity_models
node_identity_seed -->|"assigns roles"| node_role_names
node_url_model -->|"belongs to user"| node_identity_models

click node_client_app "https://github.com/etrupja/shortly/blob/master/Shortly.Client/Program.cs"
click node_home "https://github.com/etrupja/shortly/blob/master/Shortly.Client/Controllers/HomeController.cs"
click node_url_routes "https://github.com/etrupja/shortly/blob/master/Shortly.Client/Controllers/UrlController.cs"
click node_auth_routes "https://github.com/etrupja/shortly/blob/master/Shortly.Client/Controllers/AuthenticationController.cs"
click node_identity_seed "https://github.com/etrupja/shortly/blob/master/Shortly.Client/Data/DbInitializer.cs"
click node_identity_models "https://github.com/etrupja/shortly/blob/master/Shortly.Data/Models/AppUser.cs"
click node_users_service "https://github.com/etrupja/shortly/blob/master/Shortly.Data/Services/UsersService.cs"
click node_users_contract "https://github.com/etrupja/shortly/blob/master/Shortly.Data/Services/IUsersService.cs"
click node_email_validator "https://github.com/etrupja/shortly/blob/master/Shortly.Client/Helpers/Validators/CustomEmailValidator.cs"
click node_role_names "https://github.com/etrupja/shortly/blob/master/Shortly.Client/Helpers/Roles/Role.cs"
click node_url_model "https://github.com/etrupja/shortly/blob/master/Shortly.Data/Models/Url.cs"
click node_url_service "https://github.com/etrupja/shortly/blob/master/Shortly.Data/Services/UrlsService.cs"
click node_url_contract "https://github.com/etrupja/shortly/blob/master/Shortly.Data/Services/IUrlsService.cs"
click node_redirect_app "https://github.com/etrupja/shortly/blob/master/Shortly.Redirect/Program.cs"
click node_database "https://github.com/etrupja/shortly/blob/master/Shortly.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_client_app,node_home,node_url_routes toneBlue
class node_auth_routes,node_identity_seed,node_identity_models,node_users_service,node_users_contract,node_email_validator,node_role_names toneAmber
class node_url_model,node_url_service,node_url_contract,node_redirect_app toneMint
class node_database toneRose
class node_visitor,node_sendgrid,node_twilio,node_external_login toneIndigo
```

## Components

### Web client

- [MVC application](https://github.com/etrupja/shortly/blob/master/Shortly.Client/Program.cs): `Shortly.Client/Program.cs`
- [Home pages](https://github.com/etrupja/shortly/blob/master/Shortly.Client/Controllers/HomeController.cs): `Shortly.Client/Controllers/HomeController.cs`
- [URL routes](https://github.com/etrupja/shortly/blob/master/Shortly.Client/Controllers/UrlController.cs): `Shortly.Client/Controllers/UrlController.cs`

### Identity and access

- [Authentication routes](https://github.com/etrupja/shortly/blob/master/Shortly.Client/Controllers/AuthenticationController.cs): `Shortly.Client/Controllers/AuthenticationController.cs`
- [Role and user seeding](https://github.com/etrupja/shortly/blob/master/Shortly.Client/Data/DbInitializer.cs): `Shortly.Client/Data/DbInitializer.cs`
- [Identity models](https://github.com/etrupja/shortly/blob/master/Shortly.Data/Models/AppUser.cs): `Shortly.Data/Models/AppUser.cs`
- [User queries](https://github.com/etrupja/shortly/blob/master/Shortly.Data/Services/UsersService.cs): `Shortly.Data/Services/UsersService.cs`
- [User service contract](https://github.com/etrupja/shortly/blob/master/Shortly.Data/Services/IUsersService.cs): `Shortly.Data/Services/IUsersService.cs`
- [Email validation](https://github.com/etrupja/shortly/blob/master/Shortly.Client/Helpers/Validators/CustomEmailValidator.cs): `Shortly.Client/Helpers/Validators/CustomEmailValidator.cs`
- [Role names](https://github.com/etrupja/shortly/blob/master/Shortly.Client/Helpers/Roles/Role.cs): `Shortly.Client/Helpers/Roles/Role.cs`

### Short-link management

- [Short-link records](https://github.com/etrupja/shortly/blob/master/Shortly.Data/Models/Url.cs): `Shortly.Data/Models/Url.cs`
- [URL operations](https://github.com/etrupja/shortly/blob/master/Shortly.Data/Services/UrlsService.cs): `Shortly.Data/Services/UrlsService.cs`
- [URL service contract](https://github.com/etrupja/shortly/blob/master/Shortly.Data/Services/IUrlsService.cs): `Shortly.Data/Services/IUrlsService.cs`
- [Redirect executable](https://github.com/etrupja/shortly/blob/master/Shortly.Redirect/Program.cs): `Shortly.Redirect/Program.cs`

### Data persistence

- [SQL database context](https://github.com/etrupja/shortly/blob/master/Shortly.Data/AppDbContext.cs): `Shortly.Data/AppDbContext.cs`

### Other components

- **Visitor**
- **SendGrid email**
- **Twilio SMS**
- **Google / GitHub**

## Connections

- Visitor → MVC application: uses
- MVC application → Home pages: routes
- MVC application → URL routes: routes
- MVC application → Authentication routes: routes
- MVC application → SQL database context: configures (evidence: `Shortly.Client/Program.cs`)
- MVC application → URL operations: registers (evidence: `Shortly.Client/Program.cs`)
- MVC application → User queries: registers (evidence: `Shortly.Client/Program.cs`)
- MVC application → Role and user seeding: seeds (evidence: `Shortly.Client/Program.cs`)
- Authentication routes → User queries: gets users (evidence: `Shortly.Client/Controllers/AuthenticationController.cs`)
- Authentication routes → Identity models: creates users (evidence: `Shortly.Client/Controllers/AuthenticationController.cs`)
- Authentication routes → SendGrid email: sends email (evidence: `Shortly.Client/Controllers/AuthenticationController.cs`)
- Authentication routes → Twilio SMS: sends codes (evidence: `Shortly.Client/Controllers/AuthenticationController.cs`)
- Authentication routes → Google / GitHub: supports login
- User queries → SQL database context: queries (evidence: `Shortly.Data/Services/UsersService.cs`)
- User queries → Identity models: loads (evidence: `Shortly.Data/Services/UsersService.cs`)
- URL routes → URL operations: uses
- Home pages → SQL database context: uses (evidence: `Shortly.Client/Controllers/HomeController.cs`)
- URL operations → SQL database context: reads and writes (evidence: `Shortly.Data/Services/UrlsService.cs`)
- URL operations → Short-link records: handles (evidence: `Shortly.Data/Services/UrlsService.cs`)
- URL operations → URL service contract: implements (evidence: `Shortly.Data/Services/UrlsService.cs`)
- User queries → User service contract: implements (evidence: `Shortly.Data/Services/UsersService.cs`)
- SQL database context → Identity models: stores (evidence: `Shortly.Data/AppDbContext.cs`)
- SQL database context → Short-link records: stores (evidence: `Shortly.Data/AppDbContext.cs`)
- Redirect executable → URL operations: uses (evidence: `Shortly.Redirect/Program.cs`)
- Role and user seeding → Identity models: creates accounts (evidence: `Shortly.Client/Data/DbInitializer.cs`)
- Role and user seeding → Role names: assigns roles (evidence: `Shortly.Client/Data/DbInitializer.cs`)
- Short-link records → Identity models: belongs to user (evidence: `Shortly.Data/Models/Url.cs`)
