Production-grade URL shortener built with Java and Spring Boot.
Shortify lets users create short URLs, manage links, and track click analytics, with authentication via JWT, Redis-backed caching, PostgreSQL persistence, and Docker-based local infrastructure.
This repository is currently in the bootstrap stage:
- Spring Boot application scaffold is in place.
- Docker Compose services for PostgreSQL and Redis are defined.
- Core modules (auth, URL APIs, analytics, admin) are planned and documented below.
- URL shortening with customizable alias support
- JWT-based authentication and authorization
- Link management (create, update, deactivate, delete)
- Click analytics (total clicks, unique visitors, referrers, user agents, timestamps)
- Redis caching for hot link resolution and reduced DB reads
- PostgreSQL as primary persistent store
- Dockerized local development stack
- Java 17
- Spring Boot
- Spring Security + JWT
- Spring Data Redis
- PostgreSQL
- Docker / Docker Compose
- Maven
- API Layer: REST endpoints for auth, URL operations, and analytics
- Security Layer: JWT filter chain and role-based access control
- Service Layer: business logic for shortening, resolving, tracking, and management
- Cache Layer (Redis): fast alias lookup and frequently accessed metadata
- Database Layer (PostgreSQL): durable storage for users, URLs, and analytics records
- JDK 17+
- Maven 3.9+
- Docker + Docker Compose
From project root:
docker compose up -d
./mvnw spring-boot:run- Start infrastructure services:
docker compose up -d postgres redis- Run the app:
./mvnw spring-boot:runPOST /api/auth/registerPOST /api/auth/loginPOST /api/auth/refresh
POST /api/urls- create short URLGET /api/urls/{code}- get URL detailsPUT /api/urls/{code}- update URL metadataDELETE /api/urls/{code}- deactivate/delete URLGET /r/{code}- redirect to original URL
GET /api/urls/{code}/analytics- per-link analyticsGET /api/analytics/dashboard- account-level aggregates
- Use strong JWT secrets and rotate regularly
- Keep access and refresh token lifetimes short and explicit
- Store secrets in environment variables or a secret manager
- Enforce HTTPS in production
- Add rate limiting for auth and redirect endpoints
- Cache key: short code -> destination URL + metadata
- Cache hit path: serve redirect without database lookup
- Cache invalidation on URL update/deletion
- Optional TTL for stale data protection
- Track redirect events asynchronously where possible
- Capture timestamp, IP hash, user agent, referrer, and geo metadata
- Store raw events for audit + aggregate counters for fast dashboards
- Implement domain model and persistence layer
- Implement JWT auth and user management
- Build URL create/resolve/manage endpoints
- Add click tracking and analytics aggregation
- Add Redis caching and invalidation logic
- Add API documentation and production hardening
- Add CI/CD and deployment manifests
src/main/java/com/princeworks/shortify- application sourcecompose.yaml- PostgreSQL and Redis servicespom.xml- Maven dependencies and build config
Add your preferred license (MIT/Apache-2.0/etc.) in this repository.