- Google OAuth Authentication - Secure access with Google Identity Services
- Modern React Frontend - Built with React, Vite, and Chakra UI
- RESTful API - Create short URLs and fetch statistics
- Custom Short IDs - Human-readable option for memorable links
- TTL Support - Set expiration dates for your short links
- Analytics Dashboard - Track clicks with weekly statistics
- Companion Static Website - Single Page Application (SPA)
- Click Counter - Detailed analytics persisted in DynamoDB
Frontend:
- React 18 with Vite
- Chakra UI component library
- Google Identity Services for authentication
Backend:
- AWS Lambda (Python 3.10)
- API Gateway with Lambda Authorizer
- DynamoDB for data persistence
- CloudFront + S3 for static hosting
- ACM for SSL certificates
- CloudFormation + SAM for infrastructure as code
- AWS Certificate - You will need an already issued AWS Certificate Manager (ACM) wildcard Certificate in
us-east-1AWS region:*.{your_domain} - Google OAuth Client - Create a Google OAuth 2.0 Client ID from Google Cloud Console
- Add authorized JavaScript origins:
https://short.{your_domain} - No redirect URIs needed (uses Google Identity Services)
- Add authorized JavaScript origins:
- Route53 Hosted Zone - Your domain must be managed by AWS Route53
- Configure Parameters - Update the
Makefilewith your specific values
| Parameters | Default Value | Description |
|---|---|---|
| Product | url-shortener |
Product Name |
| Project | <yourProject> |
Project Name |
| Environment | prod |
Environment Name |
| MinChar | 3 |
Minimum characters for the random shortened link id |
| MaxChar | 4 |
Maximum characters for the random shortened link id |
| Domain | <yourDomain> |
Desired Domain (must be linked to the HostedZoneId Parameter) |
| SubDomain | NONE |
Subdomain for API (use NONE for root domain) |
| HostedZoneId | Required |
AWS Route53 HostedZoneId where your domain name belongs |
| FallbackUrl | <yourURL> |
When the url does not exist, fallback url |
| AWSRegion | eu-west-1 |
AWS Region |
| AlertsRecipient | Required |
Email of the recipient of CloudWatch Alarms |
| GoogleClientId | Required |
Google OAuth 2.0 Client ID for authentication |
# Deploy backend infrastructure (API Gateway, Lambda, DynamoDB)
$ make deploy # or make -f YourMakeFile deploy
# Build and deploy React frontend to S3/CloudFront
$ make setup_front # or make -f YourMakeFile setup_frontThe deployment will create:
- Backend API:
https://{Domain}/(orhttps://{SubDomain}.{Domain}/if SubDomain is set) - Frontend SPA:
https://short.{Domain}/
After deployment, navigate to https://short.{Domain} where you'll find a modern React application with:
- Authentication: Sign in with your Google account
- Create Short Links:
- Enter long URL
- Toggle human-readable option for memorable short IDs
- Set expiration (0-3650 days, 0 = never expires)
- Statistics Dashboard: View click analytics and weekly statistics for your short links
Home page screenshot:
Creation section screenshot:
Statistics section screenshot:
Note: Only authorized Google accounts (configured in DynamoDB
userstable) can access the application.
Authentication Required: Include a valid Google ID token in the Authorization header.
curl -X POST https://{domain}/create \
--header "Content-Type: application/json" \
--header "Authorization: Bearer {your_google_id_token}" \
-d '{"long_url": "https://google.com"}'Optional parameters:
ttl_in_days(integer, default: 7): Set expiration in days (0 = never expires)human_readable(boolean, default: false): Generate memorable consonant/vowel combinations
Example with all options:
curl -X POST https://{domain}/create \
--header "Content-Type: application/json" \
--header "Authorization: Bearer {your_google_id_token}" \
-d '{
"long_url": "https://google.com",
"ttl_in_days": 365,
"human_readable": true
}'Response:
{
"short_id": "baho",
"created_at": "2024-08-24T15:28:04",
"ttl": 1724772484,
"short_url": "https://{domain}/baho",
"long_url": "https://google.com"
}curl -X GET https://{domain}/stats/{short_id} \
--header "Authorization: Bearer {your_google_id_token}"Response:
{
"short_id": "baho",
"long_url": "https://google.com",
"short_url": "https://{domain}/baho",
"created_at": "2024-08-24T15:28:04",
"total_hits": 42,
"weekly_stats": [
{ "week": "2024-W34", "clicks": 15 },
{ "week": "2024-W35", "clicks": 27 }
]
}Note: Generated short IDs are lowercase to avoid confusion.
To authorize users to access the application:
-
Add authorized email addresses to the DynamoDB
userstable:aws dynamodb put-item \ --table-name users \ --item '{"email": {"S": "user@example.com"}}' -
Or use the AWS Console:
- Navigate to DynamoDB → Tables →
users - Create item with
emailattribute
- Navigate to DynamoDB → Tables →
The application follows a serverless SPA architecture:
- Frontend: React SPA hosted on S3/CloudFront
- Authentication: Google Identity Services (client-side)
- API: API Gateway with Lambda Authorizer validating Google ID tokens
- Backend: Python Lambda functions
- Database: DynamoDB for URLs, stats, and authorized users
For detailed architecture documentation, see docs/ARCHITECTURE.md
- Original implementation inspired by zoph-io/url-shortener
- Frontend redesign with React and OAuth integration (v2.0.0) and the help of Anthropic Claude
MIT License - see LICENSE file for details



