# corrailius/shortener architecture

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

- Interactive diagram: https://gitdiagram.com/corrailius/shortener
- Repository: https://github.com/corrailius/shortener

## Overview

Shortener accepts HTTP requests to create short links and follow their codes. The router validates submitted HTTP(S) URLs, asks the in-memory Agent store to save or retrieve destinations, and returns a short URL or redirect. The OTP application supervises the store and, when enabled, starts Bandit with the router. The README documents these request and response behaviors; implementation details come from the sampled Elixir files.

Main entry points: [`lib/shortener/router.ex`](https://github.com/corrailius/shortener/blob/main/lib/shortener/router.ex) (HTTP router), [`lib/shortener/store.ex`](https://github.com/corrailius/shortener/blob/main/lib/shortener/store.ex) (In-memory store), [`lib/shortener/application.ex`](https://github.com/corrailius/shortener/blob/main/lib/shortener/application.ex) (OTP application)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Application runtime"]
  node_application["OTP application<br/>[application.ex]"]
  node_bandit["Bandit server"]
end

subgraph group_links["Link service"]
  node_router["HTTP router<br/>[router.ex]"]
  node_store[("In-memory store<br/>[store.ex]")]
end

node_user(("HTTP user"))

node_user -->|"submits or follows"| node_router
node_application -->|"supervises"| node_store
node_application -->|"starts server"| node_bandit
node_bandit -->|"dispatches to"| node_router
node_router -->|"stores destination"| node_store
node_router -->|"looks up code"| node_store
node_router -->|"returns URL or redirect"| node_user

click node_application "https://github.com/corrailius/shortener/blob/main/lib/shortener/application.ex"
click node_router "https://github.com/corrailius/shortener/blob/main/lib/shortener/router.ex"
click node_store "https://github.com/corrailius/shortener/blob/main/lib/shortener/store.ex"

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_application,node_bandit,node_user toneBlue
class node_router,node_store toneAmber
```

## Components

### Application runtime

- [OTP application](https://github.com/corrailius/shortener/blob/main/lib/shortener/application.ex): `lib/shortener/application.ex`
- **Bandit server**

### Link service

- [HTTP router](https://github.com/corrailius/shortener/blob/main/lib/shortener/router.ex): `lib/shortener/router.ex`
- [In-memory store](https://github.com/corrailius/shortener/blob/main/lib/shortener/store.ex): `lib/shortener/store.ex`

### Other components

- **HTTP user**

## Connections

- HTTP user → HTTP router: submits or follows (evidence: `README.md`)
- OTP application → In-memory store: supervises (evidence: `lib/shortener/application.ex`)
- OTP application → Bandit server: starts server (evidence: `lib/shortener/application.ex`)
- Bandit server → HTTP router: dispatches to
- HTTP router → In-memory store: stores destination (evidence: `lib/shortener/router.ex`)
- HTTP router → In-memory store: looks up code (evidence: `lib/shortener/router.ex`)
- HTTP router → HTTP user: returns URL or redirect (evidence: `README.md`)
