# sintan1729/chhoto-url architecture

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

- Interactive diagram: https://gitdiagram.com/sintan1729/chhoto-url
- Repository: https://github.com/sintan1729/chhoto-url

## Overview

Chhoto URL is a self-hosted URL shortener. Users create links through the web UI or API; the backend authenticates requests, validates and stores links, then redirects visitors and records hits. Link management also covers listing, editing, deletion, search/filtering, notes and expiry. Background workers batch hit updates and periodically clean expired links. The README documents additional capabilities including QR codes, public mode and configurable landing pages. Source excerpts show server wiring and selected handlers; some subsystem connections are therefore omitted rather than inferred.

Main entry points: [`backend/src/main.rs`](https://github.com/sintan1729/chhoto-url/blob/main/backend/src/main.rs) (HTTP server), [`backend/src/services/post.rs`](https://github.com/sintan1729/chhoto-url/blob/main/backend/src/services/post.rs) (Create and login API), [`backend/src/services/get.rs`](https://github.com/sintan1729/chhoto-url/blob/main/backend/src/services/get.rs) (Read and redirect API), [`backend/src/database/events.rs`](https://github.com/sintan1729/chhoto-url/blob/main/backend/src/database/events.rs) (Link and hit operations)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_server["Server and configuration"]
  node_main["HTTP server<br/>[main.rs]"]
  node_config["Runtime configuration<br/>[config.rs]"]
  node_auth["Authentication<br/>[auth.rs]"]
  node_health["Health endpoint<br/>[get.rs]"]
end

subgraph group_management["Link management"]
  node_create["Create and login API<br/>[post.rs]"]
  node_read["Read and redirect API<br/>[get.rs]"]
  node_update["Edit link API<br/>[put.rs]"]
  node_delete["Delete link API<br/>[delete.rs]"]
  node_service_utils["Service helpers<br/>[utils.rs]"]
  node_service_types["API data types<br/>[types.rs]"]
end

subgraph group_persistence["Persistence and maintenance"]
  node_database[("SQLite database<br/>[utils.rs]")]
  node_db_events["Link and hit operations<br/>[events.rs]"]
  node_db_queries["SQL queries<br/>[queries.rs]"]
  node_background["Background workers<br/>[background.rs]"]
end

subgraph group_clients["User interfaces"]
  node_frontend["Management UI<br/>[script.js]"]
  node_landing["Public landing UI<br/>[script.js]"]
end

node_visitor(("Link visitor"))
node_user(("Admin or API client"))

node_main -->|"loads settings"| node_config
node_main -->|"wires authentication"| node_auth
node_main -->|"registers routes"| node_create
node_main -->|"registers routes"| node_read
node_main -.->|"registers routes"| node_update
node_main -.->|"registers routes"| node_delete
node_main -->|"initializes"| node_database
node_main -->|"starts workers"| node_background
node_main -.->|"registers endpoint"| node_health
node_user -->|"uses"| node_frontend
node_user -.->|"submits requests"| node_create
node_visitor -->|"opens short link"| node_read
node_frontend -.->|"uses API"| node_create
node_create -->|"checks access"| node_auth
node_create -->|"delegates creation"| node_service_utils
node_create -->|"reads link details"| node_database
node_read -.->|"checks access"| node_auth
node_read -->|"reads links"| node_database
node_read -->|"records redirect hit"| node_db_events
node_update -.->|"delegates edits"| node_service_utils
node_delete -->|"delegates deletion"| node_service_utils
node_service_utils -.->|"changes link data"| node_db_events
node_db_events -.->|"queries and updates"| node_database
node_background -->|"flushes hit counts"| node_db_events
node_background -->|"cleans expired links"| node_database
node_db_events -.->|"uses SQL definitions"| node_db_queries
node_landing -.->|"served by"| node_main

click node_main "https://github.com/sintan1729/chhoto-url/blob/main/backend/src/main.rs"
click node_config "https://github.com/sintan1729/chhoto-url/blob/main/backend/src/config.rs"
click node_auth "https://github.com/sintan1729/chhoto-url/blob/main/backend/src/auth.rs"
click node_frontend "https://github.com/sintan1729/chhoto-url/blob/main/frontend/static/script.js"
click node_landing "https://github.com/sintan1729/chhoto-url/blob/main/site/static/script.js"
click node_create "https://github.com/sintan1729/chhoto-url/blob/main/backend/src/services/post.rs"
click node_read "https://github.com/sintan1729/chhoto-url/blob/main/backend/src/services/get.rs"
click node_update "https://github.com/sintan1729/chhoto-url/blob/main/backend/src/services/put.rs"
click node_delete "https://github.com/sintan1729/chhoto-url/blob/main/backend/src/services/delete.rs"
click node_service_utils "https://github.com/sintan1729/chhoto-url/blob/main/backend/src/services/utils.rs"
click node_service_types "https://github.com/sintan1729/chhoto-url/blob/main/backend/src/services/types.rs"
click node_database "https://github.com/sintan1729/chhoto-url/blob/main/backend/src/database/utils.rs"
click node_db_events "https://github.com/sintan1729/chhoto-url/blob/main/backend/src/database/events.rs"
click node_db_queries "https://github.com/sintan1729/chhoto-url/blob/main/backend/src/database/queries.rs"
click node_background "https://github.com/sintan1729/chhoto-url/blob/main/backend/src/background.rs"
click node_health "https://github.com/sintan1729/chhoto-url/blob/main/backend/src/services/get.rs"

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_auth,node_health,node_user toneBlue
class node_create,node_read,node_update,node_delete,node_service_utils,node_service_types toneAmber
class node_database,node_db_events,node_db_queries,node_background toneMint
class node_frontend,node_landing toneRose
class node_visitor toneIndigo
```

## Components

### Server and configuration

- [HTTP server](https://github.com/sintan1729/chhoto-url/blob/main/backend/src/main.rs): `backend/src/main.rs`
- [Runtime configuration](https://github.com/sintan1729/chhoto-url/blob/main/backend/src/config.rs): `backend/src/config.rs`
- [Authentication](https://github.com/sintan1729/chhoto-url/blob/main/backend/src/auth.rs): `backend/src/auth.rs`
- [Health endpoint](https://github.com/sintan1729/chhoto-url/blob/main/backend/src/services/get.rs): `backend/src/services/get.rs`

### Link management

- [Create and login API](https://github.com/sintan1729/chhoto-url/blob/main/backend/src/services/post.rs): `backend/src/services/post.rs`
- [Read and redirect API](https://github.com/sintan1729/chhoto-url/blob/main/backend/src/services/get.rs): `backend/src/services/get.rs`
- [Edit link API](https://github.com/sintan1729/chhoto-url/blob/main/backend/src/services/put.rs): `backend/src/services/put.rs`
- [Delete link API](https://github.com/sintan1729/chhoto-url/blob/main/backend/src/services/delete.rs): `backend/src/services/delete.rs`
- [Service helpers](https://github.com/sintan1729/chhoto-url/blob/main/backend/src/services/utils.rs): `backend/src/services/utils.rs`
- [API data types](https://github.com/sintan1729/chhoto-url/blob/main/backend/src/services/types.rs): `backend/src/services/types.rs`

### Persistence and maintenance

- [SQLite database](https://github.com/sintan1729/chhoto-url/blob/main/backend/src/database/utils.rs): `backend/src/database/utils.rs`
- [Link and hit operations](https://github.com/sintan1729/chhoto-url/blob/main/backend/src/database/events.rs): `backend/src/database/events.rs`
- [SQL queries](https://github.com/sintan1729/chhoto-url/blob/main/backend/src/database/queries.rs): `backend/src/database/queries.rs`
- [Background workers](https://github.com/sintan1729/chhoto-url/blob/main/backend/src/background.rs): `backend/src/background.rs`

### User interfaces

- [Management UI](https://github.com/sintan1729/chhoto-url/blob/main/frontend/static/script.js): `frontend/static/script.js`
- [Public landing UI](https://github.com/sintan1729/chhoto-url/blob/main/site/static/script.js): `site/static/script.js`

### Other components

- **Link visitor**
- **Admin or API client**

## Connections

- HTTP server → Runtime configuration: loads settings (evidence: `backend/src/main.rs`)
- HTTP server → Authentication: wires authentication (evidence: `backend/src/main.rs`)
- HTTP server → Create and login API: registers routes (evidence: `backend/src/main.rs`)
- HTTP server → Read and redirect API: registers routes (evidence: `backend/src/main.rs`)
- HTTP server → Edit link API: registers routes
- HTTP server → Delete link API: registers routes
- HTTP server → SQLite database: initializes (evidence: `backend/src/main.rs`)
- HTTP server → Background workers: starts workers (evidence: `backend/src/main.rs`)
- HTTP server → Health endpoint: registers endpoint
- Admin or API client → Management UI: uses (evidence: `README.md`)
- Admin or API client → Create and login API: submits requests
- Link visitor → Read and redirect API: opens short link (evidence: `README.md`)
- Management UI → Create and login API: uses API
- Create and login API → Authentication: checks access (evidence: `backend/src/services/post.rs`)
- Create and login API → Service helpers: delegates creation (evidence: `backend/src/services/post.rs`)
- Create and login API → SQLite database: reads link details (evidence: `backend/src/services/post.rs`)
- Read and redirect API → Authentication: checks access
- Read and redirect API → SQLite database: reads links (evidence: `backend/src/services/get.rs`)
- Read and redirect API → Link and hit operations: records redirect hit (evidence: `backend/src/services/get.rs`)
- Edit link API → Service helpers: delegates edits
- Delete link API → Service helpers: delegates deletion (evidence: `backend/src/services/delete.rs`)
- Service helpers → Link and hit operations: changes link data
- Link and hit operations → SQLite database: queries and updates
- Background workers → Link and hit operations: flushes hit counts (evidence: `backend/src/background.rs`)
- Background workers → SQLite database: cleans expired links (evidence: `backend/src/background.rs`)
- Link and hit operations → SQL queries: uses SQL definitions
- Public landing UI → HTTP server: served by
