ZipMe is a URL-shortening backend service built using Java and Spring Boot.
It generates short codes using Base62 encoding, supports optional custom aliases, handles redirects, tracks click counts, and stores data in an H2 file-based database with caching support for efficiency.
- Shorten long URLs using Base62 codes
- Optional custom alias support (validated to prevent duplicates)
- Redirect from short URL to long URL
- Click count tracking
- Spring Cache & Caffeine for faster redirects
- Uses postgres db
- Simple Controller–Service–Repository structure
- Java
- Spring Boot
- Spring Web
- Spring Data JPA
- Spring Cache & caffeine
- postgres db
- Lombok
Base62 encoding itself does not guarantee uniqueness.
Collisions normally happen when:
- Base62 is used on random numbers
- Base62 is used on hashes of URLs
- The same input accidentally appears twice
However, ZipMe avoids this problem entirely by not using Base62 on random or arbitrary data.
-
When creating a short URL:
- If the user provides an alias:
- ZipMe checks if the alias is free.
- If available, it uses the alias as the short code.
- If no alias is given:
- A temporary entry is saved to generate an auto-increment ID.
- The ID is encoded using Base62.
- The short code is updated in the database.
- If the user provides an alias:
-
When accessing a short code:
- ZipMe fetches the original URL (from cache or DB).
- Increments the click count.
- Redirects the user to the long URL.
POST /zipme?longUrl={URL}&alias={optionalAlias}Example Response:
Short Url: http://localhost:8080/ziped/abc
If alias already exists:
Alias myalias is already in use. Try another alias or go for default zipme.
GET /ziped/{code}Redirects the user to the full long URL.
GET /info/{code}Example Response:
{
"id": 1,
"longUrl": "https://example.com",
"shortCode": "abc",
"clickCount": 4
}- Clone the repository:
git clone https://github.com/Jain1shh/ZipMe- Run the application:
./mvnw spring-boot:run(or run from your IDE)
- Access the H2 Console:
http://localhost:8080/h2-console
JDBC URL:
jdbc:h2:file:./data/urlsdb
ZipMe was built to understand backend development fundamentals using Spring Boot, including ID-based short code generation, request handling, caching, and persistent storage.