# sonal-wadkar/url-shortener architecture

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

- Interactive diagram: https://gitdiagram.com/sonal-wadkar/url-shortener
- Repository: https://github.com/sonal-wadkar/url-shortener

## Overview

Linkly’s main flow is browser authentication, then creating and managing short links in a protected dashboard; opening a short link triggers backend redirect and click tracking. README documents the backend API, JWT security, and MySQL persistence, but backend source excerpts were not provided, so those internals are represented at documented subsystem level and their connections cite the README.

Main entry points: [`url-shortner-frontend/src/api/api.js`](https://github.com/sonal-wadkar/url-shortener/blob/main/url-shortner-frontend/src/api/api.js) (REST client), [`url-shortner-frontend/src/AppRouter.jsx`](https://github.com/sonal-wadkar/url-shortener/blob/main/url-shortner-frontend/src/AppRouter.jsx) (Page routing), [`url-shortner-frontend/src/components/Dashboard/DashboardLayout.jsx`](https://github.com/sonal-wadkar/url-shortener/blob/main/url-shortner-frontend/src/components/Dashboard/DashboardLayout.jsx) (Link dashboard), [`short/src/main/java/com/example/demo/controller/UrlMappingController.java`](https://github.com/sonal-wadkar/url-shortener/blob/main/short/src/main/java/com/example/demo/controller/UrlMappingController.java) (URL management API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["React frontend"]
  node_app["App bootstrap<br/>[main.jsx]"]
  node_routing["Page routing<br/>[AppRouter.jsx]"]
  node_landing["Landing page<br/>[LandingPage.jsx]"]
  node_auth_ui["Login and register<br/>[LoginPage.jsx]"]
  node_dashboard["Link dashboard"]
  node_create_ui["Create short link"]
  node_link_list["Link list and analytics<br/>[ShortenItem.jsx]"]
  node_query_hooks["Dashboard queries<br/>[useQuery.js]"]
  node_api_client["REST client<br/>[api.js]"]
end

subgraph group_backend["Spring Boot API"]
  node_auth_api["Authentication API"]
  node_url_api["URL management API"]
  node_redirect_api["Short-link redirect"]
  node_url_service["URL business logic"]
  node_user_service["User services<br/>[UserService.java]"]
end

subgraph group_domain["Link and analytics data"]
  node_url_mapping["URL mappings<br/>[UrlMapping.java]"]
  node_click_events["Click events<br/>[ClickEvent.java]"]
  node_database[("MySQL database")]
end

subgraph group_security["Authentication"]
  node_token_state["JWT token state<br/>[ContextApi.jsx]"]
  node_private_route["Route guard<br/>[PrivateRoute.jsx]"]
  node_jwt_security["JWT security"]
end

node_visitor(("Browser user"))

node_visitor -->|"uses"| node_app
node_app -->|"renders"| node_routing
node_routing -->|"routes to"| node_landing
node_routing -->|"routes to"| node_auth_ui
node_routing -->|"routes to"| node_dashboard
node_routing -->|"guards"| node_private_route
node_private_route -->|"checks"| node_token_state
node_auth_ui -->|"calls"| node_api_client
node_auth_ui -->|"updates token"| node_token_state
node_api_client -.->|"REST requests"| node_auth_api
node_auth_api -.->|"issues JWT"| node_jwt_security
node_dashboard -->|"loads data"| node_query_hooks
node_query_hooks -->|"requests"| node_api_client
node_dashboard -.->|"opens form"| node_create_ui
node_create_ui -->|"submits link"| node_api_client
node_dashboard -->|"renders"| node_link_list
node_link_list -->|"fetches analytics"| node_api_client
node_api_client -.->|"REST requests"| node_url_api
node_url_api -.->|"delegates"| node_url_service
node_redirect_api -.->|"resolves code"| node_url_service
node_url_service -.->|"manages"| node_url_mapping
node_url_service -.->|"records clicks"| node_click_events
node_url_mapping -.->|"persists via JPA"| node_database
node_click_events -.->|"persists via JPA"| node_database
node_redirect_api -.->|"redirects"| node_visitor
node_url_api -.->|"user-specific access"| node_user_service
node_jwt_security -.->|"secures endpoints"| node_url_api

click node_app "https://github.com/sonal-wadkar/url-shortener/blob/main/url-shortner-frontend/src/main.jsx"
click node_routing "https://github.com/sonal-wadkar/url-shortener/blob/main/url-shortner-frontend/src/AppRouter.jsx"
click node_landing "https://github.com/sonal-wadkar/url-shortener/blob/main/url-shortner-frontend/src/components/LandingPage.jsx"
click node_auth_ui "https://github.com/sonal-wadkar/url-shortener/blob/main/url-shortner-frontend/src/components/LoginPage.jsx"
click node_dashboard "https://github.com/sonal-wadkar/url-shortener/blob/main/url-shortner-frontend/src/components/Dashboard/DashboardLayout.jsx"
click node_create_ui "https://github.com/sonal-wadkar/url-shortener/blob/main/url-shortner-frontend/src/components/Dashboard/CreateNewShorten.jsx"
click node_link_list "https://github.com/sonal-wadkar/url-shortener/blob/main/url-shortner-frontend/src/components/Dashboard/ShortenItem.jsx"
click node_query_hooks "https://github.com/sonal-wadkar/url-shortener/blob/main/url-shortner-frontend/src/hooks/useQuery.js"
click node_api_client "https://github.com/sonal-wadkar/url-shortener/blob/main/url-shortner-frontend/src/api/api.js"
click node_token_state "https://github.com/sonal-wadkar/url-shortener/blob/main/url-shortner-frontend/src/contextApi/ContextApi.jsx"
click node_private_route "https://github.com/sonal-wadkar/url-shortener/blob/main/url-shortner-frontend/src/PrivateRoute.jsx"
click node_auth_api "https://github.com/sonal-wadkar/url-shortener/blob/main/short/src/main/java/com/example/demo/controller/AuthController.java"
click node_url_api "https://github.com/sonal-wadkar/url-shortener/blob/main/short/src/main/java/com/example/demo/controller/UrlMappingController.java"
click node_redirect_api "https://github.com/sonal-wadkar/url-shortener/blob/main/short/src/main/java/com/example/demo/controller/RedirectController.java"
click node_url_service "https://github.com/sonal-wadkar/url-shortener/blob/main/short/src/main/java/com/example/demo/service/UrlMappingService.java"
click node_user_service "https://github.com/sonal-wadkar/url-shortener/blob/main/short/src/main/java/com/example/demo/service/UserService.java"
click node_jwt_security "https://github.com/sonal-wadkar/url-shortener/blob/main/short/src/main/java/com/example/demo/security/jwt/JwtAuthenticationFilter.java"
click node_url_mapping "https://github.com/sonal-wadkar/url-shortener/blob/main/short/src/main/java/com/example/demo/models/UrlMapping.java"
click node_click_events "https://github.com/sonal-wadkar/url-shortener/blob/main/short/src/main/java/com/example/demo/models/ClickEvent.java"

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_routing,node_landing,node_auth_ui,node_dashboard,node_create_ui,node_link_list,node_query_hooks,node_api_client,node_visitor toneBlue
class node_auth_api,node_url_api,node_redirect_api,node_url_service,node_user_service toneAmber
class node_url_mapping,node_click_events,node_database toneMint
class node_token_state,node_private_route,node_jwt_security toneRose
```

## Components

### React frontend

- [App bootstrap](https://github.com/sonal-wadkar/url-shortener/blob/main/url-shortner-frontend/src/main.jsx): `url-shortner-frontend/src/main.jsx`
- [Page routing](https://github.com/sonal-wadkar/url-shortener/blob/main/url-shortner-frontend/src/AppRouter.jsx): `url-shortner-frontend/src/AppRouter.jsx`
- [Landing page](https://github.com/sonal-wadkar/url-shortener/blob/main/url-shortner-frontend/src/components/LandingPage.jsx): `url-shortner-frontend/src/components/LandingPage.jsx`
- [Login and register](https://github.com/sonal-wadkar/url-shortener/blob/main/url-shortner-frontend/src/components/LoginPage.jsx): `url-shortner-frontend/src/components/LoginPage.jsx`
- [Link dashboard](https://github.com/sonal-wadkar/url-shortener/blob/main/url-shortner-frontend/src/components/Dashboard/DashboardLayout.jsx): `url-shortner-frontend/src/components/Dashboard/DashboardLayout.jsx`
- [Create short link](https://github.com/sonal-wadkar/url-shortener/blob/main/url-shortner-frontend/src/components/Dashboard/CreateNewShorten.jsx): `url-shortner-frontend/src/components/Dashboard/CreateNewShorten.jsx`
- [Link list and analytics](https://github.com/sonal-wadkar/url-shortener/blob/main/url-shortner-frontend/src/components/Dashboard/ShortenItem.jsx): `url-shortner-frontend/src/components/Dashboard/ShortenItem.jsx`
- [Dashboard queries](https://github.com/sonal-wadkar/url-shortener/blob/main/url-shortner-frontend/src/hooks/useQuery.js): `url-shortner-frontend/src/hooks/useQuery.js`
- [REST client](https://github.com/sonal-wadkar/url-shortener/blob/main/url-shortner-frontend/src/api/api.js): `url-shortner-frontend/src/api/api.js`

### Spring Boot API

- [Authentication API](https://github.com/sonal-wadkar/url-shortener/blob/main/short/src/main/java/com/example/demo/controller/AuthController.java): `short/src/main/java/com/example/demo/controller/AuthController.java`
- [URL management API](https://github.com/sonal-wadkar/url-shortener/blob/main/short/src/main/java/com/example/demo/controller/UrlMappingController.java): `short/src/main/java/com/example/demo/controller/UrlMappingController.java`
- [Short-link redirect](https://github.com/sonal-wadkar/url-shortener/blob/main/short/src/main/java/com/example/demo/controller/RedirectController.java): `short/src/main/java/com/example/demo/controller/RedirectController.java`
- [URL business logic](https://github.com/sonal-wadkar/url-shortener/blob/main/short/src/main/java/com/example/demo/service/UrlMappingService.java): `short/src/main/java/com/example/demo/service/UrlMappingService.java`
- [User services](https://github.com/sonal-wadkar/url-shortener/blob/main/short/src/main/java/com/example/demo/service/UserService.java): `short/src/main/java/com/example/demo/service/UserService.java`

### Link and analytics data

- [URL mappings](https://github.com/sonal-wadkar/url-shortener/blob/main/short/src/main/java/com/example/demo/models/UrlMapping.java): `short/src/main/java/com/example/demo/models/UrlMapping.java`
- [Click events](https://github.com/sonal-wadkar/url-shortener/blob/main/short/src/main/java/com/example/demo/models/ClickEvent.java): `short/src/main/java/com/example/demo/models/ClickEvent.java`
- **MySQL database**

### Authentication

- [JWT token state](https://github.com/sonal-wadkar/url-shortener/blob/main/url-shortner-frontend/src/contextApi/ContextApi.jsx): `url-shortner-frontend/src/contextApi/ContextApi.jsx`
- [Route guard](https://github.com/sonal-wadkar/url-shortener/blob/main/url-shortner-frontend/src/PrivateRoute.jsx): `url-shortner-frontend/src/PrivateRoute.jsx`
- [JWT security](https://github.com/sonal-wadkar/url-shortener/blob/main/short/src/main/java/com/example/demo/security/jwt/JwtAuthenticationFilter.java): `short/src/main/java/com/example/demo/security/jwt/JwtAuthenticationFilter.java`

### Other components

- **Browser user**

## Connections

- Browser user → App bootstrap: uses (evidence: `README.md`)
- App bootstrap → Page routing: renders (evidence: `url-shortner-frontend/src/main.jsx`)
- Page routing → Landing page: routes to (evidence: `url-shortner-frontend/src/AppRouter.jsx`)
- Page routing → Login and register: routes to (evidence: `url-shortner-frontend/src/AppRouter.jsx`)
- Page routing → Link dashboard: routes to (evidence: `url-shortner-frontend/src/AppRouter.jsx`)
- Page routing → Route guard: guards (evidence: `url-shortner-frontend/src/AppRouter.jsx`)
- Route guard → JWT token state: checks (evidence: `url-shortner-frontend/src/PrivateRoute.jsx`)
- Login and register → REST client: calls (evidence: `url-shortner-frontend/src/components/LoginPage.jsx`)
- Login and register → JWT token state: updates token (evidence: `url-shortner-frontend/src/components/LoginPage.jsx`)
- REST client → Authentication API: REST requests (evidence: `README.md`)
- Authentication API → JWT security: issues JWT (evidence: `README.md`)
- Link dashboard → Dashboard queries: loads data (evidence: `url-shortner-frontend/src/components/Dashboard/DashboardLayout.jsx`)
- Dashboard queries → REST client: requests (evidence: `url-shortner-frontend/src/hooks/useQuery.js`)
- Link dashboard → Create short link: opens form (evidence: `url-shortner-frontend/src/components/Dashboard/DashboardLayout.jsx`)
- Create short link → REST client: submits link (evidence: `url-shortner-frontend/src/components/Dashboard/CreateNewShorten.jsx`)
- Link dashboard → Link list and analytics: renders (evidence: `url-shortner-frontend/src/components/Dashboard/DashboardLayout.jsx`)
- Link list and analytics → REST client: fetches analytics (evidence: `url-shortner-frontend/src/components/Dashboard/ShortenItem.jsx`)
- REST client → URL management API: REST requests (evidence: `README.md`)
- URL management API → URL business logic: delegates (evidence: `README.md`)
- Short-link redirect → URL business logic: resolves code (evidence: `README.md`)
- URL business logic → URL mappings: manages (evidence: `README.md`)
- URL business logic → Click events: records clicks (evidence: `README.md`)
- URL mappings → MySQL database: persists via JPA (evidence: `README.md`)
- Click events → MySQL database: persists via JPA (evidence: `README.md`)
- Short-link redirect → Browser user: redirects (evidence: `README.md`)
- URL management API → User services: user-specific access (evidence: `README.md`)
- JWT security → URL management API: secures endpoints (evidence: `README.md`)
