ProjectsSeptember 29, 2026

Temporary URL shortener

Built with
  • Node.js
  • JavaScript
  • REST contracts
Temporary URL shortener: illustrated cover

System architecture

Component and data flow diagramCreate request to URL controller: Original URL. URL controller to JavaScript Map: Store alias. Open short link to Lookup handler: Short ID. Lookup handler to JavaScript Map: Read mapping. JavaScript Map to Expiry timer: Timed deletion.ONE NODE.JS PROCESS / VOLATILE STORAGEOriginal URLStore aliasShort IDRead mappingTimed deletionCreate requestPOST /api/urlURL controllerGenerate Nano IDJavaScript MapID → destinationOpen short linkGET /:hashLookup handlerResolve / 404Expiry timerDelete mapping
Swipe horizontally to inspect the diagram.A successful lookup redirects the browser to the original destination. Entries and timers live in one process; restarting it loses the links.
Long URLs are inconvenient to share, and some links only need to work for a limited time. The service creates an alias, resolves it back to the destination and removes the alias after a configured interval. Express mounts a router at /api/url. A POST request supplies the original URL. The controller generates an eight-character Nano ID, stores the mapping in a JavaScript Map and returns a short URL built from the request host. A timer deletes that mapping after the configured expiration interval. A GET request to the short-ID route looks up the Map and redirects the browser. A separate fetch route returns the original URL as JSON. Missing IDs return 404, and a health endpoint reports that the process is running. The Map removes the need for a database and keeps the example easy to run. That simplicity also defines its limits: restarting the process loses every link, and multiple server instances would each hold a different set of mappings. Expiry uses one timer per link. It demonstrates lifecycle management clearly, but timers are not a durable expiry mechanism. Deleting an alias also does not revoke access to its destination: someone who already knows the original URL can still visit it. The repository implements the short-link lifecycle without a persistent store. No throughput or deployment claims are made for this prototype. For a shared service, I would move mappings to a store with expiry support, validate allowed URL schemes, handle ID collisions explicitly and add rate limits. Absolute expiry checks during lookup would make the contract clearer than relying only on scheduled deletion.

Related projects

Let’s talk about the engineering

I’m open to software engineering roles across backend, platform, and data teams. Get in touch to discuss the architecture, trade-offs, or how this experience could help your team.
Get in touch