A full-fledged URL Shortener application built with NestJS and PostgreSQL. This application allows users to shorten URLs and track analytics of it.
-
User Authentication and Authorization
- User Signups and Logins (JWT-based)
- Email Verification for Account Activation
- Secure endpoints
-
URL Management
- Create Shortened URLs from long URLs
- Set Expiration Dates for URLs
- Automatic Email Notification upon URL Expiration
- Ownership-based Access Control (Users manage only their own URLs)
- Limit requests per IP to 5 requests/second
-
Analytics
- Track Clicks, IP Addresses, and User Agents
- Filter Analytics by various properties including browser, device, dates etc.
- View Hit Counts per URL
- Backend Framework: NestJS with TypeScript
- Database & ORM: PostgreSQL with TypeORM
- Containerization: Docker & Docker Compose
These instructions will help you set up the development environment on your local machine.
- Node.js >= 22.13.0
- Yarn
- Docker and Docker Compose
-
Clone the Repository
git clone https://github.com/pagevamp/product-traineeship-2024-shortner.git cd product-traineeship-2024-shortner
-
Install Dependencies
yarn install
-
Run Migrations
Run the database migration to create the required database entities for this application:
yarn db:migration:run
-
Setup Environment Variables
Create a
.env
file in the project root using the provided.env.example
as a reference:cp .env.example .env
-
Start with Docker Compose
Running with Docker Compose will start both the application and the database in separate containers:
docker-compose up --build
This will:
- Pull/Build a PostgreSQL database container.
- Build and start the NestJS application container.
-
Start with Node
For running this application without Docker, you need to have Nodejs and Postgresql database installed and running in your machine. Once they are installed, you can follow the following command to run the project:
yarn start:dev
This will:
- Build and start the NestJS application.
The application will be available at http://localhost:3000 or any other port specified in .env file.
Accessing the API
- Postman Workspace: Once running, you can test the APIs endpoints from this Postman Workspace. You might have to create a postman account before joining the workspace.