A URL shortening web application built with Spring Boot that allows users to register, log in, shorten long URLs, and manage their shortened links. The app supports role-based access control and is designed with a server-rendered HTML UI using Thymeleaf.
- 🔒 User Registration & Login (Spring Security + Thymeleaf)
- ✂️ Shorten URLs with generated short codes
- 🔄 Redirect from Short URL to Original URL
- 🧑💼 Role-Based Access Control (
ROLE_USER,ROLE_ADMIN) - 📦 Persistent Storage (e.g., PostgreSQL)
- 🌐 Thymeleaf-based Web Interface
- Java 17+
- Spring Boot 3
- Spring MVC
- Spring Security (Form Login)
- Thymeleaf
- PostgreSQL
- Flyway (for database migrations)
- Maven
/register→ User registration form/login→ Custom login form/→ Homepage and shortening form (public)/my-urls→ View and manage your own URLs (protected)/admin/**→ Admin-only features (optional)/s/{shortCode}→ Redirect to original URL
- Users are authenticated via form-based login
- User roles are defined using a custom
Roleenum:public enum Role { ROLE_USER, ROLE_ADMIN }
git clone https://github.com/yourusername/shorturlapp.git cd shorturlapp
./mvnw clean install
./mvnw spring-boot:run
To run the project locally with PostgreSQL:
- Create a PostgreSQL database named
shorturlapp - Copy
application-example.propertiestoapplication.properties - Update it with your own database username and password