A high-performance, full-stack URL shortener and traffic intelligence platform built with Spring Boot, React, and Go WebAssembly on Cloudflare Edge.
Shrtn is an enterprise-grade URL shortening and traffic intelligence engine. It combines a low-latency Go (Golang) WebAssembly Edge Redirect Engine running across Cloudflare's global network with a Spring Boot 4 REST API and a React 19 Dashboard.
Designed for high availability, short links resolve at Cloudflare Edge Isolates in under 20 milliseconds by querying Upstash Redis REST endpoints directly, with non-blocking asynchronous click analytics logging to PostgreSQL and automatic fallbacks.
The repository is structured as a monorepo containing three primary services:
| Component | Path | Description | Deployment |
|---|---|---|---|
| Client | /client |
React 19, TypeScript, Vite, Tailwind CSS v4, shadcn UI components, Recharts analytics, Framer Motion transitions | Vercel (app.shrtn.fun) |
| Server | /server |
Java 25, Spring Boot 4 REST API, Spring Data JPA, JWT Authentication, Resend API integration, Gradle frontend sync | Render (shrtn.fun) |
| Worker | /cloudflare-worker |
Go 1.22 compiled to WebAssembly (main.wasm), sub-20ms edge redirects, Upstash REST client, Edge static asset caching |
Cloudflare Workers |
- Sub-20ms Latency: Executes at Cloudflare's nearest edge data center (300+ locations) via WebAssembly.
- Upstash Redis Querying: Direct HTTP GET requests to Upstash Redis REST endpoints (
/get/url:{shortCode}). - Static Route Fast Paths: Instant 302 redirects for static authentication routes (
/signin,/signup,/dashboard).
- Growth Velocity & Trend Badges: Live percentage growth (+X% / -X%) comparing current traffic against prior 7-day windows.
- Peak Engagement Time Window: Evaluates traffic heatmaps to calculate the day and hour of peak visitor activity (e.g.
Thursdays at 4:00 PM). - Referrer Categorization: Groups incoming traffic into Social (X/Twitter, LinkedIn, Reddit, Instagram, Facebook, YouTube), Search (Google, Bing, DuckDuckGo), Direct, and Email.
- UTM Campaign Tracking: Tracks
utm_source,utm_medium, andutm_campaignmetrics. - Live Click Log: Real-time click stream table featuring Dicebear Notionists avatars, country flag icons, browser/OS badges, and humanized relative timestamps.
- 1-Click Data Export: Download full click analytics to CSV or JSON formats.
- All
/assets/*static JS/CSS bundles are cached directly at Cloudflare Edge (caches.default) withmax-age=31536000, immutable. - Eliminates Render free-tier container wake-up timeouts (
502 Bad Gateway).
- Visitor receives sub-20ms 302 redirects directly from Cloudflare Edge.
- Cloudflare asynchronously dispatches click tracking events (
POST /api/v1/clicks/track) with real visitor IP (CF-Connecting-IP) and Cloudflare GeoIP Country (CF-IPCountry). - Updates PostgreSQL
clickstable and invalidates Redis analytics cache in real-time.
- Real-time User-Agent parsing at the redirect boundary.
- Directs iOS visitors (
iPhone,iPad,iPod) to dedicated App Store URLs (iosUrl). - Directs Android visitors to Google Play Store URLs (
androidUrl). - Fallback redirection to the primary destination URL for desktop clients.
- Configurable
maxClickslimits per URL. - Link automatically deactivates and evicts from cache upon reaching the threshold.
- Live click progress indicators (
X / N) displayed in the client dashboard.
- Dual-mode authentication via Google OAuth 2.0, GitHub OAuth, and traditional credentials.
- Dynamic OAuth
redirect_uriresolution supportinglocalhost:8080,localhost:5173, andapp.shrtn.fun. - Transactional OTP verification delivered via Resend API (
noreply@shrtn.fun). - Optional password lock protection on individual short links.
[ Visitor Request ]
│
▼
[ Cloudflare Edge (Go Wasm) ] ──(REST GET)──► [ Upstash Redis (24h TTL) ]
│ │
│ Sub-20ms 302 Redirect │ Cache Hit
├─────────────────────────────────────────────► [ Visitor Browser ]
│
│ (Async ctx.waitUntil)
▼
[ POST /api/v1/clicks/track ] ──────────────► [ Spring Boot API (Render) ]
│
▼
[ PostgreSQL (Supabase) ]
users: Account identity, hashed passwords, verification flags.urls: Shortcode mappings, destination URLs, smart device routes, expiration timestamps, auto-destruct limits (max_clicks), password hashes.clicks: Timestamped visit logs, IP hashes, User-Agent parameters, resolved country/region/city metadata,utm_source,utm_medium,utm_campaign.otps: One-time pins for registration and password recovery flows.
- Java 25 JDK
- Go 1.22+
- Bun 1.0+ or Node.js 20+
cd server
cp .env.example .env
./gradlew bootRunBackend runs on http://localhost:8080. Gradle automatically runs copyFrontend to sync client/dist to server/src/main/resources/static.
cd client
bun install
bun run devFrontend runs on http://localhost:5173 with instant Hot Module Replacement (HMR).
cd cloudflare-worker
bun run devLocal Edge Worker runs on http://localhost:8787.
cd cloudflare-worker
bun run deploycd client
bun run buildVite compiles static assets and automatically syncs dist/* to server/src/main/resources/static/.
This project is licensed under the MIT License. See LICENSE for details.