A RESTful URL Shortener API built with Java and Spring Boot. The project focuses on clean backend architecture, database management, API design, testing, and containerized deployment.
https://url-shortner-r3v7.vercel.app/
https://url-shortener-a697.onrender.com/swagger-ui/index.html#/
- Create short URLs
- Redirect using a short code
- Track click counts
- Detect and handle duplicate URLs
- Return an existing short code when a URL already exists
- Store website/site information
- URL expiration support
- Soft deletion
- Global exception handling
- DTO-based API design
- Database migrations with Flyway
- Integration testing
- Swagger/OpenAPI documentation
- Dockerized Spring Boot application and PostgreSQL database
- Runs the application container as a non-root user
- Java 21
- Spring Boot
- Spring Data JPA / Hibernate
- PostgreSQL
- Flyway
- MapStruct
- Lombok
- Maven
- Docker & Docker Compose
- Swagger / OpenAPI
- JUnit
The application follows a layered architecture:
Client
↓
Controller
↓
Service
↓
Repository
↓
PostgreSQL
Swagger UI is available when the application is running:
http://localhost:8080/swagger-ui/index.html
Swagger provides an interactive interface for exploring and testing the API endpoints.
The project includes integration tests that verify the application together with the database and Spring application context.
Run the tests with:
mvn test- Java 21
- Maven
- Docker
- Docker Compose
mvn clean packagesudo docker compose up --build -dsudo docker pssudo docker compose logs -fThe API will be available at:
http://localhost:8080
The application uses PostgreSQL for persistent storage.
Flyway automatically applies database migrations when the application starts, keeping the database schema versioned and consistent across environments.
src/
├── main/
│ ├── java/com/urlshrtner/project/
│ │ ├── controller/
│ │ ├── service/
│ │ ├── repository/
│ │ ├── entity/
│ │ ├── dto/
│ │ ├── mapper/
│ │ └── exception/
│ │
│ └── resources/
│ └── db/migration/
│
└── test/
└── java/com/urlshrtner/project/
Kalkidan Kelemework
Computer Science student and aspiring backend developer focused on Java, Spring Boot, REST APIs, and backend system design.