# parth-076/url-shortner architecture

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

- Interactive diagram: https://gitdiagram.com/parth-076/url-shortner
- Repository: https://github.com/parth-076/url-shortner

## Overview

This is a small Express URL-shortener API. The runtime starts an HTTP listener, mounts a POST endpoint at `/api/urls`, validates the submitted `originalUrl`, generates a seven-character short code, and returns both values in JSON. The response explicitly says database storage is planned but not implemented, so the graph shows no persistence. Source excerpts establish the wiring and code-generation call; no README or storage implementation was provided.

Main entry points: [`server/src/routes/url.routes.js`](https://github.com/parth-076/url-shortner/blob/main/server/src/routes/url.routes.js) (URL endpoint), [`server/src/app.js`](https://github.com/parth-076/url-shortner/blob/main/server/src/app.js) (Express app), [`server/src/utils/generateCode.js`](https://github.com/parth-076/url-shortner/blob/main/server/src/utils/generateCode.js) (Short-code generator), [`server/src/server.js`](https://github.com/parth-076/url-shortner/blob/main/server/src/server.js) (HTTP listener)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["HTTP runtime"]
  node_server["HTTP listener<br/>[server.js]"]
  node_app["Express app<br/>[app.js]"]
end

subgraph group_api["URL API"]
  node_url_endpoint["URL endpoint<br/>[url.routes.js]"]
end

subgraph group_codes["Code generation"]
  node_code_generator["Short-code generator<br/>[generateCode.js]"]
end

node_caller(("API caller"))
node_nanoid["nanoid library"]

node_server -->|"starts listener"| node_app
node_app -->|"mounts at /api/urls"| node_url_endpoint
node_caller -->|"POSTs URL"| node_url_endpoint
node_url_endpoint -->|"generates code"| node_code_generator
node_code_generator -->|"creates identifier"| node_nanoid
node_url_endpoint -->|"returns JSON"| node_caller

click node_server "https://github.com/parth-076/url-shortner/blob/main/server/src/server.js"
click node_app "https://github.com/parth-076/url-shortner/blob/main/server/src/app.js"
click node_url_endpoint "https://github.com/parth-076/url-shortner/blob/main/server/src/routes/url.routes.js"
click node_code_generator "https://github.com/parth-076/url-shortner/blob/main/server/src/utils/generateCode.js"

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_server,node_app toneBlue
class node_url_endpoint toneAmber
class node_code_generator,node_caller toneMint
class node_nanoid toneIndigo
```

## Components

### HTTP runtime

- [HTTP listener](https://github.com/parth-076/url-shortner/blob/main/server/src/server.js): `server/src/server.js`
- [Express app](https://github.com/parth-076/url-shortner/blob/main/server/src/app.js): `server/src/app.js`

### URL API

- [URL endpoint](https://github.com/parth-076/url-shortner/blob/main/server/src/routes/url.routes.js): `server/src/routes/url.routes.js`

### Code generation

- [Short-code generator](https://github.com/parth-076/url-shortner/blob/main/server/src/utils/generateCode.js): `server/src/utils/generateCode.js`

### Other components

- **API caller**
- **nanoid library**

## Connections

- HTTP listener → Express app: starts listener (evidence: `server/src/server.js`)
- Express app → URL endpoint: mounts at /api/urls (evidence: `server/src/app.js`)
- API caller → URL endpoint: POSTs URL (evidence: `server/src/routes/url.routes.js`)
- URL endpoint → Short-code generator: generates code (evidence: `server/src/routes/url.routes.js`)
- Short-code generator → nanoid library: creates identifier (evidence: `server/src/utils/generateCode.js`)
- URL endpoint → API caller: returns JSON (evidence: `server/src/routes/url.routes.js`)
