Skip to content

thecodeholic/livewire-url-shortener

Repository files navigation

URL Shortener

A modern URL shortening service built with Laravel 12 and Livewire 4. Create short, memorable links and track their performance with built-in analytics and QR code generation.

Features

  • URL Shortening - Generate 6-character alphanumeric short codes for any URL
  • QR Code Generation - Create downloadable QR codes (SVG/PNG) with scan tracking
  • Click Analytics - Track total clicks, QR scans vs regular clicks, and view detailed statistics
  • User Dashboard - Manage all your shortened URLs in one place
  • Authentication - Full user registration, login, and password reset functionality
  • Two-Factor Authentication - Optional 2FA for enhanced account security
  • Email Verification - Verify user email addresses

Tech Stack

  • Backend: PHP 8.2+, Laravel 12
  • Frontend: Livewire 4, Flux UI, Tailwind CSS 4
  • Authentication: Laravel Fortify
  • Testing: Pest 4
  • Build Tools: Vite 7
  • Database: SQLite (default), MySQL/PostgreSQL supported

Requirements

  • PHP 8.2 or higher
  • Composer
  • Node.js and npm
  • SQLite (default) or MySQL/PostgreSQL

Installation

  1. Clone the repository

    git clone git@github.com:thecodeholic/livewire-url-shortener.git
    cd url-shortener
    
  2. Install dependencies

    composer install
    npm install
    
  3. Environment setup

    cp .env.example .env
    php artisan key:generate
    
  4. Database setup

    touch database/database.sqlite
    php artisan migrate
    
  5. Build assets

    npm run build
    

Alternatively, run the setup script:

composer setup

Running the Application

Development

Start all development services (server, queue, logs, and Vite) with a single command:

composer dev

This runs:

  • Laravel development server at http://localhost:8000
  • Queue worker for background jobs
  • Log viewer with Laravel Pail
  • Vite for hot module replacement

Production

Build assets for production:

npm run build

Running Tests

Run the full test suite:

php artisan test

Run tests with code style checking:

composer test

Run a specific test file:

php artisan test tests/Feature/UrlShortenerTest.php

Filter by test name:

php artisan test --filter=testName

Code Style

This project uses Laravel Pint for code formatting:

# Fix code style issues
composer lint

# Check for code style issues without fixing
composer test:lint

Project Structure

app/
├── Http/Controllers/     # HTTP controllers
├── Livewire/             # Livewire components
├── Models/               # Eloquent models (Url, UrlClick, User)
├── Policies/             # Authorization policies
└── Services/             # Business logic (UrlShortenerService, QrCodeService)

resources/views/
├── components/           # Livewire component views
├── layouts/              # Application layouts
└── pages/                # Page views (auth, settings)

tests/
├── Feature/              # Feature tests
└── Unit/                 # Unit tests

License

This project is open-sourced software licensed under the MIT license.

About

URL Shortener with QR code generation and URL tracking analytics

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages