Skip to content

RuidiH/MicroURL

Repository files navigation

MicroURL (Work in Progress)

MicroURL takes a long URL and returns a micro URL for you

Installation

Prerequisites

  • Go 1.21+
  • Terraform
  • Docker (for local testing)
  • AWS CLI (for AWS deployment)
  • Make or PowerShell

Setup

# Build Lambda functions (Unix/Linux/WSL with zip)
make build-lambdas

# OR for Windows PowerShell users
make build-lambdas-powershell

Deployment

Local Deployment (LocalStack Community)

# Start LocalStack and deploy
make deploy-local

# Frontend available at: http://localhost:8080

AWS Learner Lab Deployment

Standard AWS Account

# Configure AWS credentials
aws configure

# Deploy to AWS
make deploy-lab

AWS Learner Lab

# Download and source your Lab credentials
source ~/.aws/labsuser.sh  # or paste credentials into ~/.aws/credentials

# Or configure manually
aws configure
aws configure set aws_session_token <YOUR-SESSION-TOKEN>

# Deploy using existing LabRole
make deploy-lab

Testing

Local Testing (LocalStack)

After local deployment, get your API Gateway ID from Terraform output, or manually retrieve it:

cd terraform && terraform output api_gateway_id

Test LocalStack endpoints:

# Create short URL (replace <api-id> with your actual ID)
curl -X POST http://localhost:4566/restapis/<api-id>/local/_user_request_/urls \
  -H "Content-Type: application/json" \
  -d '{"url": "https://google.com"}'

# Test redirect (use returned code)
curl -L http://localhost:4566/restapis/<api-id>/local/_user_request_/urls/<code>

# Or directly visit
http://localhost:4566/restapis/<api-id>/local/_user_request_/urls/<code>

AWS Testing

After AWS deployment, get your API Gateway ID from Terraform output, or manually retrieve it:

cd terraform && terraform output api_gateway_id

Test AWS endpoints:

# Create short URL (replace <api-id> with your actual ID)
curl -X POST https://<api-id>.execute-api.us-west-2.amazonaws.com/dev/urls \
  -H "Content-Type: application/json" \
  -d '{"url": "https://google.com"}'

# Test redirect (use returned code)
curl -L https://<api-id>.execute-api.us-west-2.amazonaws.com/dev/urls/<code>

# Or directly visit
https://<api-id>.execute-api.us-west-2.amazonaws.com/dev/urls/<code>

Design

Functional Requirement

  1. Users can post a long url and get a short url.
  2. Visiting the short url should redirect user to the long url.
  3. The short url is unique for every long url provided.
  4. (Optional) Users can set a expiration date for the link.
  5. (Optional) Users can use custom alias instead if it does not already exist.

Non-functional Requirement

  1. User should receive the short url in 10 seconds.
  2. The short url should be avaialble in 1 minute.
  3. The service should support 30,000 DAU activities.

System Desgin Diagram


Image

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published