API serviceeasy

URL shortener with click analytics

An HTTP service that shortens URLs, redirects, and reports click statistics per day.

Suggested effort
~3h focused work
Window
24 hours
Starts from
An empty repo
Stack
Your choice
Sign in to start this build →

Opens in a new tab. The clock starts when you press Start inside the environment, not before, and your workspace is kept while you step away.

Time window 24 hours. Suggested effort about 3 hours.

Context

The marketing team pastes long campaign URLs into chat all day. Build them a small URL shortener service with an HTTP API, redirects, and basic click statistics.

Core requirements

  • POST /api/links with { "url": "...", "alias": "..." } (alias optional) creates a short code (random, 6 to 8 URL-safe characters) or uses the custom alias. Returns the short URL and code.
  • GET /:code redirects (HTTP 302) to the original URL and records a click (timestamp, referrer, user agent).
  • GET /api/links/:code/stats returns total clicks and clicks per day for the last 7 days.
  • DELETE /api/links/:code removes a link; its code then returns 404.
  • Persistence that survives a restart (SQLite recommended).

Acceptance criteria

  • Only http and https URLs are accepted; anything else (for example javascript:) gets a 400 with a JSON error body.
  • Custom aliases are validated ([A-Za-z0-9_-]{3,32}) and a taken alias gets a 409.
  • Code collisions are handled, not assumed impossible.
  • A failure to record a click never breaks the redirect.
  • Tests exercise the API end to end (create, redirect, stats, delete, and the error cases).

Stretch goals (optional)

  • Optional expiry (expires_at) after which the link returns 410 Gone.
  • A minimal web page to create links and view stats.
  • Per-IP rate limit on link creation.
  • QR code endpoint for a link.

Constraints

  • Any language and framework. Suggested: Node (Express/Fastify), Python (FastAPI/Flask) or Go (net/http).
  • No external services; everything runs locally.

Deliverables (every project)

  • Source code committed in this repository (the grader diffs against the first commit).
  • README.md that replaces the stub, with: how to install, run and test it (copy-pasteable commands); the decisions and trade-offs you made; what you would do next with more time; and a short note on how you used the AI agent (what you delegated, what you checked or rewrote).
  • Automated tests that run with a single command (npm test, pytest, go test ./... or cargo test).
  • No secrets in the repository. Anything configurable reads from environment variables with safe defaults.

Ground rules

  • The 24-hour clock is a window, not a workload. Stop at roughly the suggested effort, then write down what you would do next. A small, finished, tested core beats a large unfinished one.
  • Use the AI agent as much or as little as you like: every prompt is recorded and the report shows how it was used. You are judged on the result and on whether you understood and verified what the agent produced.
  • The work is yours. PraxisAI uses it only to produce your assessment report.
URL shortener with click analytics: a 24-hour take-home project | PraxisAI