# miantiao-me/sink architecture

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

- Interactive diagram: https://gitdiagram.com/miantiao-me/sink
- Repository: https://github.com/miantiao-me/sink

## Overview

Sink is a Cloudflare-hosted link shortener with a dashboard, redirect handling, and access analytics. The principal workflow is creating and managing short links, resolving visits through redirect logic, and turning click context into analytics that the dashboard can query. Separate capabilities include link checking, import/export, real-time event views, and MCP tools. The graph reflects README-documented features and the supplied source excerpts/index; several dashboard and server subsystems are represented at their documented boundaries because their implementation excerpts were not provided.

Main entry points: [`app/layouts/dashboard.vue`](https://github.com/miantiao-me/sink/blob/master/app/layouts/dashboard.vue) (Dashboard UI), [`server/middleware/1.redirect.ts`](https://github.com/miantiao-me/sink/blob/master/server/middleware/1.redirect.ts) (Short-link redirect), [`server/utils/link-store.ts`](https://github.com/miantiao-me/sink/blob/master/server/utils/link-store.ts) (Link store), [`app/components/dashboard/links/Index.vue`](https://github.com/miantiao-me/sink/blob/master/app/components/dashboard/links/Index.vue) (Link management)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Dashboard"]
  node_dashboard["Dashboard UI<br/>[dashboard.vue]"]
  node_links_ui["Link management<br/>[Index.vue]"]
  node_analysis_ui["Analytics views<br/>[Index.vue]"]
  node_realtime_ui["Live analytics<br/>[Index.vue]"]
  node_migrate_ui["Import export UI<br/>[Index.vue]"]
  node_check_ui["Link checker UI<br/>[Index.vue]"]
end

subgraph group_links["Link lifecycle"]
  node_link_api["Link query API<br/>[query.get.ts]"]
  node_search_api["Link search API<br/>[search.get.ts]"]
  node_redirect["Short-link redirect<br/>[1.redirect.ts]"]
  node_link_processing["Link processing<br/>[link-processing.ts]"]
  node_link_store[("Link store<br/>[link-store.ts]")]
  node_d1[("D1 adapter<br/>[d1.ts]")]
  node_link_check["Link checking<br/>[link-check.ts]"]
end

subgraph group_analytics["Analytics"]
  node_access_log["Access context<br/>[access-log.ts]"]
  node_analytics_api["Analytics queries"]
  node_wae[("Analytics Engine<br/>[cloudflare.ts]")]
  node_events_api["Event polling API<br/>[events.get.ts]"]
  node_globe["3D globe renderer<br/>[useWebGLGlobe.ts]"]
end

subgraph group_platform["Server platform"]
  node_auth["Session and auth<br/>[useAuthSession.ts]"]
end

subgraph group_integrations["Integrations"]
  node_mcp_api["MCP endpoint<br/>[mcp.ts]"]
  node_mcp_server["MCP server<br/>[server.ts]"]
  node_mcp_tools["MCP tools<br/>[tools.ts]"]
  node_webhook["Click webhooks<br/>[webhook.ts]"]
end

node_user(("Dashboard user"))
node_visitor(("Link visitor"))
node_mcp_client(("MCP client"))
node_cloudflare["Cloudflare runtime"]

node_user -.->|"uses"| node_dashboard
node_dashboard -.->|"checks session"| node_auth
node_dashboard -.->|"opens links"| node_links_ui
node_dashboard -.->|"opens analytics"| node_analysis_ui
node_dashboard -.->|"opens live view"| node_realtime_ui
node_dashboard -.->|"manages transfers"| node_migrate_ui
node_dashboard -.->|"checks links"| node_check_ui
node_links_ui -.->|"queries links"| node_link_api
node_links_ui -.->|"searches links"| node_search_api
node_visitor -.->|"requests short URL"| node_redirect
node_redirect -.->|"reads link"| node_link_store
node_link_processing -.->|"updates links"| node_link_store
node_link_store -.->|"uses adapter"| node_d1
node_redirect -.->|"records visit"| node_access_log
node_access_log -.->|"writes event data"| node_wae
node_analysis_ui -.->|"requests metrics"| node_analytics_api
node_analytics_api -.->|"queries"| node_wae
node_realtime_ui -.->|"polls events"| node_events_api
node_realtime_ui -.->|"renders locations"| node_globe
node_check_ui -.->|"checks destinations"| node_link_check
node_mcp_client -->|"calls tools"| node_mcp_api
node_mcp_api -->|"handles request"| node_mcp_server
node_mcp_server -->|"registers tools"| node_mcp_tools
node_mcp_tools -->|"reads and writes"| node_link_store
node_mcp_tools -->|"builds analytics queries"| node_analytics_api
node_cloudflare -.->|"hosts storage"| node_d1
node_cloudflare -.->|"provides analytics"| node_wae
node_redirect -.->|"schedules click delivery"| node_webhook

click node_dashboard "https://github.com/miantiao-me/sink/blob/master/app/layouts/dashboard.vue"
click node_links_ui "https://github.com/miantiao-me/sink/blob/master/app/components/dashboard/links/Index.vue"
click node_analysis_ui "https://github.com/miantiao-me/sink/blob/master/app/components/dashboard/analysis/Index.vue"
click node_realtime_ui "https://github.com/miantiao-me/sink/blob/master/app/components/dashboard/realtime/Index.vue"
click node_migrate_ui "https://github.com/miantiao-me/sink/blob/master/app/components/dashboard/migrate/Index.vue"
click node_check_ui "https://github.com/miantiao-me/sink/blob/master/app/components/dashboard/check/Index.vue"
click node_auth "https://github.com/miantiao-me/sink/blob/master/app/composables/useAuthSession.ts"
click node_link_api "https://github.com/miantiao-me/sink/blob/master/server/api/link/query.get.ts"
click node_search_api "https://github.com/miantiao-me/sink/blob/master/server/api/link/search.get.ts"
click node_redirect "https://github.com/miantiao-me/sink/blob/master/server/middleware/1.redirect.ts"
click node_link_processing "https://github.com/miantiao-me/sink/blob/master/server/utils/link-processing.ts"
click node_link_store "https://github.com/miantiao-me/sink/blob/master/server/utils/link-store.ts"
click node_d1 "https://github.com/miantiao-me/sink/blob/master/server/services/link-store/d1.ts"
click node_link_check "https://github.com/miantiao-me/sink/blob/master/server/utils/link-check.ts"
click node_access_log "https://github.com/miantiao-me/sink/blob/master/server/utils/access-log.ts"
click node_analytics_api "https://github.com/miantiao-me/sink/blob/master/server/utils/analytics-queries.ts"
click node_wae "https://github.com/miantiao-me/sink/blob/master/server/utils/cloudflare.ts"
click node_events_api "https://github.com/miantiao-me/sink/blob/master/server/api/logs/events.get.ts"
click node_globe "https://github.com/miantiao-me/sink/blob/master/app/composables/globe/useWebGLGlobe.ts"
click node_mcp_api "https://github.com/miantiao-me/sink/blob/master/server/api/mcp.ts"
click node_mcp_server "https://github.com/miantiao-me/sink/blob/master/server/services/mcp/server.ts"
click node_mcp_tools "https://github.com/miantiao-me/sink/blob/master/server/services/mcp/tools.ts"
click node_webhook "https://github.com/miantiao-me/sink/blob/master/server/utils/webhook.ts"

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_dashboard,node_links_ui,node_analysis_ui,node_realtime_ui,node_migrate_ui,node_check_ui,node_user,node_mcp_client toneBlue
class node_link_api,node_search_api,node_redirect,node_link_processing,node_link_store,node_d1,node_link_check toneAmber
class node_access_log,node_analytics_api,node_wae,node_events_api,node_globe toneMint
class node_auth toneRose
class node_mcp_api,node_mcp_server,node_mcp_tools,node_webhook,node_visitor,node_cloudflare toneIndigo
```

## Components

### Dashboard

- [Dashboard UI](https://github.com/miantiao-me/sink/blob/master/app/layouts/dashboard.vue): `app/layouts/dashboard.vue`
- [Link management](https://github.com/miantiao-me/sink/blob/master/app/components/dashboard/links/Index.vue): `app/components/dashboard/links/Index.vue`
- [Analytics views](https://github.com/miantiao-me/sink/blob/master/app/components/dashboard/analysis/Index.vue): `app/components/dashboard/analysis/Index.vue`
- [Live analytics](https://github.com/miantiao-me/sink/blob/master/app/components/dashboard/realtime/Index.vue): `app/components/dashboard/realtime/Index.vue`
- [Import export UI](https://github.com/miantiao-me/sink/blob/master/app/components/dashboard/migrate/Index.vue): `app/components/dashboard/migrate/Index.vue`
- [Link checker UI](https://github.com/miantiao-me/sink/blob/master/app/components/dashboard/check/Index.vue): `app/components/dashboard/check/Index.vue`

### Link lifecycle

- [Link query API](https://github.com/miantiao-me/sink/blob/master/server/api/link/query.get.ts): `server/api/link/query.get.ts`
- [Link search API](https://github.com/miantiao-me/sink/blob/master/server/api/link/search.get.ts): `server/api/link/search.get.ts`
- [Short-link redirect](https://github.com/miantiao-me/sink/blob/master/server/middleware/1.redirect.ts): `server/middleware/1.redirect.ts`
- [Link processing](https://github.com/miantiao-me/sink/blob/master/server/utils/link-processing.ts): `server/utils/link-processing.ts`
- [Link store](https://github.com/miantiao-me/sink/blob/master/server/utils/link-store.ts): `server/utils/link-store.ts`
- [D1 adapter](https://github.com/miantiao-me/sink/blob/master/server/services/link-store/d1.ts): `server/services/link-store/d1.ts`
- [Link checking](https://github.com/miantiao-me/sink/blob/master/server/utils/link-check.ts): `server/utils/link-check.ts`

### Analytics

- [Access context](https://github.com/miantiao-me/sink/blob/master/server/utils/access-log.ts): `server/utils/access-log.ts`
- [Analytics queries](https://github.com/miantiao-me/sink/blob/master/server/utils/analytics-queries.ts): `server/utils/analytics-queries.ts`
- [Analytics Engine](https://github.com/miantiao-me/sink/blob/master/server/utils/cloudflare.ts): `server/utils/cloudflare.ts`
- [Event polling API](https://github.com/miantiao-me/sink/blob/master/server/api/logs/events.get.ts): `server/api/logs/events.get.ts`
- [3D globe renderer](https://github.com/miantiao-me/sink/blob/master/app/composables/globe/useWebGLGlobe.ts): `app/composables/globe/useWebGLGlobe.ts`

### Server platform

- [Session and auth](https://github.com/miantiao-me/sink/blob/master/app/composables/useAuthSession.ts): `app/composables/useAuthSession.ts`

### Integrations

- [MCP endpoint](https://github.com/miantiao-me/sink/blob/master/server/api/mcp.ts): `server/api/mcp.ts`
- [MCP server](https://github.com/miantiao-me/sink/blob/master/server/services/mcp/server.ts): `server/services/mcp/server.ts`
- [MCP tools](https://github.com/miantiao-me/sink/blob/master/server/services/mcp/tools.ts): `server/services/mcp/tools.ts`
- [Click webhooks](https://github.com/miantiao-me/sink/blob/master/server/utils/webhook.ts): `server/utils/webhook.ts`

### Other components

- **Dashboard user**
- **Link visitor**
- **MCP client**
- **Cloudflare runtime**

## Connections

- Dashboard user → Dashboard UI: uses
- Dashboard UI → Session and auth: checks session
- Dashboard UI → Link management: opens links
- Dashboard UI → Analytics views: opens analytics
- Dashboard UI → Live analytics: opens live view
- Dashboard UI → Import export UI: manages transfers
- Dashboard UI → Link checker UI: checks links
- Link management → Link query API: queries links
- Link management → Link search API: searches links
- Link visitor → Short-link redirect: requests short URL
- Short-link redirect → Link store: reads link
- Link processing → Link store: updates links
- Link store → D1 adapter: uses adapter
- Short-link redirect → Access context: records visit
- Access context → Analytics Engine: writes event data
- Analytics views → Analytics queries: requests metrics
- Analytics queries → Analytics Engine: queries
- Live analytics → Event polling API: polls events (evidence: `README.md`)
- Live analytics → 3D globe renderer: renders locations (evidence: `README.md`)
- Link checker UI → Link checking: checks destinations (evidence: `README.md`)
- MCP client → MCP endpoint: calls tools (evidence: `README.md`)
- MCP endpoint → MCP server: handles request (evidence: `server/services/mcp/server.ts`)
- MCP server → MCP tools: registers tools (evidence: `server/services/mcp/server.ts`)
- MCP tools → Link store: reads and writes (evidence: `server/services/mcp/tools.ts`)
- MCP tools → Analytics queries: builds analytics queries (evidence: `server/services/mcp/tools.ts`)
- Cloudflare runtime → D1 adapter: hosts storage (evidence: `README.md`)
- Cloudflare runtime → Analytics Engine: provides analytics (evidence: `README.md`)
- Short-link redirect → Click webhooks: schedules click delivery (evidence: `README.md`)
