A full-featured URL shortener service built with Node.js, Express, and PostgreSQL.
This project provides RESTful APIs for user authentication, URL shortening, and analytics.
- π User Authentication β JWT-based signup and login
- βοΈ URL Shortening β Convert long URLs to short codes
- π§© URL Management β View and delete your shortened URLs
- π Redirection β Automatic redirect to original URLs
- π‘οΈ Secure & Type-safe β Built using Zod validation and Drizzle ORM
| Category | Technology | Purpose |
|------------------|----------------------|------------------------------------------|
| Backend | Node.js + Express | REST API development |
| Database | PostgreSQL | Relational data store |
| ORM | Drizzle ORM | Type-safe database queries & schema |
| Containerization | Docker + Compose | Local PostgreSQL instance |
| Authentication | JWT | Secure private routes |
| Validation | Zod | Input validation |
| Testing | Postman | Manual API testing |
---
## π Prerequisites
Before you begin, make sure you have the following installed on your system:
- [Node.js](https://nodejs.org/) (v18 or above recommended)
- [Docker Desktop](https://www.docker.com/products/docker-desktop/)
- [Postman](https://www.postman.com/) (for API testing)
- [VS Code](https://code.visualstudio.com/) (recommended editor)
---
## ποΈ Project Structure
```text
src/
βββ controllers/ # Route controllers
βββ services/ # Business logic
βββ models/ # Database models
βββ middleware/ # Custom middleware
βββ utils/ # Utility functions
βββ validation/ # Zod schemas
βββ config/ # Configuration files
## π API Endpoints
### π§ββοΈ Auth Routes
```bash
| Method | Endpoint | Description | Auth Required |
|--------|--------------|--------------------------|----------------|
| POST | '/signup' | Register a new user | β |
| POST | '/login' | Login and receive token | β |
## π URL Routes
| Method | Endpoint | Description | Auth Required |
|--------|----------------|---------------------------------------------|----------------|
| POST | '/shorten' | Create a short URL from a long one | β
|
| GET | '/:shortCode' | Redirect to the original URL | β |
| GET | '/urls' | Get all URLs created by the logged-in user | β
|
| DELETE | '/urls/:id' | Delete a short URL (if it belongs to user) | β
|