A full-stack URL shortener built with Go, React, PostgreSQL, and Supabase. The application allows users to create short URLs, redirect using short codes, update existing mappings, delete mappings, and retrieve URL statistics.
- Create short URLs from long URLs
- Redirect users using short codes
- Update existing URL mappings
- Delete URL mappings
- Retrieve URL statistics
- React
- Vite
- Tailwind CSS
- JavaScript
- Go
- Chi Router
- pgx PostgreSQL Driver
- PostgreSQL
- Supabase
- Render (Backend)
- Vercel (Frontend)
┌─────────────┐ REST API ┌─────────────┐ PostgreSQL ┌─────────────┐
│ React (UI) │ ────────────────► │ Go Backend │ ───────────────────► │ Supabase │
└─────────────┘ └─────────────┘ └─────────────┘
User enters URL
│
▼
React Frontend
│
POST /shorten
│
▼
Go Backend
│
Generate Short Code
│
Store in PostgreSQL
│
▼
Return Short Code
│
▼
Display Short URL
User visits /{shortcode}
│
▼
Go Backend
│
Lookup URL in Database
│
▼
HTTP Redirect
│
▼
Original Website
url_shortener/
│
├── backend/
│ ├── main.go
│ ├── routes.go
│ ├── handlers.go
│ ├── database.go
│ ├── config.go
│ ├── models.go
│ ├── utils.go
│ ├── go.mod
│ └── go.sum
│
├── client/
│ ├── src/
│ │ ├── App.jsx
│ │ ├── main.jsx
│ ├── package.json
│ ├── vite.config.js
│ └── index.html
│
└── README.md
Application entry point.
Responsibilities:
- Load configuration
- Connect to database
- Initialize routes
- Start HTTP server
Handles application configuration.
Responsibilities:
- Read environment variables
- Provide configuration values
Responsible for database connection and queries.
Responsibilities:
- Establish PostgreSQL connection
- Store global database instance
- Execute database operations
Contains HTTP request handlers.
Responsibilities:
- Parse incoming requests
- Validate data
- Call database functions
- Return JSON responses
Responsible for API route registration.
Responsibilities:
- Configure router
- Register endpoints
- Configure middleware
Contains helper functions.
Responsibilities:
- Generate random short codes
- Reusable utility logic
DATABASE_URL=your_postgresql_connection_string
PORT=8000git clone https://github.com/Sri-Varshith/url_shortener.git
cd url_shortenercd backend
go mod download
go run .Server starts on:
http://localhost:8000
cd client
npm install
npm run devFrontend starts on:
http://localhost:5173
- Custom short codes
- URL analytics dashboard
- Authentication
- Rate limiting
- QR code generation
- Custom domains
- Expiring URLs
- Improved statistics and tracking