A minimal Spring Boot service to shorten long URLs and redirect them efficiently using PostgreSQL and Redis.
- Java 17, Spring Boot (no Spring Data)
- PostgreSQL for persistence
- Redis (Jedis) for caching and maintaining key pool
- HikariCP for DB connection pooling
- Converts long URLs into short keys
- 302 redirects for short URLs
- Redis caching for performance
- Retry logic for key collisions
- Clean separation: Controller → Service → Repository
-
Configure
application.propertieswith DB and Redis. -
Start PostgreSQL and Redis.
-
Run the app:
mvn spring-boot:run
-
Use
POST /api/shortenandGET /{shortKey}to shorten and resolve URLs.
- Add logging
- Add authentication to APIs
- Docker support