Standard URL shorteners lack security controls, expose private redirects to scraping, and lack programmatic lifecycle and one-time deactivation rules.
02 / Engineering & BA Role
Full-Stack Software Engineer (Sole Developer)
03 / Outcome
Redirects check the stored expiry date and deactivate single-use links after their first visit.
Overview
NanoLink is a URL shortening application that lets users create short links with optional custom aliases, password protection, expiration and one-time use. The application also records click counts and link activity.
What I built
Engineered REST API routes in Next.js App Router with Zod schema validation, Prisma ORM transactions, and conditional redirect resolution.
Product Interface
nanl.vercel.app
Live
Engineering Decisions
Validate link requests
What
The create-link API checks the submitted URL and options.
Why
Invalid input should return a useful error before a link is saved.
How
The route validates the request, normalizes the URL and checks it before creating the record.
Keep identifiers unique
What
Short codes and custom aliases have database uniqueness constraints.
Why
A short link must identify one destination.
How
The API checks existing codes and PostgreSQL also enforces unique values.
Apply link rules
What
Links can require a password, expire or allow one use.
Why
The person sharing a link needs control over how it is opened.
How
The redirect workflow checks the stored options. One-time links become inactive after use.
Record link activity
What
A link stores its click count and last visit.
Why
The owner can see whether the link is being used.
How
The application updates the link record when handling a visit.
Data Architecture & Schema
The PostgreSQL Link model stores the original URL, short code, optional alias, password hash, expiry, activity status and click information. Short codes and custom aliases are unique. This keeps link options together with the destination they control.
originalUrl
Destination URL
shortCode
Unique short identifier
customAlias
Optional, unique alias
password
Optional password hash
expiresAt
Optional expiry date
oneTimeUse
Single-use setting
clicks
Visit count
lastVisited
Last visit time
isActive
Whether the link is active
API & System Workflow
POST /api/links receives the URL and options, validates the request, checks the alias, hashes a supplied password and creates the link record. A successful creation returns the new link with HTTP 201. Invalid input returns an error response.
Request
Zod Validation
Application Logic
PostgreSQL
Response
End-to-end system lifecycle
Representative Implementation
API validation & persistence · Creating the Link record. Excerpt from the repository source.