π A Quick Backstory
Hey everyone, Iβm Sanjay β a self-taught dev who loves building from scratch and learning by doing. I recently went deep into DevOps and containerization, and this URL shortener project was my way of exploring Redis, Docker, and cloud deployment β all in one shot.
This project was never about just shortening URLs. For me, it was about:
Learning how to structure a scalable backend π§±
Working with Redis as a primary data store π§
Deploying real-world projects with Docker + Render π
Itβs simple on the surface, but I learned a ton building this. Here's the breakdown π
π URL Shortener β Node.js, Redis & Docker
A full-stack, production-grade URL shortening service built with Node.js, Express, Redis, and Docker β complete with a RESTful API, unit tests, containerization, and cloud deployment on Render.
π Live Demo
π’ Deployed on Render
Frontend: StaticHTML + JS
Backend: Node.js + Redis
Dockerized withDockerfile
andnginx
(for local use)
π§° Tech Stack
- Frontend: HTML, JavaScript (Vanilla)
- Backend: Node.js + Express
- Database: Redis (for storing shortened URLs)
- Testing: Jest
-
DevOps: Docker, Render, NGINX
(Experimental): Rate Limiting, GitHub Actions (CI)- Docker & docker-compose (for local development)
- Render (for cloud deployment)
- NGINX (proxy for local routing)
π Project Structure
05sanjaykumar-url-shortern/
βββ public/ # Static frontend (HTML + JS)
βββ src/
β βββ app.js # Main app setup
β βββ controllers/ # Shorten & redirect logic
β βββ middleware/ # Rate limiting (dummy)
β βββ routes/ # API endpoints
β βββ services/ # Redis logic + URL generation
βββ test/ # Unit tests + Redis mocks
βββ nginx/ # NGINX config (for local Docker)
βββ .github/workflows/ # CI pipeline (placeholder)
βββ Dockerfile + docker-compose.yml
βββ server.js
βββ .env-example
β Features
- π Shortens long URLs to unique 6-character codes
- π Redirects to original URLs
- π§ Stores URL mappings in Redis
- π§ͺ Unit-tested with mocked Redis interactions
- π οΈ Includes a basic demo rate limiter (not production-grade)
- π³ Local Docker support
- π Fully deployed backend + frontend on Render
βοΈ Running Locally
Option 1: Docker (recommended)
docker-compose up
Then open: localhost
(OR)
Option 2: Manual
git checkout render-deploy
npm install
redis-server
npm start
Then open: http://localhost:3000
π§ͺ Run Tests
npm test
Tests include mocked Redis functionality for isolated unit testing.
π¦ Deployment (Render)
The app is deployed using Render:
- Backend connects to Redis
- Frontend served statically (via nginx or Render)
- Base URL is dynamically handled in production
π Learnings
- π¦ Designed modular Express backend (routes, controllers, services)
- π§ͺ Wrote unit tests with Redis mocks
- π³ Containerized with Docker + Docker Compose
- π Deployed on Render (frontend + backend)
- π οΈ Explored how rate limiting works in Express (demo-only)
- π± Gained deeper insight into app structure, devops, and deployment
β οΈ Note: The rate limiter is a basic, demonstration-only middleware. For real-world production use, consider packages like
express-rate-limit
or Redis-backed implementations.
π Author
Sanjay Kumar β Lifelong learner, and builder of things.
GitHub Repo
Top comments (0)