Shawtly is a full-stack, modern URL shortener designed for the modern web. Built with cutting-edge technologies and a focus on user experience, it provides a seamless way to create, manage, and track shortened URLs.
- π¨ Beautiful Interface β Sleek, responsive design that works on all devices
- β‘ Lightning Fast β Built with modern React and optimized for performance
- π Secure by Default β JWT authentication and secure route protection
- π Real-time Analytics β Track clicks, views, and user engagement
- π― Custom Links β Create memorable, branded short URLs
- π One-Click Actions β Copy, share, and manage links effortlessly
|
|
π¦ Complete Dependencies
Frontend
- React 19 β Modern React with concurrent features
- Vite β Lightning fast build tool
- Tailwind CSS β Utility-first CSS framework
- Redux Toolkit β State management
- TanStack Router β Type-safe routing
- TanStack Query β Data fetching & caching
- Axios β HTTP client
Backend
π¦ shawtly-url-shortener/
βββ ποΈ BACKEND/
β βββ π app.js # Express app configuration
β βββ π src/
β βββ π config/ # Database & app configuration
β βββ π controllers/ # Request handlers
β βββ π DAO/ # Data Access Objects
β βββ π middleware/ # Custom middleware
β βββ π models/ # Mongoose schemas
β βββ π routes/ # API routes
β βββ π services/ # Business logic
β βββ π utils/ # Helper functions
β
βββ ποΈ FRONTEND/
β βββ π index.html # Entry HTML
β βββ π vite.config.js # Vite configuration
β βββ π src/
β βββ π apis/ # API integration
β βββ π components/ # Reusable components
β βββ π pages/ # Page components
β βββ π routing/ # Route configuration
β βββ π store/ # Redux store
β βββ π utils/ # Utility functions
β
βββ π README.md # You are here!
Make sure you have these installed:
- Node.js v18 or higher
- MongoDB (local or cloud instance)
- Git for version control
-
Clone the repository
git clone https://github.com/yourusername/shawtly-url-shortener.git cd shawtly-url-shortener -
Setup Backend
cd BACKEND npm install # Create environment file cp .env.example .env # Edit .env with your configurations
-
Setup Frontend
cd ../FRONTEND npm install # Optional: Create frontend environment file cp .env.example .env
Backend (.env)
# Database
MONGO_URI=mongodb://localhost:27017/shawtly
# or MongoDB Atlas: mongodb+srv://username:password@cluster.mongodb.net/shawtly
# Authentication
JWT_SECRET=your-super-secret-jwt-key-here
JWT_EXPIRE=7d
# Server
PORT=5000
NODE_ENV=development
# Optional: Rate limiting
RATE_LIMIT_WINDOW_MS=900000
RATE_LIMIT_MAX_REQUESTS=100Frontend (.env) (Optional)
VITE_API_URL=http://localhost:5000/api
VITE_BASE_URL=http://localhost:3000Development Mode:
# Terminal 1: Backend
cd BACKEND
npm run dev
# Terminal 2: Frontend
cd FRONTEND
npm run devProduction Build:
# Build frontend
cd FRONTEND
npm run build
# Start production server
cd ../BACKEND
npm startπ Authentication Endpoints
| Method | Endpoint | Description | Body |
|---|---|---|---|
POST |
/api/auth/register |
Register new user | {email, password, name} |
POST |
/api/auth/login |
User login | {email, password} |
POST |
/api/auth/logout |
User logout | - |
GET |
/api/auth/me |
Get current user | - |
PUT |
/api/auth/profile |
Update profile | {name, email} |
π URL Management Endpoints
| Method | Endpoint | Description | Body |
|---|---|---|---|
POST |
/api/urls/create |
Create short URL | {originalUrl, customSlug?} |
GET |
/api/urls |
Get user's URLs | - |
GET |
/api/urls/:id |
Get URL details | - |
PUT |
/api/urls/:id |
Update URL | {customSlug?, active?} |
DELETE |
/api/urls/:id |
Delete URL | - |
GET |
/:shortId |
Redirect to original | - |
π Analytics Endpoints
| Method | Endpoint | Description | Query Params |
|---|---|---|---|
GET |
/api/analytics/url/:id |
URL analytics | ?period=7d&timezone=UTC |
GET |
/api/analytics/dashboard |
Dashboard stats | ?period=30d |
GET |
/api/analytics/export/:id |
Export data | ?format=csv |
We welcome contributions! Here's how you can help:
- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature - Commit your changes:
git commit -m 'Add amazing feature' - Push to the branch:
git push origin feature/amazing-feature - Open a Pull Request
- Follow the existing code style
- Write meaningful commit messages
- Add tests for new features
- Update documentation as needed
- Ensure all tests pass before submitting
Common Issues & Solutions
Backend won't start:
- Check if MongoDB is running
- Verify environment variables
- Ensure correct Node.js version
Frontend build fails:
- Clear node_modules:
rm -rf node_modules && npm install - Check for syntax errors
- Verify all dependencies are installed
Authentication not working:
- Verify JWT_SECRET is set
- Check cookie settings
- Ensure CORS is properly configured
This project is licensed under the MIT License - see the LICENSE file for details.
Special thanks to these amazing projects and resources:
- React - The library for web and native user interfaces
- Tailwind CSS - A utility-first CSS framework
- TanStack - High-quality open-source software
- MongoDB - The application data platform
- nanoid - A tiny, secure, URL-friendly ID generator