Skip to content

sandeshpawar10/URL-Shortner-Project

Repository files navigation

🔗 URL Shortener Backend

A scalable backend service for generating and managing short URLs, built using Node.js, Express, PostgreSQL, and Drizzle ORM.


🚀 Features

  • User Authentication (JWT-based)
  • Password hashing with salt (crypto)
  • Create short URLs using nanoid
  • Redirect short URLs to original links
  • PostgreSQL relational database
  • Drizzle ORM integration
  • Dockerized setup

🛠️ Tech Stack

  • Node.js
  • Express.js
  • PostgreSQL
  • Drizzle ORM
  • JWT Authentication
  • Zod (validation)
  • Docker

📁 Project Structure

.
├── controllers/
├── models/
├── database/
├── utils/
├── docker-compose.yml
├── Dockerfile
├── server.js
└── README.md

⚙️ Setup Instructions

1. Clone Repository

git clone https://github.com/your-username/url-shortener-backend.git
cd url-shortener-backend

2. Install Dependencies

npm install

3. Setup Environment Variables

Create a .env file:

DATABASE_URL=postgresql://user:password@localhost:5432/dbname
JWT_SECRET=your_secret_key
PORT=3000

4. Run Database (Docker)

docker compose up -d

5. Run Server

npm start

🔑 API Endpoints

🔐 Auth

  • POST /user/signin → Register user
  • POST /user/login → Login user
  • POST /user/codes → Get all codes of user of all urls

🔗 URL

  • POST /shorten → Create short URL (Auth required)
  • GET /r/:shortCode → Redirect to original URL

🧠 Database Design

userTable

  • id (UUID)
  • email
  • password
  • salt

urlTable

  • id (UUID)
  • user_id (FK)
  • short_code
  • target_url

🐳 Docker Support

Run full backend with PostgreSQL:

docker compose up --build

👨‍💻 Author

Sandesh Pawar

About

Scalable URL shortener backend built with Node.js, Express, PostgreSQL, and Drizzle ORM, featuring JWT authentication and Docker support.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors