# andyxning/shortme architecture

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

- Interactive diagram: https://gitdiagram.com/andyxning/shortme
- Repository: https://github.com/andyxning/shortme

## Overview

ShortMe is a Go URL-shortening service. Its principal workflow validates a submitted HTTP(S) URL, allocates a unique sequence, encodes it into a short code, stores the mapping, then serves it through expansion or a temporary redirect. The repository also provides a browser interface with QR codes and previews, plus version and health endpoints. Edges are grounded in the sampled callers or README; unsampled details of web assets and database schemas are not inferred.

Main entry points: [`web/web.go`](https://github.com/andyxning/shortme/blob/master/web/web.go) (HTTP routing), [`short/short.go`](https://github.com/andyxning/shortme/blob/master/short/short.go) (Shortening service), [`web/api/short.go`](https://github.com/andyxning/shortme/blob/master/web/api/short.go) (Short and expand API), [`main.go`](https://github.com/andyxning/shortme/blob/master/main.go) (Application startup)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Runtime and configuration"]
  node_main["Application startup<br/>[main.go]"]
  node_config["Configuration<br/>[conf.go]"]
end

subgraph group_shortening["Shortening and expansion"]
  node_service["Shortening service<br/>[short.go]"]
  node_encoding["Base conversion<br/>[base.go]"]
end

subgraph group_persistence["Persistence and sequence"]
  node_shortdb[("URL mapping store<br/>[shortme.sql]")]
  node_sequenceapi["Sequence registry<br/>[sequence.go]"]
  node_sequenceimpl["MySQL sequence generator<br/>[sequence.go]"]
  node_sequencedb[("Sequence store<br/>[sequence.sql]")]
end

subgraph group_interfaces["HTTP and web interfaces"]
  node_httpserver["HTTP routing<br/>[web.go]"]
  node_api["Short and expand API<br/>[short.go]"]
  node_status["Version and health<br/>[generic.go]"]
  node_webpage["Web page handler<br/>[www.go]"]
  node_browser["Browser short/expand UI<br/>[shortme.js]"]
  node_template["Web templates"]
  node_staticassets["Static assets"]
end

node_user(("API or web user"))

node_user -->|"sends HTTP"| node_httpserver
node_main -->|"loads settings"| node_config
node_main -->|"starts service"| node_service
node_main -->|"starts server"| node_httpserver
node_httpserver -->|"routes requests"| node_api
node_httpserver -->|"routes status"| node_status
node_httpserver -->|"routes page"| node_webpage
node_httpserver -->|"serves assets"| node_staticassets
node_webpage -->|"renders template"| node_template
node_browser -->|"posts requests"| node_api
node_api -->|"shortens or expands"| node_service
node_service -->|"encodes sequence"| node_encoding
node_service -->|"reads and writes mappings"| node_shortdb
node_service -->|"requests sequence"| node_sequenceapi
node_sequenceimpl -->|"registers generator"| node_sequenceapi
node_sequenceimpl -->|"allocates sequence"| node_sequencedb
node_api -->|"returns response"| node_user
node_config -->|"configures behavior"| node_service

click node_main "https://github.com/andyxning/shortme/blob/master/main.go"
click node_config "https://github.com/andyxning/shortme/blob/master/conf/conf.go"
click node_httpserver "https://github.com/andyxning/shortme/blob/master/web/web.go"
click node_api "https://github.com/andyxning/shortme/blob/master/web/api/short.go"
click node_status "https://github.com/andyxning/shortme/blob/master/web/api/generic.go"
click node_webpage "https://github.com/andyxning/shortme/blob/master/web/www/www.go"
click node_browser "https://github.com/andyxning/shortme/blob/master/static/js/shortme.js"
click node_template "https://github.com/andyxning/shortme/tree/master/template"
click node_service "https://github.com/andyxning/shortme/blob/master/short/short.go"
click node_encoding "https://github.com/andyxning/shortme/blob/master/base/base.go"
click node_shortdb "https://github.com/andyxning/shortme/blob/master/schema/shortme.sql"
click node_sequenceapi "https://github.com/andyxning/shortme/blob/master/sequence/sequence.go"
click node_sequenceimpl "https://github.com/andyxning/shortme/blob/master/sequence/db/sequence.go"
click node_sequencedb "https://github.com/andyxning/shortme/blob/master/schema/sequence.sql"
click node_staticassets "https://github.com/andyxning/shortme/tree/master/static"

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_main,node_config,node_user toneBlue
class node_service,node_encoding toneAmber
class node_shortdb,node_sequenceapi,node_sequenceimpl,node_sequencedb toneMint
class node_httpserver,node_api,node_status,node_webpage,node_browser,node_template,node_staticassets toneRose
```

## Components

### Runtime and configuration

- [Application startup](https://github.com/andyxning/shortme/blob/master/main.go): `main.go`
- [Configuration](https://github.com/andyxning/shortme/blob/master/conf/conf.go): `conf/conf.go`

### Shortening and expansion

- [Shortening service](https://github.com/andyxning/shortme/blob/master/short/short.go): `short/short.go`
- [Base conversion](https://github.com/andyxning/shortme/blob/master/base/base.go): `base/base.go`

### Persistence and sequence

- [URL mapping store](https://github.com/andyxning/shortme/blob/master/schema/shortme.sql): `schema/shortme.sql`
- [Sequence registry](https://github.com/andyxning/shortme/blob/master/sequence/sequence.go): `sequence/sequence.go`
- [MySQL sequence generator](https://github.com/andyxning/shortme/blob/master/sequence/db/sequence.go): `sequence/db/sequence.go`
- [Sequence store](https://github.com/andyxning/shortme/blob/master/schema/sequence.sql): `schema/sequence.sql`

### HTTP and web interfaces

- [HTTP routing](https://github.com/andyxning/shortme/blob/master/web/web.go): `web/web.go`
- [Short and expand API](https://github.com/andyxning/shortme/blob/master/web/api/short.go): `web/api/short.go`
- [Version and health](https://github.com/andyxning/shortme/blob/master/web/api/generic.go): `web/api/generic.go`
- [Web page handler](https://github.com/andyxning/shortme/blob/master/web/www/www.go): `web/www/www.go`
- [Browser short/expand UI](https://github.com/andyxning/shortme/blob/master/static/js/shortme.js): `static/js/shortme.js`
- [Web templates](https://github.com/andyxning/shortme/tree/master/template): `template`
- [Static assets](https://github.com/andyxning/shortme/tree/master/static): `static`

### Other components

- **API or web user**

## Connections

- API or web user → HTTP routing: sends HTTP (evidence: `README.md`)
- Application startup → Configuration: loads settings (evidence: `main.go`)
- Application startup → Shortening service: starts service (evidence: `main.go`)
- Application startup → HTTP routing: starts server (evidence: `main.go`)
- HTTP routing → Short and expand API: routes requests (evidence: `web/web.go`)
- HTTP routing → Version and health: routes status (evidence: `web/web.go`)
- HTTP routing → Web page handler: routes page (evidence: `web/web.go`)
- HTTP routing → Static assets: serves assets (evidence: `web/web.go`)
- Web page handler → Web templates: renders template (evidence: `web/www/www.go`)
- Browser short/expand UI → Short and expand API: posts requests (evidence: `static/js/shortme.js`)
- Short and expand API → Shortening service: shortens or expands (evidence: `web/api/short.go`)
- Shortening service → Base conversion: encodes sequence (evidence: `short/short.go`)
- Shortening service → URL mapping store: reads and writes mappings (evidence: `short/short.go`)
- Shortening service → Sequence registry: requests sequence (evidence: `short/short.go`)
- MySQL sequence generator → Sequence registry: registers generator (evidence: `sequence/db/sequence.go`)
- MySQL sequence generator → Sequence store: allocates sequence (evidence: `sequence/db/sequence.go`)
- Short and expand API → API or web user: returns response (evidence: `README.md`)
- Configuration → Shortening service: configures behavior (evidence: `short/short.go`)
