# yalamarthi-kuladeep/url-shortner architecture

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

- Interactive diagram: https://gitdiagram.com/yalamarthi-kuladeep/url-shortner
- Repository: https://github.com/yalamarthi-kuladeep/url-shortner

## Overview

This repository implements a URL-shortening web application. Users register or sign in, then create and manage short links, view click statistics and per-link analytics, and follow public short links through redirects. The client’s dashboard initiates link-management requests; the server routes requests through authentication and validation to controllers and domain services. Server setup and persistence wiring are shown, but the client API’s HTTP target is not established by the excerpts, so that connection is marked unverified.

Main entry points: [`url-shortener/server/server.js`](https://github.com/yalamarthi-kuladeep/url-shortner/blob/main/url-shortener/server/server.js) (HTTP server), [`url-shortener/client/src/App.jsx`](https://github.com/yalamarthi-kuladeep/url-shortner/blob/main/url-shortener/client/src/App.jsx) (App routing), [`url-shortener/server/routes/authRoutes.js`](https://github.com/yalamarthi-kuladeep/url-shortner/blob/main/url-shortener/server/routes/authRoutes.js) (Auth routes), [`url-shortener/server/routes/urlRoutes.js`](https://github.com/yalamarthi-kuladeep/url-shortner/blob/main/url-shortener/server/routes/urlRoutes.js) (Link routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Web client"]
  node_app["App routing<br/>[App.jsx]"]
  node_auth_ui["Auth state<br/>[AuthContext.jsx]"]
  node_dashboard["Link dashboard<br/>[Dashboard.jsx]"]
  node_analytics_ui["Link analytics<br/>[Analytics.jsx]"]
  node_api_client["API client<br/>[api.js]"]
end

subgraph group_server["API server"]
  node_auth_routes["Auth routes<br/>[authRoutes.js]"]
  node_url_routes["Link routes<br/>[urlRoutes.js]"]
  node_url_controller["Link controller<br/>[urlController.js]"]
  node_auth_controller["Auth controller<br/>[authController.js]"]
  node_auth_middleware["Authentication<br/>[auth.js]"]
  node_validation["Request validation<br/>[validate.js]"]
  node_server_entry["HTTP server<br/>[server.js]"]
end

subgraph group_domain["Domain services"]
  node_auth_service["Account service<br/>[authService.js]"]
  node_token_service["Token service<br/>[tokenService.js]"]
  node_url_service["Short-link service<br/>[urlService.js]"]
end

subgraph group_persistence["Persistence"]
  node_url_model["Link records<br/>[Url.js]"]
  node_user_model["User records<br/>[User.js]"]
  node_db_config["Database connection<br/>[db.js]"]
end

node_visitor(("Visitor"))
node_mongo[("MongoDB")]

node_visitor -->|"uses"| node_app
node_app -->|"routes to"| node_dashboard
node_app -->|"routes to"| node_analytics_ui
node_app -->|"renders navigation"| node_auth_ui
node_dashboard -->|"requests links"| node_api_client
node_auth_ui -->|"requests accounts"| node_api_client
node_api_client -.->|"sends API requests"| node_server_entry
node_server_entry -->|"mounts"| node_auth_routes
node_server_entry -->|"mounts"| node_url_routes
node_server_entry -->|"routes redirects"| node_url_controller
node_auth_routes -->|"dispatches to"| node_auth_controller
node_auth_routes -->|"protects session route"| node_auth_middleware
node_auth_routes -->|"validates input"| node_validation
node_url_routes -->|"dispatches to"| node_url_controller
node_url_routes -->|"protects links"| node_auth_middleware
node_url_routes -->|"validates input"| node_validation
node_url_controller -->|"invokes operations"| node_url_service
node_auth_controller -->|"invokes account operations"| node_auth_service
node_auth_service -->|"reads and creates"| node_user_model
node_auth_service -->|"signs token"| node_token_service
node_auth_middleware -->|"loads user"| node_user_model
node_url_service -->|"manages link records"| node_url_model
node_db_config -->|"connects"| node_mongo
node_server_entry -->|"connects database"| node_db_config

click node_app "https://github.com/yalamarthi-kuladeep/url-shortner/blob/main/url-shortener/client/src/App.jsx"
click node_auth_ui "https://github.com/yalamarthi-kuladeep/url-shortner/blob/main/url-shortener/client/src/context/AuthContext.jsx"
click node_dashboard "https://github.com/yalamarthi-kuladeep/url-shortner/blob/main/url-shortener/client/src/pages/Dashboard.jsx"
click node_analytics_ui "https://github.com/yalamarthi-kuladeep/url-shortner/blob/main/url-shortener/client/src/pages/Analytics.jsx"
click node_api_client "https://github.com/yalamarthi-kuladeep/url-shortner/blob/main/url-shortener/client/src/services/api.js"
click node_auth_routes "https://github.com/yalamarthi-kuladeep/url-shortner/blob/main/url-shortener/server/routes/authRoutes.js"
click node_url_routes "https://github.com/yalamarthi-kuladeep/url-shortner/blob/main/url-shortener/server/routes/urlRoutes.js"
click node_url_controller "https://github.com/yalamarthi-kuladeep/url-shortner/blob/main/url-shortener/server/controllers/urlController.js"
click node_auth_controller "https://github.com/yalamarthi-kuladeep/url-shortner/blob/main/url-shortener/server/controllers/authController.js"
click node_auth_middleware "https://github.com/yalamarthi-kuladeep/url-shortner/blob/main/url-shortener/server/middleware/auth.js"
click node_validation "https://github.com/yalamarthi-kuladeep/url-shortner/blob/main/url-shortener/server/middleware/validate.js"
click node_server_entry "https://github.com/yalamarthi-kuladeep/url-shortner/blob/main/url-shortener/server/server.js"
click node_auth_service "https://github.com/yalamarthi-kuladeep/url-shortner/blob/main/url-shortener/server/services/authService.js"
click node_token_service "https://github.com/yalamarthi-kuladeep/url-shortner/blob/main/url-shortener/server/services/tokenService.js"
click node_url_service "https://github.com/yalamarthi-kuladeep/url-shortner/blob/main/url-shortener/server/services/urlService.js"
click node_url_model "https://github.com/yalamarthi-kuladeep/url-shortner/blob/main/url-shortener/server/models/Url.js"
click node_user_model "https://github.com/yalamarthi-kuladeep/url-shortner/blob/main/url-shortener/server/models/User.js"
click node_db_config "https://github.com/yalamarthi-kuladeep/url-shortner/blob/main/url-shortener/server/config/db.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_app,node_auth_ui,node_dashboard,node_analytics_ui,node_api_client toneBlue
class node_auth_routes,node_url_routes,node_url_controller,node_auth_controller,node_auth_middleware,node_validation,node_server_entry,node_mongo toneAmber
class node_auth_service,node_token_service,node_url_service toneMint
class node_url_model,node_user_model,node_db_config toneRose
class node_visitor toneIndigo
```

## Components

### Web client

- [App routing](https://github.com/yalamarthi-kuladeep/url-shortner/blob/main/url-shortener/client/src/App.jsx): `url-shortener/client/src/App.jsx`
- [Auth state](https://github.com/yalamarthi-kuladeep/url-shortner/blob/main/url-shortener/client/src/context/AuthContext.jsx): `url-shortener/client/src/context/AuthContext.jsx`
- [Link dashboard](https://github.com/yalamarthi-kuladeep/url-shortner/blob/main/url-shortener/client/src/pages/Dashboard.jsx): `url-shortener/client/src/pages/Dashboard.jsx`
- [Link analytics](https://github.com/yalamarthi-kuladeep/url-shortner/blob/main/url-shortener/client/src/pages/Analytics.jsx): `url-shortener/client/src/pages/Analytics.jsx`
- [API client](https://github.com/yalamarthi-kuladeep/url-shortner/blob/main/url-shortener/client/src/services/api.js): `url-shortener/client/src/services/api.js`

### API server

- [Auth routes](https://github.com/yalamarthi-kuladeep/url-shortner/blob/main/url-shortener/server/routes/authRoutes.js): `url-shortener/server/routes/authRoutes.js`
- [Link routes](https://github.com/yalamarthi-kuladeep/url-shortner/blob/main/url-shortener/server/routes/urlRoutes.js): `url-shortener/server/routes/urlRoutes.js`
- [Link controller](https://github.com/yalamarthi-kuladeep/url-shortner/blob/main/url-shortener/server/controllers/urlController.js): `url-shortener/server/controllers/urlController.js`
- [Auth controller](https://github.com/yalamarthi-kuladeep/url-shortner/blob/main/url-shortener/server/controllers/authController.js): `url-shortener/server/controllers/authController.js`
- [Authentication](https://github.com/yalamarthi-kuladeep/url-shortner/blob/main/url-shortener/server/middleware/auth.js): `url-shortener/server/middleware/auth.js`
- [Request validation](https://github.com/yalamarthi-kuladeep/url-shortner/blob/main/url-shortener/server/middleware/validate.js): `url-shortener/server/middleware/validate.js`
- [HTTP server](https://github.com/yalamarthi-kuladeep/url-shortner/blob/main/url-shortener/server/server.js): `url-shortener/server/server.js`

### Domain services

- [Account service](https://github.com/yalamarthi-kuladeep/url-shortner/blob/main/url-shortener/server/services/authService.js): `url-shortener/server/services/authService.js`
- [Token service](https://github.com/yalamarthi-kuladeep/url-shortner/blob/main/url-shortener/server/services/tokenService.js): `url-shortener/server/services/tokenService.js`
- [Short-link service](https://github.com/yalamarthi-kuladeep/url-shortner/blob/main/url-shortener/server/services/urlService.js): `url-shortener/server/services/urlService.js`

### Persistence

- [Link records](https://github.com/yalamarthi-kuladeep/url-shortner/blob/main/url-shortener/server/models/Url.js): `url-shortener/server/models/Url.js`
- [User records](https://github.com/yalamarthi-kuladeep/url-shortner/blob/main/url-shortener/server/models/User.js): `url-shortener/server/models/User.js`
- [Database connection](https://github.com/yalamarthi-kuladeep/url-shortner/blob/main/url-shortener/server/config/db.js): `url-shortener/server/config/db.js`

### Other components

- **Visitor**
- **MongoDB**

## Connections

- Visitor → App routing: uses (evidence: `url-shortener/client/src/App.jsx`)
- App routing → Link dashboard: routes to (evidence: `url-shortener/client/src/App.jsx`)
- App routing → Link analytics: routes to (evidence: `url-shortener/client/src/App.jsx`)
- App routing → Auth state: renders navigation (evidence: `url-shortener/client/src/App.jsx`)
- Link dashboard → API client: requests links (evidence: `url-shortener/client/src/pages/Dashboard.jsx`)
- Auth state → API client: requests accounts (evidence: `url-shortener/client/src/context/AuthContext.jsx`)
- API client → HTTP server: sends API requests
- HTTP server → Auth routes: mounts (evidence: `url-shortener/server/server.js`)
- HTTP server → Link routes: mounts (evidence: `url-shortener/server/server.js`)
- HTTP server → Link controller: routes redirects (evidence: `url-shortener/server/server.js`)
- Auth routes → Auth controller: dispatches to (evidence: `url-shortener/server/routes/authRoutes.js`)
- Auth routes → Authentication: protects session route (evidence: `url-shortener/server/routes/authRoutes.js`)
- Auth routes → Request validation: validates input (evidence: `url-shortener/server/routes/authRoutes.js`)
- Link routes → Link controller: dispatches to (evidence: `url-shortener/server/routes/urlRoutes.js`)
- Link routes → Authentication: protects links (evidence: `url-shortener/server/routes/urlRoutes.js`)
- Link routes → Request validation: validates input (evidence: `url-shortener/server/routes/urlRoutes.js`)
- Link controller → Short-link service: invokes operations (evidence: `url-shortener/server/controllers/urlController.js`)
- Auth controller → Account service: invokes account operations (evidence: `url-shortener/server/controllers/authController.js`)
- Account service → User records: reads and creates (evidence: `url-shortener/server/services/authService.js`)
- Account service → Token service: signs token (evidence: `url-shortener/server/services/authService.js`)
- Authentication → User records: loads user (evidence: `url-shortener/server/middleware/auth.js`)
- Short-link service → Link records: manages link records (evidence: `url-shortener/server/services/urlService.js`)
- Database connection → MongoDB: connects (evidence: `url-shortener/server/config/db.js`)
- HTTP server → Database connection: connects database (evidence: `url-shortener/server/server.js`)
