A scalable and production-ready URL shortener built using modern web technologies. This project demonstrates backend architecture, caching, containerization, and full-stack integration.
- 🔗 Shorten long URLs into compact links
- ⚡ Fast redirection using caching (Redis)
- 🗄️ Persistent storage with MongoDB
- 📊 Unique short code generation
- 🐳 Fully containerized using Docker & Docker Compose
- React
- Tailwind CSS
- Nginx (for serving production build)
- Node.js
- Express.js
- Mongoose
- MongoDB (persistent storage)
- Redis (caching layer)
- Docker
- Docker Compose
User → Frontend (React + Nginx)
↓
Backend (Node.js)
↙ ↘
Redis (Cache) MongoDB (DB)
- User submits a long URL
- Backend generates a short code
- Data stored in MongoDB
- Frequently accessed URLs cached in Redis
- Redirect happens via backend
- Docker installed
- Docker Compose installed
docker compose up --build- Backend API: https://hub.docker.com/repository/docker/manankapkar/urlshortner-backend
- Frontend: https://hub.docker.com/repository/docker/manankapkar/urlshortner-frontend
| Service | Description | Port |
|---|---|---|
| frontend | React app via Nginx | 3000 |
| backend | Node.js API | 5000 |
| mongodb | Database | 27017 |
| redis | Cache | 6379 |
Create a .env file in backend:
PORT=5000
MONGO_URI=mongodb://mongodb:27017/urlshortener
REDIS_HOST=redis
REDIS_PORT=6379
BASE_URL=http://localhost:5000- MongoDB uses Docker volume for persistent storage
- Data remains intact even after container restarts
- Implemented Redis caching to reduce MongoDB queries
- Improved response time for repeated URL access
- Designing scalable backend systems
- Using Redis for performance optimization
- Dockerizing multi-service applications
- Managing persistent volumes
Feel free to fork this repo and improve it!
