How raftywate/url-shortener-with-consistent-hashing works
ShardLink is a distributed URL-shortening demo with a React dashboard and Spring backend. Users submit a URL, the backend normalizes it, generates a Base62 code, routes it through a virtual-node consistent-hash ring, and stores the mapping; redirect requests check Redis before querying the selected logical shard. The dashboard also polls analytics and visualizes cache, redirect, shard, and ring state. Edges reflect the sampled calls and README-described flows; some dashboard widgets and analytics endpoint wiring are represented at subsystem level because their implementation was not excerpted.
Main entry points: Dashboard.jsx Dashboard · UrlService.java URL Service · UrlController.java URL Controller · ShortenCard.jsx Shorten Form
Components 21
Dashboard UI
- Dashboard
frontend/src/pages/Dashboard.jsx - Shorten Form
frontend/src/components/ShortenCard.jsx - Analytics Widgets
frontend/src/components/dashboard/AnalyticsCards.jsx - Stats Cards
frontend/src/components/dashboard/StatsCards.jsx - Hash Ring View
frontend/src/components/dashboard/HashRing.jsx - Node Controls
frontend/src/components/dashboard/NodeControls.jsx - Recent URLs
frontend/src/components/dashboard/UrlTable.jsx - Redirect Chart
frontend/src/components/dashboard/RedirectChart.jsx - URL API Client
frontend/src/services/urlService.js - Analytics Client
frontend/src/services/analyticsService.js
HTTP API
- URL Controller
backend/src/main/java/org/raftywate/urlshortenerwithconsistenthashing/controller/UrlController.java - Analytics Controller
backend/src/main/java/org/raftywate/urlshortenerwithconsistenthashing/controller/AnalyticsController.java - Rate Limiter
backend/src/main/java/org/raftywate/urlshortenerwithconsistenthashing/ratelimit/RateLimitService.java
Shortening and Routing
- URL Service
backend/src/main/java/org/raftywate/urlshortenerwithconsistenthashing/service/UrlService.java - Hash Ring Router
backend/src/main/java/org/raftywate/urlshortenerwithconsistenthashing/hashing/ConsistentHashingService.java - URL Request
backend/src/main/java/org/raftywate/urlshortenerwithconsistenthashing/dto/UrlRequest.java
Storage and Metrics
- Analytics Service
backend/src/main/java/org/raftywate/urlshortenerwithconsistenthashing/analytics/AnalyticsService.java - Global Lookup
backend/src/main/java/org/raftywate/urlshortenerwithconsistenthashing/repository/UrlLookupRepository.java - PostgreSQL
- Redis
Other components
- User
Connections 24
- User → Dashboard: uses
readme.md - Dashboard → Shorten Form: renders
frontend/src/pages/Dashboard.jsx - Dashboard → Analytics Widgets: renders
frontend/src/pages/Dashboard.jsx - Dashboard → Stats Cards: renders
frontend/src/pages/Dashboard.jsx - Dashboard → Hash Ring View: renders
frontend/src/pages/Dashboard.jsx - Dashboard → Node Controls: renders
frontend/src/pages/Dashboard.jsx - Dashboard → Recent URLs: renders
frontend/src/pages/Dashboard.jsx - Dashboard → Redirect Chart: renders
frontend/src/pages/Dashboard.jsx - Shorten Form → URL API Client: calls
frontend/src/components/ShortenCard.jsx - URL API Client → URL Controller: posts URL
frontend/src/services/urlService.js - Dashboard → Analytics Client: polls
frontend/src/pages/Dashboard.jsx - Analytics Client → Analytics Controller: requests metrics
frontend/src/services/analyticsService.js - URL Controller → URL Request: accepts
backend/src/main/java/org/raftywate/urlshortenerwithconsistenthashing/controller/UrlController.java - URL Controller → Rate Limiter: checks limit
backend/src/main/java/org/raftywate/urlshortenerwithconsistenthashing/controller/UrlController.java - URL Controller → URL Service: delegates
backend/src/main/java/org/raftywate/urlshortenerwithconsistenthashing/controller/UrlController.java - User → URL Controller: redirects
readme.md - Analytics Controller → Analytics Service: queries
backend/src/main/java/org/raftywate/urlshortenerwithconsistenthashing/controller/AnalyticsController.java - URL Service → Hash Ring Router: routes code
backend/src/main/java/org/raftywate/urlshortenerwithconsistenthashing/service/UrlService.java - URL Service → Global Lookup: reads and saves
backend/src/main/java/org/raftywate/urlshortenerwithconsistenthashing/service/UrlService.java - URL Service → PostgreSQL: queries shard
backend/src/main/java/org/raftywate/urlshortenerwithconsistenthashing/service/UrlService.java - URL Service → Redis: checks and caches
backend/src/main/java/org/raftywate/urlshortenerwithconsistenthashing/service/UrlService.java - URL Service → Analytics Service: updates metrics
backend/src/main/java/org/raftywate/urlshortenerwithconsistenthashing/service/UrlService.java - Rate Limiter → Redis: counts requests
backend/src/main/java/org/raftywate/urlshortenerwithconsistenthashing/ratelimit/RateLimitService.java - Global Lookup → PostgreSQL: persists lookup