DEV Community

Cover image for Design a serverless URL Shortener leveraging AWS
Anmol Pal for AWS Community Builders

Posted on • Edited on

13

Design a serverless URL Shortener leveraging AWS

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 /<shortUrl> — 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


Warp.dev image

Warp is the #1 coding agent.

Warp outperforms every other coding agent on the market, and gives you full control over which model you use. Get started now for free, or upgrade and unlock 2.5x AI credits on Warp's paid plans.

Download Warp

Top comments (4)

Collapse
 
divyansh_singh_e7a0019ac8 profile image
Divyansh Singh

Insightful

Collapse
 
sanya_pandey_816177614bd2 profile image
Sanya Pandey

Great work!

Collapse
 
anushka_agarwal_8583a3828 profile image
Anushka Agarwal

Keep it up!!

Collapse
 
siddharth_gahalot_2a82988 profile image
Siddharth Gahalot • Edited

Well done Anmol 👍