β¨ A backend URL Shortener built using Golang + Gin + PostgreSQL, with Clerk authentication, rate limiting and clean routes.
- π URL Shortening
- π Redirect Handler
- π Clerk Auth Middleware
- π¦ PostgreSQL Storage
- β‘ Gin high-performance router
- π§© Signup webhook
- π§± Rate Limiting middleware
- π§ Modular structure
- 𦦠Golang (1.22+) β Fast, compiled, highly performant backend language
- πΏ Gin Framework β Lightweight, minimal & extremely fast HTTP router
- ποΈ PostgreSQL β Relational storage for persistent URL and user data
- π‘οΈ Clerk Authentication β Secure user auth + webhooks
Below are all available endpoints explained briefly π
-
GET
/health-check(Public)Checks if the server is healthy and running properly.
-
POST
/shorten(Private)Creates a short URL for the authenticated user.
Requires Clerk authentication & rate limiting.
-
GET
/:code(Public)Redirects to the original long URL based on the short code.
Returns404if the URL does not exist.
-
GET
/stats(Private)Returns paginated list of URLs owned by the authenticated user.
Useful for analytics / dashboard views.
-
DELETE
/:code(Private)Deletes a specific URL owned by the authenticated user.
-
POST
/webhook/signup(Public)Clerk signup webhook.
Triggers when a new user registers.
git clone https://github.com/LokeshXs/urlbit_url-shortener.git
cd urlbit_url-shortenergo mod tidy
cp .env.example .envPOSTGRES_URL=<your-postgres-url>
CLERK_SECRET_KEY=<your-clerk-secret-key>
go run main.go
If everything is setup correctly, you should now see the service running locally π
β¨ Why I built this
Because almost every product needs a clean and reliable short-link systemβand building this from scratch gives maximum control & full ownership instead of depending on third-party platforms π¨βπ»
Lokesh Singh
π Portfolio β https://lokesh-singh.vercel.app/