A full-stack MERN application that allows users to generate short URLs and QR codes for long URLs. The system supports both guest users (tracked via httpOnly cookie) and registered users with authentication and pricing plans.
- URL Shortening: Convert long URLs into short, memorable links
- QR Code Generation: Automatic QR code generation for each short URL
- Guest & Registered Users: Create short URLs as a guest or register for advanced features
- Click Analytics: Track clicks with detailed analytics (geographic location, device, browser, referrer)
- Custom Aliases: Registered users can create custom short codes
- Plan-based Quotas: Free, Pro, and Enterprise plans with different limits
- Email/Password registration and login
- JWT tokens stored in httpOnly cookies
- Guest user tracking with secure guestId cookies
- Secure password hashing with bcrypt
- Real-time click tracking with geographic location
- Device and browser detection
- Referrer tracking
- Day-by-day analytics
- Custom date range filtering
- Stripe integration for plan upgrades
- Webhook handling for payment success
- Automatic plan updates
- Runtime: Node.js + Express.js
- Database: MongoDB
- Authentication: JWT + bcrypt
- QR Code: qrcode library
- Analytics: GeoIP-Lite, UA-Parser
- Payment: Stripe
- Security: Helmet, CORS, Rate Limiting
- Framework: React 18
- Routing: React Router v6
- State Management: Zustand
- HTTP Client: Axios
- Styling: Tailwind CSS
- Icons: React Icons
- Notifications: React Hot Toast
cd backend
cp .env.example .env
# Edit .env with your MongoDB URI and other config
npm install
npm run devcd frontend
cp .env.example .env
npm install
npm startBackend runs on http://localhost:5000
Frontend runs on http://localhost:3000
backend/
├── models/ # MongoDB schemas
├── controllers/ # Business logic
├── routes/ # API endpoints
├── middleware/ # Auth, validation, error handling
├── utils/ # Helper functions
└── server.js # Express app
frontend/
├── src/
│ ├── components/ # Reusable components
│ ├── pages/ # Route pages
│ ├── store/ # Zustand state
│ ├── services/ # API calls
│ └── App.jsx # Root component
└── public/ # Static files
POST /api/auth/register- Register new userPOST /api/auth/login- Login userGET /api/auth/logout- LogoutGET /api/auth/me- Get profile (protected)
POST /api/url/create- Create short URLGET /api/url/list- List user's URLsGET /api/url/:id- Get URL detailsDELETE /api/url/:id- Delete URLGET /:shortCode- Redirect to original URL
GET /api/analytics/:urlId- Get URL analyticsGET /api/analytics/dashboard- Dashboard stats (protected)
GET /api/plan- List all plansGET /api/plan/current- Get user's plan (protected)POST /api/plan/upgrade- Upgrade plan (protected)
| Feature | Free | Pro | Enterprise |
|---|---|---|---|
| Links/month | 100 | 5,000 | 100,000 |
| Analytics retention | 30 days | 365 days | Unlimited |
| Custom domains | ❌ | ✅ | ✅ |
| Custom aliases | ✅ | ✅ | ✅ |
| API access | ❌ | ✅ | ✅ |
| Price | Free | $9.99 | $49.99 |
- Password: Bcrypt hashing
- Authentication: JWT in httpOnly cookies
- Validation: Input validation on all endpoints
- Rate Limiting: API rate limiting to prevent abuse
- CORS: Configured for security
- Headers: Helmet.js for security headers
- Guest Tracking: Secure guestId in httpOnly cookies
MONGODB_URI=mongodb+srv://...
JWT_SECRET=your_secret_key
JWT_EXPIRY=7d
NODE_ENV=development
PORT=5000
CLIENT_URL=http://localhost:3000
STRIPE_SECRET_KEY=sk_test_...
STRIPE_WEBHOOK_SECRET=whsec_...
BASE_URL=http://localhost:5000
REACT_APP_API_URL=http://localhost:5000/api
- Fork the repository
- Create a feature branch
- Commit your changes
- Push and create a Pull Request
MIT License - feel free to use this project for personal or commercial purposes.
For issues and questions, please create an issue on GitHub.
Built with ❤️ using MERN Stack