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/linkswith{ "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 /:coderedirects (HTTP 302) to the original URL and records a click (timestamp, referrer, user agent).GET /api/links/:code/statsreturns total clicks and clicks per day for the last 7 days.DELETE /api/links/:coderemoves a link; its code then returns 404.- Persistence that survives a restart (SQLite recommended).
Acceptance criteria
- Only
httpandhttpsURLs are accepted; anything else (for examplejavascript:) 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.mdthat 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 ./...orcargo 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.