Skip to content

SnapLink is a modern, scalable URL shortener built with Django (Python) and React (Frontend). It allows users to shorten URLs, track visits, and manage links via a REST API & Web Interface.

Notifications You must be signed in to change notification settings

madhvi-n/snaplink

Repository files navigation

SnapLink - A URL Shortener

Django CI Python Django Django Rest Framework React

SnapLink is a modern, scalable URL shortener built with Django (Python) and React (Frontend). It allows users to shorten URLs, track visits, and manage links via a REST API & Web Interface.

✨ Features

🔗 Core URL Shortening

  • Convert long URLs into short, shareable links
  • Support for custom vanity URLs (Planned)

📊 Analytics & Tracking

  • Click Tracking – Monitor total clicks per short URL
  • Daily Unique Visitors – Track users based on IP
  • Geolocation & Device Data (Future Feature)

⏳ Expiration & One-Time Use

  • Set Expiration – Define a custom expiry date for short links
  • One-Time Use Links – Auto-delete after first visit

🔒 User Authentication & Authorization

  • JWT-Based Authentication with access_token & refresh_token
  • User Registration & Login
  • Personalized Dashboard – Users can manage their URLs

⚡ Performance & Caching

  • Django Cache (Redis) for fast URL redirection
  • Database Indexing & Optimization for efficient queries

🚀 DevOps & Scalability

  • ✅ PostgreSQL Database Integration
  • ✅ Rate Limiting for API security (Django Rest Framework)
  • 🔜 Dockerized Deployment (Planned)
  • 🔜 CI/CD Pipelines with GitHub Actions (Planned)
  • 🔜 Error Monitoring with Sentry (Planned)

📸 Screenshots

SnapLink Home

SnapLink Shorten Url

🛠 Tech Stack

Backend:

  • Python (Django)
  • Django REST Framework (DRF)
  • PostgreSQL (Database)
  • Redis (Caching)

Frontend:

  • React (with Vite)
  • Tailwind CSS (for styling)

📦 Installation & Setup

  1. Clone the Repository

    git clone https://github.com/madhvi-n/snaplink.git
    cd snaplink
  2. Set up a virtual environment

    python -m venv venv
    source venv/bin/activate  # On macOS/Linux
    venv\Scripts\activate  # On Windows
  3. Install Dependencies

    pip install -r requirements.txt
  4. Set up PostgreSQL database

    sudo -u postgres psql
    CREATE DATABASE snaplink;
    CREATE USER snaplink_user WITH PASSWORD 'yourpassword';
    ALTER ROLE snaplink_user SET client_encoding TO 'utf8';
    ALTER ROLE snaplink_user SET default_transaction_isolation TO 'read committed';
    ALTER ROLE snaplink_user SET timezone TO 'UTC';
    GRANT ALL PRIVILEGES ON DATABASE snaplink TO snaplink_user;
  5. Apply Database Migrations & Create Superuser

    python manage.py migrate
    python manage.py createsuperuser
  6. Run the Development Server

    python manage.py runserver

    Access at: http://127.0.0.1:8000

Frontend

  1. Navigate to the Frontend Folder

    cd frontend/snap_link
  2. Install dependencies

    npm install
  3. Set Backend API URL Create a .env file in the frontend root and add:

    VITE_API_URL=http://localhost:8000/api/v1
  4. Start the development server

    npm run dev

📝 API Documentation

The API documentation is available via Swagger:

  • Swagger UI: http://127.0.0.1:8000/api/swagger/
  • Redoc: http://127.0.0.1:8000/api/redoc/
  • DRF Browsable API: http://127.0.0.1:8000/api/v1/

⚙️ Environment Variables (Example .env file)

SECRET_KEY=django-secret-key
DEBUG=True
BASE_URL=http://localhost:8000
REDIS_URL=your-redis-url
ALLOWED_HOSTS=localhost,127.0.0.1
DB_NAME=snaplink
DB_USER=postgres
DB_PASSWORD=123456

🚀 Deployment Guide (Coming Soon)

  • Dockerization
  • CI/CD Pipelines with GitHub Actions
  • Production Database Setup

🛤 Roadmap & Future Features

Completed Features

  • ✅ Core URL Shortening (short links)
  • ✅ Click Tracking (monitor total clicks per URL)
  • ✅ Expiration & One-Time Use Links
  • ✅ JWT-Based Authentication (access_token & refresh_token)
  • ✅ User Registration & Login
  • ✅ PostgreSQL Database Integration
  • ✅ Rate Limiting for API security

Upcoming Features

  • ⬜ Custom Vanity URLs (personalized short links)
  • ⬜ Geolocation & Device Tracking
  • ⬜ User Dashboard for managing URLs
  • ⬜ Dockerized Deployment
  • ⬜ CI/CD Pipelines with GitHub Actions
  • ⬜ Error Monitoring with Sentry

🎉 Happy Coding! 🚀

About

SnapLink is a modern, scalable URL shortener built with Django (Python) and React (Frontend). It allows users to shorten URLs, track visits, and manage links via a REST API & Web Interface.

Topics

Resources

Stars

Watchers

Forks