Skip to content

voloshynm/UrlShortener

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 

Repository files navigation

UrlShortener

A lightweight, efficient URL shortening service built with Java and Spring Boot. Transform long URLs into short, manageable links with comprehensive analytics and management features.

🚀 Features

  • URL Shortening: Convert long URLs into short, memorable links
  • Custom Aliases: Create personalized short URLs with custom keywords
  • Analytics Dashboard: Track clicks, referrers, and usage statistics
  • API Access: RESTful API for programmatic URL shortening
  • Bulk Operations: Shorten multiple URLs simultaneously
  • Expiration Control: Set expiration dates for temporary links
  • QR Code Generation: Automatic QR code creation for each shortened URL

🛠️ Tech Stack

  • Backend: Java 17, Spring Boot 3.x
  • Database: H2 (development), PostgreSQL (production)
  • Caching: Redis for high-performance link resolution
  • Frontend: Thymeleaf templates with Bootstrap
  • Build Tool: Maven
  • Testing: JUnit 5, Mockito

📋 Prerequisites

  • Java 17 or higher
  • Maven 3.6+
  • Redis server (optional, for caching)
  • PostgreSQL (for production deployment)

🚀 Quick Start

  1. Clone the repository:
git clone https://github.com/voloshynm/UrlShortener.git
cd UrlShortener
  1. Configure application properties:
# Edit src/main/resources/application.properties
server.port=8080
spring.datasource.url=jdbc:h2:mem:testdb
app.base-url=http://localhost:8080
  1. Build and run:
mvn clean install
mvn spring-boot:run
  1. Access the application:
    • Web Interface: http://localhost:8080
    • API Documentation: http://localhost:8080/swagger-ui.html

🔧 API Usage

Shorten URL

POST /api/shorten
Content-Type: application/json

{
  "originalUrl": "https://example.com/very/long/url",
  "customAlias": "mylink",
  "expirationDate": "2025-12-31T23:59:59"
}

Redirect to Original URL

GET /{shortCode}
# Redirects to original URL

Get URL Statistics

GET /api/stats/{shortCode}
# Returns click count, creation date, etc.

🏗️ Project Structure

UrlShortener/
├── src/main/java/
│   ├── controller/          # REST controllers
│   ├── service/            # Business logic
│   ├── repository/         # Data access layer
│   ├── model/              # Entity classes
│   └── config/             # Configuration classes
├── src/main/resources/
│   ├── templates/          # Thymeleaf templates
│   ├── static/             # CSS, JS, images
│   └── application.properties
└── src/test/               # Unit and integration tests

🔒 Configuration

Database Configuration

# H2 (Development)
spring.datasource.url=jdbc:h2:mem:testdb
spring.h2.console.enabled=true

# PostgreSQL (Production)
spring.datasource.url=jdbc:postgresql://localhost:5432/urlshortener
spring.datasource.username=your_username
spring.datasource.password=your_password

Redis Configuration (Optional)

spring.redis.host=localhost
spring.redis.port=6379
spring.redis.password=your_redis_password

🧪 Testing

Run the test suite:

mvn test

Run integration tests:

mvn verify

📊 Features Overview

Feature Description Status
URL Shortening Basic URL shortening functionality
Custom Aliases User-defined short codes
Click Analytics Track and display usage statistics
QR Codes Generate QR codes for URLs
Bulk Operations Process multiple URLs at once
API Access RESTful API endpoints
Link Expiration Time-based URL expiration
Admin Dashboard Management interface 🚧

🚀 Deployment

Docker Deployment

# Build Docker image
docker build -t urlshortener .

# Run container
docker run -p 8080:8080 urlshortener

Production Deployment

  1. Configure production database
  2. Set environment variables
  3. Build production JAR: mvn clean package -Pprod
  4. Deploy to your preferred platform

🤝 Contributing

  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

📝 License

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

👤 Author

Maksym Voloshyn

🙏 Acknowledgments

  • Spring Boot team for the excellent framework
  • Bootstrap for responsive UI components
  • H2 Database for easy development setup

Built with ❤️ for efficient link management

Keywords: java spring-boot url-shortener rest-api maven h2-database redis analytics

About

Mindavalley Application

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages