Skip to content

Latest commit

Β 

History

23 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸš€ Shawtly – Modern URL Shortener

Transform long URLs into powerful, trackable short links

License: MIT Made with React Backend: Node.js Database: MongoDB


🎯 What is Shawtly?

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.

✨ Key Highlights

  • 🎨 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

πŸš€ Features

🎨 Modern UI/UX

  • Responsive, mobile-first design
  • Beautiful gradients and animations
  • Dark/light mode support
  • Intuitive user interface

πŸ” Authentication & Security

  • Secure JWT-based authentication
  • Protected routes and API endpoints
  • Password hashing with bcrypt
  • Session management

πŸ“Š Analytics Dashboard

  • Real-time click tracking
  • Visual analytics charts
  • URL performance metrics
  • Export data functionality

⚑ URL Management

  • Instant URL shortening
  • Custom slug creation
  • Bulk URL operations
  • QR code generation

πŸ› οΈ Tech Stack

Frontend

React Vite TailwindCSS Redux

Backend

Node.js Express.js MongoDB JWT

πŸ“¦ Complete Dependencies

Frontend

Backend

  • Node.js – JavaScript runtime
  • Express – Web framework
  • MongoDB – NoSQL database
  • Mongoose – MongoDB object modeling
  • JWT – Authentication tokens
  • bcryptjs – Password hashing
  • nanoid – URL ID generation

πŸ—οΈ Project Architecture

πŸ“¦ 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!

πŸš€ Quick Start

Prerequisites

Make sure you have these installed:

  • Node.js v18 or higher
  • MongoDB (local or cloud instance)
  • Git for version control

πŸ”§ Installation

  1. Clone the repository

    git clone https://github.com/yourusername/shawtly-url-shortener.git
    cd shawtly-url-shortener
  2. Setup Backend

    cd BACKEND
    npm install
    
    # Create environment file
    cp .env.example .env
    # Edit .env with your configurations
  3. Setup Frontend

    cd ../FRONTEND
    npm install
    
    # Optional: Create frontend environment file
    cp .env.example .env

βš™οΈ Environment Variables

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=100

Frontend (.env) (Optional)

VITE_API_URL=http://localhost:5000/api
VITE_BASE_URL=http://localhost:3000

πŸƒβ€β™‚οΈ Running the Application

Development Mode:

# Terminal 1: Backend
cd BACKEND
npm run dev

# Terminal 2: Frontend  
cd FRONTEND
npm run dev

Production Build:

# Build frontend
cd FRONTEND
npm run build

# Start production server
cd ../BACKEND
npm start

πŸ“‘ API Reference

πŸ” 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

🀝 Contributing

We welcome contributions! Here's how you can help:

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/amazing-feature
  3. Commit your changes: git commit -m 'Add amazing feature'
  4. Push to the branch: git push origin feature/amazing-feature
  5. Open a Pull Request

πŸ“‹ Development Guidelines

  • Follow the existing code style
  • Write meaningful commit messages
  • Add tests for new features
  • Update documentation as needed
  • Ensure all tests pass before submitting

πŸ› Troubleshooting

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

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.


πŸ™ Acknowledgements

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

Made with ❀️ by Akshat

⭐ Star this repo if you find it helpful! ⭐

πŸ” Back to Top

About

Resources

Stars

0 stars

Watchers

0 watching

Forks

Contributors

Languages