Skip to content

Hitnarola/URL_Shortner

Repository files navigation

๐Ÿ”— URL Shortener – Full-Stack Link Management Platform

[Live Project: https://url-shortner-sooty-delta.vercel.app/]


๐Ÿš€ Overview

URL Shortener is a modern full-stack web app to create, manage, and share short links. It includes secure JWT authentication, custom short codes, a responsive dashboard UI, and an Owner Admin Dashboard to view platform metrics and activity.


๐Ÿ†• New Features

  • ๐Ÿงฉ Enhanced frontend dashboard with user profile card and quick logout
  • ๐ŸŸข Google Sign-In flow using Google Identity Services (/user/google/config, /user/google)
  • ๐Ÿ‘‘ Owner-only admin analytics panel with user counts, link counts, and latest URL activity
  • ๐Ÿชช GET /user/me now returns isOwner to enable role-based UI rendering

โœจ Features

๐Ÿ‘ค User

  • ๐Ÿ” Email/password signup and login
  • ๐ŸŸข Google Sign-In (login/signup via Google account)
  • โœ‚๏ธ Create short links from long URLs
  • ๐Ÿท๏ธ Optional custom short code while creating links
  • ๐Ÿ“‹ View all your created links
  • ๐Ÿ—‘๏ธ Delete your own links
  • ๐Ÿ“ฑ Responsive UI (Bootstrap + TailwindCSS)

๐Ÿ› ๏ธ Owner/Admin

  • ๐Ÿงพ Owner-only dashboard visibility (based on OWNER_EMAIL)
  • ๐Ÿ“Š Platform summary: total users + total links
  • ๐Ÿ‘ฅ User table with per-user link count
  • ๐Ÿ•’ Recent links feed with owner email
  • ๐Ÿ”’ Protected admin API (/admin/overview)

โš™๏ธ Backend

  • ๐Ÿง  REST API with Express
  • ๐Ÿ—„๏ธ PostgreSQL + Drizzle ORM
  • ๐Ÿ”‘ JWT auth middleware (Authorization: Bearer <token>)
  • โœ… Input validation with Zod
  • ↪๏ธ Redirect short code to original target URL

๐Ÿงฐ Tech Stack

  • Backend: Node.js, Express, PostgreSQL, Drizzle ORM, JWT, Zod
  • Frontend: HTML, Bootstrap 5, TailwindCSS, Vanilla JavaScript
  • Auth: Email/Password + Google Identity Services
  • Tools: Docker Compose, PNPM, Drizzle Kit

๐Ÿ Getting Started

1) Clone & Install

git clone <your-repo-url>
cd URL_Shortner
pnpm install

2) Run PostgreSQL (Docker)

docker compose up -d

3) Configure Environment

Create or update .env:

DATABASE_URL=postgres://postgres:admin@localhost:5432/postgres
PORT=8000
JWT_SECRET=your_jwt_secret
OWNER_EMAIL=your_owner_email@example.com
GOOGLE_CLIENT_ID=your_google_client_id.apps.googleusercontent.com

GOOGLE_CLIENT_ID is required only if you want Google Sign-In enabled.

4) Push Database Schema

pnpm db:push

5) Start App

pnpm dev

Open: http://localhost:8000


โ–ฒ Deploy on Vercel

1) Push code to GitHub

Make sure your latest changes are pushed to your repository.

2) Import Project in Vercel

  • Go to Vercel Dashboard
  • Click Add New Project
  • Select this GitHub repository

3) Configure Project

  • Framework Preset: Other
  • Install Command: pnpm install
  • Build Command: (leave empty)
  • Output Directory: (leave empty)

4) Add Environment Variables

Set these in Project Settings → Environment Variables:

  • DATABASE_URL
  • JWT_SECRET
  • OWNER_EMAIL
  • GOOGLE_CLIENT_ID (optional if Google Sign-In is used)

PORT is managed by Vercel automatically.

5) Run database schema push

Run this against your hosted PostgreSQL database:

pnpm db:push

6) Google OAuth production origin (if enabled)

Add your Vercel domain to Google OAuth Authorized JavaScript origins, for example:

  • https://your-project.vercel.app

๐Ÿ” Google Sign-In Setup

  1. Open Google Cloud Console: https://console.cloud.google.com/
  2. Create OAuth Client ID (Web application)
  3. Add Authorized JavaScript origin:
    • http://localhost:8000
  4. Copy the generated Client ID into .env as GOOGLE_CLIENT_ID
  5. Restart the app

๐Ÿง‘‍๐Ÿ’ป API Endpoints

Auth

  • POST /user/signup
  • POST /user/login
  • POST /user/google
  • GET /user/google/config
  • GET /user/me (auth required)

URL

  • POST /shorten (auth required)
  • GET /codes (auth required)
  • DELETE /:id (auth required)
  • GET /:shortcode (public redirect)

Admin (Owner Only)

  • GET /admin/overview (auth + owner email match)

๐Ÿ“ Folder Structure

URL_Shortner/
├── api/
│   └── index.js
├── db/
├── middleware/
├── model/
├── public/
│   ├── app.js
│   ├── index.html
│   └── styles.css
├── routes/
├── services/
├── utils/
├── validation/
├── docker-compose.yml
├── drizzle.config.js
├── index.js
├── package.json
├── server.js
├── vercel.json
└── README.md

๐Ÿ“ License

This project is licensed under the ISC License.


๐Ÿ“ฌ Contact

For support or contributions, please open an issue or pull request in this repository.

Releases

No releases published

Packages

 
 
 

Contributors