A robust and scalable URL shortening service built with Spring Boot, featuring user authentication, analytics dashboard, and comprehensive URL management capabilities.
- URL Shortening: Convert long URLs into short, manageable links
- User Authentication: Secure JWT-based authentication system
- Analytics Dashboard: Comprehensive statistics and insights
- Expiration Management: Set custom expiration dates for URLs
- Usage Tracking: Monitor click counts and performance metrics
- RESTful API: Clean and intuitive API design
- Backend: Spring Boot 3.5.6
- Database: MySQL with JPA/Hibernate
- Security: Spring Security with JWT authentication
- Build Tool: Gradle
- Java Version: 21
- Dependencies: Lombok, BCrypt, JJWT
- Java 21 or higher
- MySQL 8.0 or higher
- Gradle 7.0 or higher
-
Copy the example configuration file:
cp src/main/resources/application.properties.example src/main/resources/application.properties
-
Configure your database and JWT settings in
application.properties:spring.datasource.url=jdbc:mysql://localhost:3306/url_shortener spring.datasource.username=your_username spring.datasource.password=your_password jwt.secret=your_jwt_secret_key
-
Clone the repository
git clone https://github.com/montemurro19/url-shortener.git cd url-shortener -
Build the project
./gradlew build
-
Run the application
./gradlew bootRun
The application will start on http://localhost:8080/api
POST /api/auth/register
Content-Type: application/json
{
"email": "user@example.com",
"password": "password123",
"firstName": "John",
"lastName": "Doe"
}POST /api/auth/login
Content-Type: application/json
{
"email": "user@example.com",
"password": "password123"
}POST /api/url/shorten
Authorization: Bearer {jwt_token}
Content-Type: application/json
{
"originalUrl": "https://www.example.com/very-long-url"
}GET /api/url/{shortCode}GET /api/dashboard/summary
Authorization: Bearer {jwt_token}GET /api/dashboard/urls
Authorization: Bearer {jwt_token}GET /api/dashboard/urls/top?limit=10
Authorization: Bearer {jwt_token}src/
├── main/
│ ├── java/com/montes/url_shortener/
│ │ ├── application/ # Application services
│ │ │ ├── dashboard/ # Dashboard business logic
│ │ │ ├── url/ # URL shortening logic
│ │ │ └── user/ # User management logic
│ │ ├── domain/ # Domain models
│ │ │ ├── dashboard/ # Dashboard entities
│ │ │ ├── url/ # URL entities
│ │ │ └── user/ # User entities
│ │ ├── infrastructure/ # Infrastructure layer
│ │ │ ├── url/ # URL repositories
│ │ │ └── user/ # User repositories & utilities
│ │ ├── presentation/ # REST controllers
│ │ │ ├── dashboard/ # Dashboard endpoints
│ │ │ ├── url/ # URL endpoints
│ │ │ └── user/ # Authentication endpoints
│ │ └── config/ # Configuration classes
│ └── resources/
│ └── application.properties
└── test/ # Test classes
./gradlew test./gradlew bootJarA comprehensive Postman collection is available in the documentation/ folder:
- Import
documentation/postman_collection.jsoninto Postman - Set the
base_urlvariable to your API endpoint - Use the collection to test all endpoints
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
Matheus Montemurro
- GitHub: @montemurro19