Skip to content

Akashkalee/LinkSnap

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LinkSnap - URL Shortener

A modern, feature-rich URL shortener built with Django and Python. Create custom short links, track analytics, and generate QR codes with a stunning glassmorphism UI.

Features

Core Features

  • 🔗 Shorten long URLs instantly
  • 🎨 Custom short codes for branded links
  • ⏰ Optional URL expiration
  • 📊 Real-time click tracking and analytics
  • 📱 QR code generation for easy sharing
  • 🎯 Clean, intuitive dashboard

🎨 Premium UI/UX

  • Modern glassmorphism design
  • Smooth animations and transitions
  • Fully responsive layout
  • Dark theme with vibrant gradients
  • Interactive micro-animations

Tech Stack

  • Backend: Django 5.0.1
  • Database: SQLite (easily switchable to PostgreSQL/MySQL)
  • Frontend: HTML5, CSS3, Vanilla JavaScript
  • QR Codes: qrcode library
  • Styling: Custom CSS with modern design patterns

Installation

  1. Clone or navigate to the project directory

    cd "c:\Users\akash\OneDrive\Desktop\url shortener"
  2. Install dependencies

    pip install -r requirements.txt
  3. Run migrations

    python manage.py migrate
  4. Create a superuser (optional, for admin access)

    python manage.py createsuperuser
  5. Start the development server

    python manage.py runserver
  6. Access the application

    You can add this to your local and run it. 
    

Usage

Creating a Short URL

  1. Navigate to the home page
  2. Enter your long URL
  3. (Optional) Click "Advanced Options" to:
    • Set a custom short code
    • Set an expiration date
  4. Click "Shorten"
  5. Copy your new short URL or generate a QR code

Managing URLs

  1. Go to the Dashboard
  2. View all your shortened URLs with statistics
  3. Actions available:
    • Copy: Copy the short URL to clipboard
    • QR Code: Generate and download QR code
    • Stats: View detailed analytics
    • Delete: Remove the URL

URL Redirection

Simply visit any short URL (e.g., http://127.0.0.1:8000/abc123) and you'll be automatically redirected to the original URL. Each click is tracked for analytics.

Project Structure

url shortener/
├── manage.py
├── requirements.txt
├── README.md
├── db.sqlite3
├── urlshortener/          # Project settings
│   ├── __init__.py
│   ├── settings.py
│   ├── urls.py
│   └── wsgi.py
└── shortener/             # Main app
    ├── migrations/
    ├── templates/
    │   └── shortener/
    │       ├── base.html
    │       ├── home.html
    │       ├── dashboard.html
    │       └── expired.html
    ├── __init__.py
    ├── admin.py
    ├── models.py
    ├── views.py
    └── urls.py

API Endpoints

  • POST /api/create/ - Create a new short URL
  • GET /api/stats/<short_code>/ - Get URL statistics
  • DELETE /api/delete/<short_code>/ - Delete a URL
  • GET /qr/<short_code>/ - Generate QR code
  • GET /<short_code>/ - Redirect to original URL

Models

URL Model

  • original_url: The long URL to shorten
  • short_code: Unique short code
  • created_at: Creation timestamp
  • expires_at: Optional expiration date
  • clicks: Click counter
  • is_active: Active status
  • custom_code: Whether it's a custom code

Click Model

  • url: Foreign key to URL
  • clicked_at: Click timestamp
  • ip_address: Visitor IP
  • user_agent: Browser information
  • referrer: Referring URL

Customization

Changing Colors

Edit the CSS variables in shortener/templates/shortener/base.html:

:root {
    --primary: #6366f1;
    --secondary: #ec4899;
    --accent: #14b8a6;
    /* ... more colors */
}

Database Configuration

To use PostgreSQL or MySQL, update DATABASES in urlshortener/settings.py:

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql',
        'NAME': 'your_db_name',
        'USER': 'your_db_user',
        'PASSWORD': 'your_password',
        'HOST': 'localhost',
        'PORT': '5432',
    }
}

Deployment

For production deployment:

  1. Set DEBUG = False in settings.py
  2. Configure ALLOWED_HOSTS
  3. Set up a production database
  4. Configure static files with collectstatic
  5. Use a production server (Gunicorn, uWSGI)
  6. Set up a reverse proxy (Nginx, Apache)

Security Features

  • CSRF protection enabled
  • SQL injection prevention (Django ORM)
  • XSS protection
  • Secure password hashing
  • Clickjacking protection

Future Enhancements

  • User authentication and personal dashboards
  • Bulk URL shortening
  • Advanced analytics (geographic data, device types)
  • API rate limiting
  • Custom domains
  • Link preview before redirect
  • Browser extension

License

This project is open source and available under the MIT License.

Support

For issues, questions, or contributions, please create an issue in the repository.


Built with ❤️ using Django and Python

About

A modern, feature-rich URL shortener built with Django and Python. Create custom short links, track analytics, and generate QR codes with a stunning glassmorphism UI.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages