ShrinkIt β Serverless URL Shortener
ShrinkIt is an open-source, serverless URL shortener built with AWS SAM and Go (Golang). It allows you to shorten long URLs into tiny, shareable links while staying cost-efficient and fully under your control.
β¨ Features
- π Short URLs β Generate simple, easy-to-share links.
- β‘ Serverless β Powered by AWS Lambda for high scalability and low cost.
- π Built with Go β Fast, efficient, and highly portable.
- π§© Infrastructure as Code β Managed using AWS SAM templates.
ποΈ Architecture
ShrinkIt is designed as a fully serverless app:
- API Gateway β Provides REST endpoints for creating and retrieving short URLs.
- Lambda (Go) β Business logic written in Go, handling shortening and redirection.
- DynamoDB β Stores original URLs and short-code mappings.
- AWS SAM β Deploys and manages the entire infrastructure.
[ Client ] β [ API Gateway ] β [ Lambda (Go) ] β [ DynamoDB ]
π Getting Started
Prerequisites
1. Clone the Repository
git clone https://github.com/ticatwolves/shrinkIt.git
cd shrinkIt
2. Build the Project
make build
3. Deploy to AWS
make deploy
Follow the prompts to configure stack name, region, and permissions.
4. Usage
-
Shorten a URL
curl -X POST https://<api-id>.execute-api.<region>.amazonaws.com/prod -H "Content-Type: application/json" -d '{"url": "https://example.com/very/long/url"}'
Response:
{ "short_url": "https://<api-id>.execute-api.<region>.amazonaws.com/prod/shrink/abcd123" }
-
Redirect to original URL
curl -i https://<api-id>.execute-api.<region>.amazonaws.com/prod/shrink/abcd123
π Development
Run Locally with SAM
make local-start
Test with:
curl http://127.0.0.1:3000/shrink -d '{"url":"https://example.com"}'
π Project Structure
.
βββ cmd/ # Go Lambda handler
βββ internal/ # Business logic
βββ deploy/template.yaml # AWS SAM template
βββ go.mod
βββ README.md
π License
This project is licensed under the MIT License.