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
💫 💫
Demo links
- 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
- Get the short link information
curl https://ev8saa98t2.execute-api.us-east-1.amazonaws.com/prod/url-handler/{ID}
- 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.
- Install project dependencies:
npm install
- Initialize the project on localhost
npm run start:dev
How to deploy:
Manually:
- Containerize the project
docker build -t url-shortener-repo .
- 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.
- Install aws-cdk package
npm install -g aws-cdk
- Install project dependencies:
npm install
- 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.
- 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