# anxfairytale/linkforge architecture

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

- Interactive diagram: https://gitdiagram.com/anxfairytale/linkforge
- Repository: https://github.com/anxfairytale/linkforge

## Overview

AWS URL Shortener is a serverless web application: a user submits a destination in the static browser app, the API creates a short code, and opening that link redirects to the destination while recording a click. The browser can also retrieve link statistics and refresh them. The README documents S3 hosting, API Gateway, Lambda, and DynamoDB; the sampled handler and frontend establish the request and storage behavior. Deployment and test tooling are omitted. Template wiring and unsampled documentation details are not independently verified here.

Main entry points: [`frontend/app.js`](https://github.com/anxfairytale/linkforge/blob/main/frontend/app.js) (Shortener UI), [`backend/app.py`](https://github.com/anxfairytale/linkforge/blob/main/backend/app.py) (Route handler), [`frontend/config.js`](https://github.com/anxfairytale/linkforge/blob/main/frontend/config.js) (API config)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Browser app"]
  node_frontend["Shortener UI<br/>[app.js]"]
  node_config["API config<br/>[config.js]"]
end

subgraph group_api["API handling"]
  node_handler["Route handler<br/>[app.py]"]
  node_shorten["Create short link<br/>[app.py]"]
  node_validate["URL validation<br/>[app.py]"]
  node_codegen["Code allocation<br/>[app.py]"]
  node_redirect["Redirect handler<br/>[app.py]"]
  node_stats["Stats handler<br/>[app.py]"]
  node_health["Health route<br/>[app.py]"]
end

subgraph group_data["Link data"]
  node_table[("Link mappings")]
end

subgraph group_aws["AWS services"]
  node_gateway{{"HTTP API"}}
  node_s3["Static website"]
  node_cloudfront["Optional HTTPS"]
end

node_visitor(("Visitor"))

node_visitor -->|"loads site"| node_s3
node_s3 -->|"serves assets"| node_frontend
node_frontend -->|"reads config"| node_config
node_frontend -->|"calls API"| node_gateway
node_gateway -->|"invokes"| node_handler
node_handler -->|"routes to"| node_shorten
node_shorten -->|"validates URL"| node_validate
node_shorten -->|"allocates code"| node_codegen
node_shorten -->|"conditional write"| node_table
node_handler -->|"routes to"| node_redirect
node_redirect -->|"reads and increments"| node_table
node_redirect -->|"returns 302"| node_visitor
node_handler -->|"routes to"| node_stats
node_stats -->|"reads mapping"| node_table
node_frontend -->|"requests stats"| node_stats
node_handler -->|"routes to"| node_health
node_frontend -->|"shortens and refreshes"| node_gateway
node_cloudfront -.->|"private origin"| node_s3

click node_frontend "https://github.com/anxfairytale/linkforge/blob/main/frontend/app.js"
click node_config "https://github.com/anxfairytale/linkforge/blob/main/frontend/config.js"
click node_handler "https://github.com/anxfairytale/linkforge/blob/main/backend/app.py"
click node_shorten "https://github.com/anxfairytale/linkforge/blob/main/backend/app.py"
click node_validate "https://github.com/anxfairytale/linkforge/blob/main/backend/app.py"
click node_codegen "https://github.com/anxfairytale/linkforge/blob/main/backend/app.py"
click node_redirect "https://github.com/anxfairytale/linkforge/blob/main/backend/app.py"
click node_stats "https://github.com/anxfairytale/linkforge/blob/main/backend/app.py"
click node_health "https://github.com/anxfairytale/linkforge/blob/main/backend/app.py"

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_frontend,node_config toneBlue
class node_handler,node_shorten,node_validate,node_codegen,node_redirect,node_stats,node_health toneAmber
class node_table toneMint
class node_gateway,node_s3,node_cloudfront toneRose
class node_visitor toneIndigo
```

## Components

### Browser app

- [Shortener UI](https://github.com/anxfairytale/linkforge/blob/main/frontend/app.js): `frontend/app.js`
- [API config](https://github.com/anxfairytale/linkforge/blob/main/frontend/config.js): `frontend/config.js`

### API handling

- [Route handler](https://github.com/anxfairytale/linkforge/blob/main/backend/app.py): `backend/app.py`
- [Create short link](https://github.com/anxfairytale/linkforge/blob/main/backend/app.py): `backend/app.py`
- [URL validation](https://github.com/anxfairytale/linkforge/blob/main/backend/app.py): `backend/app.py`
- [Code allocation](https://github.com/anxfairytale/linkforge/blob/main/backend/app.py): `backend/app.py`
- [Redirect handler](https://github.com/anxfairytale/linkforge/blob/main/backend/app.py): `backend/app.py`
- [Stats handler](https://github.com/anxfairytale/linkforge/blob/main/backend/app.py): `backend/app.py`
- [Health route](https://github.com/anxfairytale/linkforge/blob/main/backend/app.py): `backend/app.py`

### Link data

- **Link mappings**

### AWS services

- **HTTP API**
- **Static website**
- **Optional HTTPS**

### Other components

- **Visitor**

## Connections

- Visitor → Static website: loads site (evidence: `README.md`)
- Static website → Shortener UI: serves assets (evidence: `README.md`)
- Shortener UI → API config: reads config (evidence: `frontend/app.js`)
- Shortener UI → HTTP API: calls API (evidence: `README.md`)
- HTTP API → Route handler: invokes (evidence: `README.md`)
- Route handler → Create short link: routes to (evidence: `backend/app.py`)
- Create short link → URL validation: validates URL (evidence: `backend/app.py`)
- Create short link → Code allocation: allocates code (evidence: `backend/app.py`)
- Create short link → Link mappings: conditional write (evidence: `backend/app.py`)
- Route handler → Redirect handler: routes to (evidence: `backend/app.py`)
- Redirect handler → Link mappings: reads and increments (evidence: `backend/app.py`)
- Redirect handler → Visitor: returns 302 (evidence: `README.md`)
- Route handler → Stats handler: routes to (evidence: `backend/app.py`)
- Stats handler → Link mappings: reads mapping (evidence: `backend/app.py`)
- Shortener UI → Stats handler: requests stats (evidence: `frontend/app.js`)
- Route handler → Health route: routes to (evidence: `backend/app.py`)
- Shortener UI → HTTP API: shortens and refreshes (evidence: `frontend/app.js`)
- Optional HTTPS → Static website: private origin (evidence: `README.md`)
