# shreyabansal08/gdg_r2 architecture

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

- Interactive diagram: https://gitdiagram.com/shreyabansal08/gdg_r2
- Repository: https://github.com/shreyabansal08/gdg_r2

## Overview

This Flask URL shortener accepts link creation, redirect, statistics, health, and authenticated deletion requests. Its main workflow validates a URL and optional TTL/alias, generates or accepts a code, persists the link in SQLite, then returns a short URL; following that URL checks expiry, increments clicks, and redirects. The single source file combines routing, domain logic, and persistence. All implementation nodes therefore point to app.py; the README documents the API, while the excerpt confirms the internal calls shown.

Main entry points: [`app.py`](https://github.com/shreyabansal08/gdg_r2/blob/main/app.py) (Flask Routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["HTTP API"]
  node_routes["Flask Routes<br/>[app.py]"]
end

subgraph group_link["Link Handling"]
  node_shorten["Create Short Link<br/>[app.py]"]
  node_validate["URL and TTL Checks<br/>[app.py]"]
  node_code["Code Generation<br/>[app.py]"]
  node_redirect["Follow and Count<br/>[app.py]"]
  node_stats["Link Statistics<br/>[app.py]"]
  node_delete["Authenticated Delete<br/>[app.py]"]
end

subgraph group_storage["SQLite Storage"]
  node_store[("Link Records<br/>[app.py]")]
end

node_client(("API Client"))
node_destination(("Original URL"))

node_client -->|"sends requests"| node_routes
node_routes -->|"routes creation"| node_shorten
node_routes -->|"routes code"| node_redirect
node_routes -->|"routes statistics"| node_stats
node_routes -->|"routes deletion"| node_delete
node_shorten -->|"checks input"| node_validate
node_shorten -->|"generates code"| node_code
node_shorten -->|"saves link"| node_store
node_redirect -->|"reads and counts"| node_store
node_redirect -->|"redirects visitor"| node_destination
node_stats -->|"reads link"| node_store
node_delete -->|"deletes link"| node_store

click node_routes "https://github.com/shreyabansal08/gdg_r2/blob/main/app.py"
click node_shorten "https://github.com/shreyabansal08/gdg_r2/blob/main/app.py"
click node_validate "https://github.com/shreyabansal08/gdg_r2/blob/main/app.py"
click node_code "https://github.com/shreyabansal08/gdg_r2/blob/main/app.py"
click node_redirect "https://github.com/shreyabansal08/gdg_r2/blob/main/app.py"
click node_stats "https://github.com/shreyabansal08/gdg_r2/blob/main/app.py"
click node_delete "https://github.com/shreyabansal08/gdg_r2/blob/main/app.py"
click node_store "https://github.com/shreyabansal08/gdg_r2/blob/main/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_routes,node_client toneBlue
class node_shorten,node_validate,node_code,node_redirect,node_stats,node_delete toneAmber
class node_store toneMint
class node_destination toneIndigo
```

## Components

### HTTP API

- [Flask Routes](https://github.com/shreyabansal08/gdg_r2/blob/main/app.py): `app.py`

### Link Handling

- [Create Short Link](https://github.com/shreyabansal08/gdg_r2/blob/main/app.py): `app.py`
- [URL and TTL Checks](https://github.com/shreyabansal08/gdg_r2/blob/main/app.py): `app.py`
- [Code Generation](https://github.com/shreyabansal08/gdg_r2/blob/main/app.py): `app.py`
- [Follow and Count](https://github.com/shreyabansal08/gdg_r2/blob/main/app.py): `app.py`
- [Link Statistics](https://github.com/shreyabansal08/gdg_r2/blob/main/app.py): `app.py`
- [Authenticated Delete](https://github.com/shreyabansal08/gdg_r2/blob/main/app.py): `app.py`

### SQLite Storage

- [Link Records](https://github.com/shreyabansal08/gdg_r2/blob/main/app.py): `app.py`

### Other components

- **API Client**
- **Original URL**

## Connections

- API Client → Flask Routes: sends requests (evidence: `README.md`)
- Flask Routes → Create Short Link: routes creation (evidence: `app.py`)
- Flask Routes → Follow and Count: routes code (evidence: `app.py`)
- Flask Routes → Link Statistics: routes statistics (evidence: `app.py`)
- Flask Routes → Authenticated Delete: routes deletion (evidence: `app.py`)
- Create Short Link → URL and TTL Checks: checks input (evidence: `app.py`)
- Create Short Link → Code Generation: generates code (evidence: `app.py`)
- Create Short Link → Link Records: saves link (evidence: `app.py`)
- Follow and Count → Link Records: reads and counts (evidence: `app.py`)
- Follow and Count → Original URL: redirects visitor (evidence: `app.py`)
- Link Statistics → Link Records: reads link (evidence: `app.py`)
- Authenticated Delete → Link Records: deletes link (evidence: `app.py`)
