https://github.com/05sanjaykumar/url-shortern
A scalable, Dockerized URL Shortener built with Node.js and Redis โ designed to explore backend architecture, caching, and deployment concepts.
https://github.com/05sanjaykumar/url-shortern
devops docker express express-js nginx node redis url-shortener
Last synced: 2 months ago
JSON representation
A scalable, Dockerized URL Shortener built with Node.js and Redis โ designed to explore backend architecture, caching, and deployment concepts.
- Host: GitHub
- URL: https://github.com/05sanjaykumar/url-shortern
- Owner: 05sanjaykumar
- Created: 2025-05-05T17:35:32.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-05-13T19:55:52.000Z (about 1 year ago)
- Last Synced: 2025-05-13T20:55:06.004Z (about 1 year ago)
- Topics: devops, docker, express, express-js, nginx, node, redis, url-shortener
- Language: JavaScript
- Homepage:
- Size: 113 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# ๐ URL Shortener
A full-stack, production-grade URL shortening service built with **Node.js**, **Express**, **Redis**, and **Docker** โ complete with rate limiting, RESTful API, unit tests, and deployment on Render.
---
## ๐ Live Demo
> ๐ข Deployed on [Render](https://url-shortern-9qxj.onrender.com/)
> Frontend: Static `HTML + JS`
> Backend: Node.js + Redis
> Dockerized with `Dockerfile` and `nginx` (for local use)
---
## ๐งฐ Tech Stack
- **Frontend**: HTML, JavaScript (Vanilla)
- **Backend**: Node.js + Express
- **Database**: Redis (for storing shortened URLs)
- **Testing**: Jest
- **Rate Limiting**: Custom Express middleware
- **DevOps**:
- Docker & docker-compose (for local setup)
- Render (for cloud deployment)
- NGINX (proxy for containerized routing)
---
## ๐ Project Structure
```
โโโ public/ # Static frontend
โโโ src/
โ โโโ controllers/ # Shorten & redirect logic
โ โโโ routes/ # API endpoints
โ โโโ services/ # Redis + URL generation
โ โโโ middleware/ # Rate limiter
โโโ test/ # Unit tests (with mocks)
โโโ Dockerfile # Container setup
โโโ docker-compose.yml # Dev orchestration
โโโ server.js # Entry point
โโโ README.md # Project info
````
---
## โ
Features
- ๐ Shortens long URLs to 6-character codes
- ๐ Redirects to original URL from code
- ๐ง Stores data in **Redis**
- ๐ก๏ธ Built-in **rate limiter** middleware (basic DDoS protection)
- ๐งช Unit tested with mocks for Redis
- ๐ณ Local Docker support
- ๐ Deployed on **Render**
---
## ๐ Running Locally
### Option 1: Docker (Recommended for full stack)
```bash
docker-compose up
````
### Option 2: Manual
```bash
npm install
redis-server
npm start
```
Then visit: [http://localhost:3000](http://localhost:3000)
---
## ๐งช Run Tests
```bash
npm test
```
Includes mocks for Redis to ensure unit isolation.
---
## ๐ Deployment (Render)
The backend and frontend are deployed using **Render.com**:
* **Backend**: Connected to Redis instance
* **Frontend**: Served via static files or nginx
* **Base URL** is set dynamically in production
---
## ๐ Learnings
* ๐ฆ **Modular Express structure** with `controllers`, `routes`, and `services`
* ๐งช Wrote **unit tests** with Redis mocks
* ๐ณ Learned how to containerize full-stack apps with Docker
* ๐ Deployed using **Render** and explored cloud hosting
* ๐ก๏ธ Implemented basic **rate limiting**
* ๐ฑ Explored logging, monitoring, and optional CI/CD pipelines
---
## ๐ Author
**Sanjay Kumar** โ *Lifelong learner, Polyglot dev, and builder of things.*