All projects

Open Source

LynkGo

LynkGo converts long URLs into compact, shareable links using a Snowflake ID generator and Base62 encoding. Built with Java and Spring Boot, it provides a REST API for link creation, redirection, link management, and click statistics, with MongoDB Atlas handling persistent storage.

LynkGo screenshot

LynkGo is a URL-shortening service built with Java, Spring Boot, Spring MVC, and MongoDB Atlas. It accepts a long URL and generates a compact short code that can be shared independently of the original address. The identifier is created using a Snowflake-style ID generator and represented as a shorter string through Base62 encoding. When someone opens the short link, the backend resolves the code, retrieves the saved URL, validates the link's current state, and issues an HTTP redirect. Alongside the core shortening and redirection flow, the service supports link statistics, destination updates, deletion, expiration checks, and activation controls. The codebase separates shortening, redirection, shared utilities, configuration, and exception handling into focused modules.

The problem

Long URLs can be difficult to share, especially when they contain lengthy paths or query parameters. A URL shortener needs to do more than generate a smaller string: it must create a reliable mapping between the short code and the original destination, handle redirects correctly, and prevent expired or disabled links from being used. The identifier-generation strategy also matters because randomly generated codes can collide and require additional database checks.

The solution

I built LynkGo using Java, Spring Boot, and MongoDB Atlas, with a modular backend organised around URL shortening and redirection. The service generates unique identifiers using a Snowflake-style ID generator and converts them into compact, URL-safe strings through Base62 encoding. MongoDB Atlas stores the original URLs and their associated metadata. The redirect flow retrieves the corresponding record, checks whether the link exists, is active, and has expired, and then redirects the visitor to the original destination. The API also includes link-management operations, click tracking, and consistent error responses.

What it does

  • Create short links from long URLs through a REST API
  • Generate unique identifiers using a Snowflake-style ID generator
  • Encode identifiers into compact, URL-safe Base62 strings
  • Redirect visitors to the original destination using HTTP redirects
  • Track click counts and expose link statistics
  • Validate link expiration before redirecting
  • Enable or disable links without requiring permanent deletion
  • Update the destination associated with an existing short code
  • Delete short links through a dedicated API endpoint
  • Return structured error responses through global exception handling
  • Monitor application health and metrics using Spring Boot Actuator
  • Use DTOs to separate API contracts from MongoDB document models

Screenshots

LynkGo screenshot 2

What was hard

One of the main engineering decisions was how to generate short codes without relying on random strings and repeated collision checks. LynkGo uses a Snowflake-style identifier generator followed by Base62 encoding, separating identifier generation from its compact external representation. The redirect flow also requires careful validation: a stored URL should not automatically be treated as usable if the link has expired or has been deactivated. Another important consideration was keeping the codebase maintainable as features grew. I organised the implementation into business-focused modules and used DTOs to avoid exposing persistence models directly through the API. Global exception handling provides a consistent way to communicate failures, while Actuator helps expose application health and metrics for operational visibility.

Results

LynkGo brings URL creation, redirection, and link management into a structured backend service. The project demonstrates how identifier generation, encoding, document persistence, validation, and HTTP redirects work together in a practical application. It also gave me experience organising Spring Boot code by business functionality and keeping API request and response models separate from MongoDB documents.