A production-ready, distributed URL shortener platform built using Spring Boot Microservices, leveraging OAuth2, Kafka, Redis, MongoDB TTL, and JWT Authentication. This platform not only shortens links, but also supports ad-based interstitial redirection, rate limiting, and high scalability out of the box.
- ✅ Unique short URL generation
- 🔐 OAuth2 & JWT-based Authentication
- ⚡ Redis caching for high performance
- 🧪 Token-secured API Gateway with Rate Limiting
- 📩 Kafka-based Event-Driven architecture
- ⏳ MongoDB TTL auto-expiry for short URLs
- 🧠 Bcrypt password encryption with MySQL User Service
- 🎯 10-second Interstitial Ad Page before redirect
- 📈 Modular, Multi-Repo, Dockerized Microservices
- User Login via
/auth/login→ receives JWT - Create Short URL via
/shorten→ saves in MongoDB, sends Kafka message - Caching Service listens to Kafka → caches URL in Redis with TTL
- Redirect Request checks Redis → fallback to MongoDB → shows Ad page → redirects to original URL
| Layer | Technology |
|---|---|
| Language | Java 17 |
| Framework | Spring Boot 3.2, Spring WebFlux, Spring Security |
| Messaging | Apache Kafka |
| Database | MongoDB (TTL), MySQL |
| Caching | Redis |
| Auth | OAuth2, JWT, Bcrypt |
| Gateway | Spring Cloud Gateway |
| Monitoring | Spring Actuator |
| Frontend | Thymeleaf, JavaScript |
| DevOps | Docker, Docker Compose |
| Others | Lombok, SLF4J, Maven, Rate Limiting |
git clone https://github.com/your-username/url-shortener.git
cd url-shortener
docker-compose up --buildcurl --location 'http://localhost:8080/auth/login' --header 'Content-Type: application/json' --data '{
"username": "testuser",
"password": "123"
}'curl --location 'http://localhost:8080/shorten' --header 'Content-Type: application/json' --header 'Authorization: Bearer <your_jwt_token>' --data '{
"longUrl": "https://google.com"
}'http://localhost:8080/r/abc123 → redirects to ad page for 10s → redirects to original link
| Storage | Usage |
|---|---|
| MongoDB | Stores short URL mappings (TTL Index for expiry) |
| Redis | Caches hot URLs for fast resolution |
| MySQL | Stores user credentials securely (hashed with Bcrypt) |
- Users are shown an ad/interstitial page for 10 seconds after accessing the short link
- Ads can be static banners, dynamic content, or affiliate promotions
- This feature is key to potential monetization strategy
./mvnw testAll critical modules are covered with unit tests, including edge cases and failure scenarios.
- OAuth2 + JWT for authenticated APIs
- Rate Limiting at API Gateway (per IP / token)
- Sanitization of long URLs
- Password encryption using Bcrypt
- Secure Kafka communication (if TLS configured)
| Topic | Description |
|---|---|
create-url |
Emitted when a short URL is created |
url-visited |
[Future] For tracking analytics |
- Exposed via
/actuatorendpoints - Health, metrics, and readiness probes
- Can be integrated with Prometheus/Grafana
| Endpoint | Method | Auth | Description |
|---|---|---|---|
/auth/login |
POST | ❌ | Login and get JWT |
/shorten |
POST | ✅ | Create short URL |
/r/{shortId} |
GET | ❌ | Redirect to original URL |
We follow Semantic Versioning:
Current Version: 1.2.0
Feel free to reach out:
- Email: parsa10007@gmail.com
- GitHub Issues for bugs & feature requests
Made with ☕, Spring, and ❤️ by [Parsa Eftekharmanesh]



