A URL shortener with advanced analytics, including click tracking, country-based insights, device detection (Linux, Windows, Mac), and referrer tracking (LinkedIn, Twitter, etc.).
- 🔗 URL Shortening using Base62 encoding
- 📊 Advanced Analytics: Click count, country tracking, device insights, and referral sources
- 🔒 Secure Authentication with Firebase Admin SDK
- ⚡ Performance Optimization with Redis caching
- 📂 Scalable Database Design with PostgreSQL/MongoDB & optimized indexing
- 🛠 Background Processing with BullMQ for analytics updates
- 📡 WebSocket Integration for live tracking
- 📜 RESTful APIs with proper authentication
- Backend: Node.js, Express.js, TypeScript
- Database: PostgreSQL(Prisma ORM)
- Caching & Queues: Redis, BullMQ
- Authentication: Firebase Admin SDK
- Real-time Communication: WebSockets
- Containerization: Docker
-
Clone the repository:
git clone https://github.com/amitskingh/url-shortner cd url-shortner
-
Install dependencies:
npm install
-
Configure environment variables: Create a
.env
file and add the required variables:DATABASE_URL=your_database_url REDIS_URL=your_redis_url # Convert you firebase config into base64 FIREBASE_ADMIN_SDK=your_firebase_config # `AccountID` & `LicenseKey` is from your MaxMind account. AccountID=account_id LicenseKey=license_key
-
Start the development server:
npm run dev npm run worker
Method | Endpoint | Description |
---|---|---|
POST |
/api/v1/ |
Fetch all shorten URL |
POST |
/api/v1/short |
Shorten a URL |
GET |
/api/v1/:shortURL |
Redirect to Original URL |
GET |
/api/v1/analytics/:aliasId |
Get URL Analytics |
- Fork the repository
- Create a feature branch (
git checkout -b feature-branch
) - Commit your changes (
git commit -m 'Add new feature'
) - Push to the branch (
git push origin feature-branch
) - Create a Pull Request
This project is licensed under the MIT License. Feel free to use and modify it!