A full-stack URL shortener built in Go, featuring real-time analytics, MongoDB integration, and a Chrome Extension interface.
- 🔗 Shorten long URLs using a clean hash-based method
- 🌍 Real-time analytics (IP, browser, user agent)
- 📦 Persistent storage using MongoDB
- 🧩 Chrome Extension integration
- 🛡️ CORS-safe for frontend access
- 🧪 RESTful API with JSON support
url-shortener/
├── cmd/ # Entry point (main.go)
├── handler/ # HTTP handlers
├── service/ # Business logic
├── store/ # MongoDB operations
├── models/ # Data models
├── utils/ # Utility functions (hashing)
├── chrome-extension/ # Manifest, popup.html, popup.js
└── .env # MongoDB URIPrerequisites Go 1.21+
MongoDB URI (use MongoDB Atlas or local MongoDB)
git clone https://github.com/yourusername/url-shortener.git
cd url-shortener
MONGO_URI=mongodb+srv://<user>:<password>@cluster.mongodb.net/?retryWrites=true
go run cmd/main.go
POST /shorten — Pass JSON { "url": "https://example.com" }
GET /redirect/:id — Redirect to original
GET /analytics/:id — Get visit logs
Setup
-
Open Chrome → chrome://extensions
-
Enable Developer Mode
-
Click Load Unpacked → select chrome-extension/ folder
Usage
-
Paste long URL
-
Click Shorten → auto-copies the short URL
-
Go (Golang)
-
MongoDB
-
Chrome Extension (Frontend)

