/url-shortener-app

Primary LanguageTypeScriptApache License 2.0Apache-2.0

Sample Project Url Shortener Application

Sample application project to short an URL.

Techstack:

  • NestJS - Typescript power 💪
  • AWS CDK - To create the IaC (Infrastructure as a code) and deploy using Cloudformation
  • Flutter Web - Beautiful UIs in a breeze 💅
  • Docker - Pack it, ship it! 🚢 🚀
  • Magic 💫💫

Publish Docker Image to ECR

Demo links

  1. Create a short link:
curl -d '{"longUrl": "google.com"}' -H "Content-Type: application/json" -X POST https://ev8saa98t2.execute-api.us-east-1.amazonaws.com/prod/url-handler
  1. Get the short link information
curl https://ev8saa98t2.execute-api.us-east-1.amazonaws.com/prod/url-handler/{ID}
  1. Health Check endpoint
curl https://ev8saa98t2.execute-api.us-east-1.amazonaws.com/prod/url-handler

Getting Started

Folder Structure:

📂/
└───📂 backend - NestJS Backend Application
└───📂 frontend - Flutter Web Application
└───📂 iac - AWS CDK Project contains the infrastructure to deploy the backend service.

Backend

Open your terminal and open the backend folder.

  1. Install project dependencies:
npm install
  1. Initialize the project on localhost
npm run start:dev

How to deploy:

Manually:

  1. Containerize the project
docker build -t url-shortener-repo .
  1. Push the generated Docker container to your desired repository.

Via CI/CD

Configure your repository to use Github Actions

Use this workflow as reference

IaC (Infrastructure as Code)

Open your terminal and open the iac folder.

  1. Install aws-cdk package
npm install -g aws-cdk
  1. Install project dependencies:
npm install
  1. Syntethize the cdk code to generate a cloudformation template
cdk synth

This will output to the cdk.out directory, where you can review the template before deploying.

  1. Deploy your infrastructure.
cdk deploy

Infrastructure to be provisioned:

  • API Gateway
  • ECR Repository
  • Lambda Function
  • IAM Role
  • DynamoDB Table definition

BE AWARE YOU MIGHT INCUR IN COSTS BY DEPLOYING TO AWS

Frontend

TBD

Want to deploy your own?

Deploy to AWS