Skip to content

About

πŸ”— Shortly β€” React frontend for a full-stack URL shortener: JWT accounts, link dashboard, click analytics and a one-click demo login. Live on Vercel.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

Β 

History

17 Commits

Folders and files

Repository files navigation

πŸ”— Shortly

Shorten links. Manage them. Track every click.

A full-stack URL shortener with JWT accounts, a link-management dashboard and per-link click analytics. This repo is the React frontend; the REST API lives in url-shortener-api.

Live app API docs Backend repo

React Vite React Router Axios License: MIT

πŸš€ Recruiters & reviewers: click Try Demo β€” one click, no sign-up

Or log in manually with demo@urlshortener.dev / demo1234

Walkthrough: demo login, creating a short link, viewing analytics

⏳ The backend runs on Render's free tier. A keep-alive job pings it every 14 minutes, so it's normally awake; if it isn't, the app shows a "waking up" notice and the first request can take up to a minute.


✨ Features

πŸ”— Shorten links Random 7-character codes, or your own custom alias (3–20 characters)
πŸ“‹ Dashboard Search, sort by date / clicks / URL, filter by minimum clicks, pagination, live totals
✏️ Edit & delete Change a link's destination or alias; delete with a confirmation dialog
πŸ“Š Analytics Lifetime clicks, clicks per day, a click-event log, and date-range filtering
πŸ” Accounts Register / log in with JWT; every user only ever sees their own links
πŸš€ One-click demo A shared demo account with sample links β€” visible from the navbar, home, login and register pages
πŸ›Ÿ Resilient UX "Waking up" notice for cold starts, clear errors when the API is unreachable, toast on expired sessions, no accidental logouts on slow networks
πŸ“± Responsive Works on phones and desktops

πŸ–ΌοΈ Screenshots

Home β€” shorten a link or jump into the demo
Home page
Login β€” the demo is the first thing you see
Login page with demo button
Dashboard β€” all your links, clicks and actions
Dashboard
Analytics β€” clicks per day and the event log
Analytics page
Edit a link β€” new destination or alias
Edit link dialog
Mobile
Mobile home and dashboard

🧩 Architecture

flowchart LR
    user["πŸ‘€ Visitor"] -->|"uses"| web["βš›οΈ Shortly frontend<br/>React + Vite Β· Vercel"]
    web -->|"HTTPS · JSON · JWT"| api["🟒 REST API<br/>Node.js + Express · Render"]
    clicker["πŸ”— Anyone opening a short link"] -->|"GET /:code"| api
    api -->|"302 redirect + click recorded"| clicker
    api --> db[("πŸƒ MongoDB Atlas<br/>users Β· urls Β· clicks")]
    cron["⏰ GitHub Actions keep-alive<br/>every 14 min"] -.->|"GET /health/db"| api
Loading
Part Repo Hosting
Frontend (this repo) url-shortener-frontend Vercel
REST API url-shortener-api Render (free tier) + MongoDB Atlas
Click analytics pipeline (Kafka β†’ ClickHouse) clickstream-pipeline Docker / Codespaces
First version (Express + Redis cache) url-shortener β€”

🧠 How it works

  • Auth: the JWT is kept in localStorage; an Axios request interceptor adds Authorization: Bearer … to every call, and a response interceptor turns any 401 into a clean logout plus a "session expired" toast.
  • Protected routes: /dashboard and /analytics/:code redirect to /login (remembering where you were going); the login page offers the one-click demo, so nobody gets stuck.
  • Session restore: on load the app calls GET /api/auth/me. Only a real 401 clears the session β€” a timeout while the free server wakes up keeps you signed in.
  • Demo account: POST /api/auth/demo returns a token for a shared account. The API keeps it to its newest 20 links and re-creates sample links if it's ever emptied.

πŸ› οΈ Tech stack

React 19 Β· Vite 8 Β· React Router 7 Β· Axios Β· lucide-react icons Β· a hand-written CSS design system (no UI framework) Β· ESLint Β· Vercel

πŸš€ Run locally

git clone https://github.com/ARYAN10227/url-shortener-frontend.git
cd url-shortener-frontend
npm install
cp .env.example .env       # set VITE_API_URL=http://localhost:3000 to use a local API
npm run dev                # β†’ http://localhost:5173
Script What it does
npm run dev Dev server with hot reload
npm run build Production build into dist/
npm run preview Serve the production build locally
npm run lint ESLint
Variable Default Purpose
VITE_API_URL https://url-shortener-api-h1dj.onrender.com Base URL of the REST API

πŸ“ Project structure

src/
β”œβ”€β”€ pages/        Landing, Login, Register, Dashboard, Analytics
β”œβ”€β”€ components/   Navbar, Footer, Edit/Delete/Analytics modals, DemoLoginButton,
β”‚                 ServerWakeNotice, ProtectedRoute, Toast
β”œβ”€β”€ context/      AuthProvider (session, login, demo, logout), ToastProvider
β”œβ”€β”€ services/     api.js β€” Axios client, token storage, every API call
└── index.css     Design tokens and components

🌐 Deployment

  • Hosted on Vercel; every push to main deploys automatically, and pull requests get preview URLs.
  • vercel.json rewrites every path to index.html, so client-side routes survive a page refresh.
  • Deployment Protection is off for production β€” otherwise visitors are sent to a Vercel login page.

πŸ‘‹ Built by Aryan Raj

GitHub LinkedIn Email

⭐ If you like this project, consider giving it a star!

About

πŸ”— Shortly β€” React frontend for a full-stack URL shortener: JWT accounts, link dashboard, click analytics and a one-click demo login. Live on Vercel.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Contributors

Languages