A modern URL shortener application with a sleek black-orange themed UI.
- ✨ Shorten long URLs instantly
- 📊 View click analytics
- 📋 Copy shortened URLs to clipboard
- 🎨 Beautiful black-orange themed interface
- 📱 Fully responsive design
- ⚡ Built with React + Vite and Node.js
Frontend:
- React with Vite
- Axios for API calls
- Lucide React for icons
- Modern CSS with CSS Variables
Backend:
- Node.js with Express
- MongoDB with Mongoose
- nanoid for generating short IDs
- Node.js (v14 or higher)
- MongoDB running locally or MongoDB Atlas connection
-
Clone the repository
git clone <your-repo-url> cd url-shortener
-
Set up the backend
cd server npm install -
Set up the frontend
cd ../client npm install -
Configure environment variables Create a
.envfile in the server directory:MONGODB_URI=mongodb://localhost:27017/urlshortener PORT=5000
-
Start the backend server
cd server npm start -
Start the frontend development server
cd client npm run dev -
Open your browser Navigate to
http://localhost:5173
POST /api/url- Create a shortened URLGET /api/url/analytics/:shortId- Get analytics for a short URLGET /:shortId- Redirect to original URL (with tracking)
url-shortener/
├── server/ # Backend code
│ ├── app.js # Main server file
│ ├── config/ # Database configuration
│ ├── controllers/ # Route controllers
│ ├── model/ # Database models
│ └── routes/ # API routes
└── client/ # Frontend code
├── src/
│ ├── components/ # React components
│ ├── App.jsx # Main App component
│ └── App.css # Styling
└── public/ # Static assets
- Enter any valid URL to get a shortened version
- Automatically validates URL format
- Generates unique 8-character short IDs
- View total click count
- See complete visit history with timestamps
- Beautiful data visualization
- Instant copy-to-clipboard functionality
- One-click URL opening in new tab
- Loading states and error handling
- Fully responsive design
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
This project is licensed under the MIT License.