# dvin1211/cut_link architecture

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

- Interactive diagram: https://gitdiagram.com/dvin1211/cut_link
- Repository: https://github.com/dvin1211/cut_link

## Overview

Cut Link is a URL-shortening application with a React client and Django REST API. Users authenticate, create short links with generated or custom aliases, manage their links, and follow redirects; click counts are buffered and periodically persisted, with daily statistics stored as well. The README documents the multi-backend deployment and Redis, RabbitMQ, PostgreSQL, and Celery roles. Several endpoint and page implementations were not sampled, so their internal call wiring is shown only where supported by the tree or documentation.

Main entry points: [`backend/links/services.py`](https://github.com/dvin1211/cut_link/blob/main/backend/links/services.py) (Link services), [`frontend/src/api/client.ts`](https://github.com/dvin1211/cut_link/blob/main/frontend/src/api/client.ts) (API transport), [`frontend/src/pages`](https://github.com/dvin1211/cut_link/tree/main/frontend/src/pages) (App pages), [`frontend/src/pages/CabinetPage.tsx`](https://github.com/dvin1211/cut_link/blob/main/frontend/src/pages/CabinetPage.tsx) (Link cabinet)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Web client"]
  node_app["Route shell<br/>[App.tsx]"]
  node_pages["App pages"]
  node_cabinet["Link cabinet<br/>[CabinetPage.tsx]"]
  node_linkform["Create form<br/>[LinkCreateForm.tsx]"]
  node_linklist["Link list<br/>[LinksList.tsx]"]
  node_apiclient["API transport<br/>[client.ts]"]
end

subgraph group_identity["Identity"]
  node_authcontext["Auth state<br/>[AuthContext.tsx]"]
  node_authapi["Auth client<br/>[auth.ts]"]
  node_usersapi["User endpoints<br/>[urls.py]"]
  node_userviews["User handlers<br/>[views.py]"]
  node_userrecords["User records<br/>[models.py]"]
end

subgraph group_links["Link lifecycle"]
  node_linksapi["Link endpoints<br/>[urls.py]"]
  node_linkviews["Link handlers<br/>[views.py]"]
  node_linkservices["Link services<br/>[services.py]"]
  node_linkrecords[("Link records<br/>[models.py]")]
  node_redirectcache["Redirect cache<br/>[cache_utils.py]"]
end

subgraph group_analytics["Click analytics"]
  node_clickbuffer["Click buffer<br/>[click_buffer.py]"]
  node_task["Flush task<br/>[tasks.py]"]
  node_settings["Task schedule<br/>[settings.py]"]
end

node_visitor(("Visitor"))
node_browser(("Browser"))
node_postgres[("PostgreSQL")]
node_redis[("Redis")]
node_rabbitmq["RabbitMQ"]
node_target(("Destination URL"))

node_visitor -->|"uses"| node_browser
node_browser -->|"opens"| node_app
node_app -->|"routes"| node_pages
node_pages -->|"uses auth"| node_authcontext
node_pages -->|"shows"| node_cabinet
node_cabinet -->|"creates links"| node_linkform
node_cabinet -->|"manages links"| node_linklist
node_authcontext -->|"calls"| node_authapi
node_authapi -->|"requests"| node_apiclient
node_linkform -->|"submits"| node_apiclient
node_linklist -->|"requests"| node_apiclient
node_apiclient -->|"HTTP requests"| node_usersapi
node_apiclient -->|"HTTP requests"| node_linksapi
node_usersapi -->|"dispatches"| node_userviews
node_userviews -->|"reads/writes"| node_userrecords
node_linksapi -->|"dispatches"| node_linkviews
node_linkviews -->|"delegates"| node_linkservices
node_linkservices -->|"reads/writes"| node_linkrecords
node_linkservices -->|"caches/invalidates"| node_redirectcache
node_redirectcache -->|"reads/writes"| node_redis
node_linkservices -->|"records/flushes"| node_clickbuffer
node_clickbuffer -->|"buffers clicks"| node_redis
node_linkservices -->|"persists counts"| node_linkrecords
node_linkrecords -->|"stores"| node_postgres
node_settings -->|"schedules"| node_task
node_task -->|"calls flush"| node_linkservices
node_settings -.->|"configures broker"| node_rabbitmq
node_browser -->|"follows short link"| node_target

click node_app "https://github.com/dvin1211/cut_link/blob/main/frontend/src/App.tsx"
click node_pages "https://github.com/dvin1211/cut_link/tree/main/frontend/src/pages"
click node_cabinet "https://github.com/dvin1211/cut_link/blob/main/frontend/src/pages/CabinetPage.tsx"
click node_linkform "https://github.com/dvin1211/cut_link/blob/main/frontend/src/components/LinkCreateForm.tsx"
click node_linklist "https://github.com/dvin1211/cut_link/blob/main/frontend/src/components/LinksList.tsx"
click node_authcontext "https://github.com/dvin1211/cut_link/blob/main/frontend/src/auth/AuthContext.tsx"
click node_authapi "https://github.com/dvin1211/cut_link/blob/main/frontend/src/api/auth.ts"
click node_apiclient "https://github.com/dvin1211/cut_link/blob/main/frontend/src/api/client.ts"
click node_usersapi "https://github.com/dvin1211/cut_link/blob/main/backend/users/urls.py"
click node_userviews "https://github.com/dvin1211/cut_link/blob/main/backend/users/views.py"
click node_userrecords "https://github.com/dvin1211/cut_link/blob/main/backend/users/models.py"
click node_linksapi "https://github.com/dvin1211/cut_link/blob/main/backend/links/urls.py"
click node_linkviews "https://github.com/dvin1211/cut_link/blob/main/backend/links/views.py"
click node_linkservices "https://github.com/dvin1211/cut_link/blob/main/backend/links/services.py"
click node_linkrecords "https://github.com/dvin1211/cut_link/blob/main/backend/links/models.py"
click node_redirectcache "https://github.com/dvin1211/cut_link/blob/main/backend/links/cache_utils.py"
click node_clickbuffer "https://github.com/dvin1211/cut_link/blob/main/backend/links/click_buffer.py"
click node_task "https://github.com/dvin1211/cut_link/blob/main/backend/links/tasks.py"
click node_settings "https://github.com/dvin1211/cut_link/blob/main/backend/config/settings.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_app,node_pages,node_cabinet,node_linkform,node_linklist,node_apiclient,node_browser toneBlue
class node_authcontext,node_authapi,node_usersapi,node_userviews,node_userrecords,node_postgres,node_redis toneAmber
class node_linksapi,node_linkviews,node_linkservices,node_linkrecords,node_redirectcache toneMint
class node_clickbuffer,node_task,node_settings toneRose
class node_visitor,node_rabbitmq,node_target toneIndigo
```

## Components

### Web client

- [Route shell](https://github.com/dvin1211/cut_link/blob/main/frontend/src/App.tsx): `frontend/src/App.tsx`
- [App pages](https://github.com/dvin1211/cut_link/tree/main/frontend/src/pages): `frontend/src/pages`
- [Link cabinet](https://github.com/dvin1211/cut_link/blob/main/frontend/src/pages/CabinetPage.tsx): `frontend/src/pages/CabinetPage.tsx`
- [Create form](https://github.com/dvin1211/cut_link/blob/main/frontend/src/components/LinkCreateForm.tsx): `frontend/src/components/LinkCreateForm.tsx`
- [Link list](https://github.com/dvin1211/cut_link/blob/main/frontend/src/components/LinksList.tsx): `frontend/src/components/LinksList.tsx`
- [API transport](https://github.com/dvin1211/cut_link/blob/main/frontend/src/api/client.ts): `frontend/src/api/client.ts`

### Identity

- [Auth state](https://github.com/dvin1211/cut_link/blob/main/frontend/src/auth/AuthContext.tsx): `frontend/src/auth/AuthContext.tsx`
- [Auth client](https://github.com/dvin1211/cut_link/blob/main/frontend/src/api/auth.ts): `frontend/src/api/auth.ts`
- [User endpoints](https://github.com/dvin1211/cut_link/blob/main/backend/users/urls.py): `backend/users/urls.py`
- [User handlers](https://github.com/dvin1211/cut_link/blob/main/backend/users/views.py): `backend/users/views.py`
- [User records](https://github.com/dvin1211/cut_link/blob/main/backend/users/models.py): `backend/users/models.py`

### Link lifecycle

- [Link endpoints](https://github.com/dvin1211/cut_link/blob/main/backend/links/urls.py): `backend/links/urls.py`
- [Link handlers](https://github.com/dvin1211/cut_link/blob/main/backend/links/views.py): `backend/links/views.py`
- [Link services](https://github.com/dvin1211/cut_link/blob/main/backend/links/services.py): `backend/links/services.py`
- [Link records](https://github.com/dvin1211/cut_link/blob/main/backend/links/models.py): `backend/links/models.py`
- [Redirect cache](https://github.com/dvin1211/cut_link/blob/main/backend/links/cache_utils.py): `backend/links/cache_utils.py`

### Click analytics

- [Click buffer](https://github.com/dvin1211/cut_link/blob/main/backend/links/click_buffer.py): `backend/links/click_buffer.py`
- [Flush task](https://github.com/dvin1211/cut_link/blob/main/backend/links/tasks.py): `backend/links/tasks.py`
- [Task schedule](https://github.com/dvin1211/cut_link/blob/main/backend/config/settings.py): `backend/config/settings.py`

### Other components

- **Visitor**
- **Browser**
- **PostgreSQL**
- **Redis**
- **RabbitMQ**
- **Destination URL**

## Connections

- Visitor → Browser: uses
- Browser → Route shell: opens
- Route shell → App pages: routes
- App pages → Auth state: uses auth
- App pages → Link cabinet: shows
- Link cabinet → Create form: creates links
- Link cabinet → Link list: manages links
- Auth state → Auth client: calls
- Auth client → API transport: requests
- Create form → API transport: submits
- Link list → API transport: requests
- API transport → User endpoints: HTTP requests
- API transport → Link endpoints: HTTP requests
- User endpoints → User handlers: dispatches
- User handlers → User records: reads/writes
- Link endpoints → Link handlers: dispatches
- Link handlers → Link services: delegates
- Link services → Link records: reads/writes
- Link services → Redirect cache: caches/invalidates
- Redirect cache → Redis: reads/writes
- Link services → Click buffer: records/flushes
- Click buffer → Redis: buffers clicks
- Link services → Link records: persists counts
- Link records → PostgreSQL: stores
- Task schedule → Flush task: schedules
- Flush task → Link services: calls flush
- Task schedule → RabbitMQ: configures broker
- Browser → Destination URL: follows short link
