Design a serverless URL Shortener service using AWS.

Link to Github repository: https://github.com/anmol111pal/URL-Shortener-using-AWS/

Requirements

Provide an endpoint where the user can request for a shortened version of a URL. Also provide an endpoint that redirects the short URL to the original URL.

Glossary

API Gateway: acts as a single entry point for API calls, routing client requests to the appropriate backend services while also handling tasks like authentication, authorization, and rate limiting.

Lambda: is a serverless, event-driven compute service that allows you to run code without provisioning or managing servers, focusing on code execution and scaling based on events, rather than infrastructure.

Dynamo DB: is a fully managed, serverless NoSQL database service provided by AWS that supports key-value and document data models, designed for high-performance and scalable applications.

Proposed Design Approach

Architecture Design of serverless URL Shortener

Implementation Plan

Implement a REST API on API Gateway, that exposes two endpoints.

POST /shorten-url — send a URL via request body and shorten the URL.
GET / — redirects the user to the original URL.
Both the endpoints will map to a Lambda function each to process the request.

We will have the following Lambda functions:

  1. ShortenURLFunction — a funtion that receives the original (long) URL and generates a short ID that maps to the provided URL. This function adds this into the Dynamo DB table, and initializes the click count to 0.

  2. RedirectURLFunction — a function that receives the short URL, queries the Dynamo DB table. This function increments the click count, and redirects the user to the original URL.

Dynamo DB Schema

{

shortUrl — string

url — string

timestamp — DateTime

clicks — integer

}

Follow on my socials:

Linkedin:https://www.linkedin.com/in/anmol-pal/

Github: https://github.com/anmol111pal/

X/Twitter: [https://x.com/anmol111pal](https://x.com/anmol111pal