Build a URL shortener API with a simple analytics dashboard using Next.js 15 (App Router). Users can shorten URLs, get redirected, and view click counts. Dark-themed UI on port 4004.
package.json
tsconfig.json
next.config.js
tailwind.config.ts
postcss.config.js
src/lib/store.ts # In-memory Map: code -> { originalUrl, clicks, createdAt }
src/lib/types.ts # TypeScript interfaces: ShortenRequest, ShortenResponse, LinkStats
src/lib/utils.ts # generateCode() helper, URL validation
src/app/globals.css # Tailwind directives + dark theme
src/app/layout.tsx # Root layout with Inter font, dark class, metadata
src/app/page.tsx # Client component: form + stats table + auto-refresh
src/app/api/shorten/route.ts # POST handler: validate URL, generate code, store, return response
src/app/api/[code]/route.ts # GET handler: lookup code, increment clicks, 302 redirect or 404
src/app/api/stats/route.ts # GET handler: return all links with click counts
Overview
Build a URL shortener API with a simple analytics dashboard using Next.js 15 (App Router). Users can shorten URLs, get redirected, and view click counts. Dark-themed UI on port 4004.
Requirements
/with:File Structure
Dependencies
Design Specification
Acceptance Criteria
Edge Cases