Blog
Thoughts on engineering, design, and building great products.
WebSocket API: Pushing Click Counts to a Realtime Dashboard
Build the realtime part of the dashboard. Stand up an API Gateway WebSocket API with $connect and $disconnect routes, store each connection in DynamoDB tied to the link it watches, then have the aggregator push the new click count down to exactly the open connections each time it finishes counting. Open a real connection, click the link, and watch the number jump to the browser with no reload.
Counting Clicks Safely: Idempotency, DLQ, and Partial Batch Failure
Turn the logging consumer from the previous article into a real aggregator. Insert SQS between EventBridge and Lambda for batching, retry, and a dead-letter queue, count clicks into DynamoDB with a transaction that both increments counters and prevents double-counting in one atomic operation, and report failures per message so only the broken one is retried. Real tests: a duplicate event counts once, a failing event lands in the DLQ.
EventBridge: Decoupling Click Recording from the Redirect Path
Opening the event-driven part. Instead of counting clicks right inside the redirect handler, every link open publishes an event onto a custom EventBridge event bus, and a separate consumer handles it. Build the bus, have resolve publish the event, attach a consumer via an event pattern, then open a real link to watch the event flow through the bus to the consumer.
Multi-Tenant: Each User Their Own Data Slice, and Blocking IDOR
Turn the URL shortener into a true multi-tenant system. Add a list-links route scoped to the identity in the token, and a delete-link route that checks ownership inside the write operation so one user can't delete another's link even if they guess the code right. Tested with two real users to see the boundary hold.
Cognito and JWT Authorizer: Only Logged-In Users Can Create Links
Add real users with Amazon Cognito. Stand up a user pool that issues JWTs, attach the HTTP API's JWT authorizer to protect the create-link route while the open-link route stays public, and have the handler read the user identity from a claim in the token instead of hard-coding it. Create a real user, get a real token, call the API with and without a token to see the boundary.
Wiring DynamoDB Into Code: Safe Writes and Atomic Counter
Wire the two handlers into the real DynamoDB: create-link writes an item with a conditional write so it never overwrites a duplicate code, resolve-link does a lookup then counts clicks with an atomic counter. Fire many opens in parallel to see the atomic counter count exactly, and hit a real account limit — Lambda concurrency — when 40 of 50 requests come back 503.
Global Secondary Index and Sparse Index: Opening a New Query Path
The single-table from the previous article answers 'open a link by code' fast, but is helpless at 'list a user's links'. This article adds a global secondary index to invert the key and open exactly that query path, then uses a sparse index so the index holds only links and naturally drops the stat records. Create a real GSI, run a real query to see the mechanics.