HTTP API Gateway routes to three Lambda functions:
LinkHandlerFunctionfor create, metadata read, partial update, delete.RedirectFunctionfor public redirect and analytics increment.StatsFunctionfor summary and daily analytics read.
All functions use a single DynamoDB table: UrlShortenerTable.
PK(string)SK(string)
PK = LINK#{shortCode}SK = METADATA
Attributes:
originalUrlcreatedAt(ISO string)expiresAt(epoch seconds, used as DynamoDB TTL)passwordHash(optional, salted scrypt hash)clickCount(number)lastAccessedAt(ISO string, optional)entityType = LINK
PK = LINK#{shortCode}SK = STATS#{YYYY-MM-DD}
Attributes:
datecountentityType = DAILY_STATS
- Read link metadata by
PK + SK. - Create link with conditional write to prevent collisions.
- Partial updates using dynamic
UpdateExpression. - Increment clicks using atomic counter.
- Aggregate daily counts with
STATS#records. - Query daily stats via
begins_with(SK, "STATS#").
expiresAtis stored as epoch seconds.- DynamoDB TTL eventually purges expired items.
- Redirect checks expiration synchronously and returns
410 Goneimmediately.