A full-stack URL Shortener web application built using React (Vite) for the frontend and Spring Boot for the backend.
The application allows users to shorten long URLs into compact short links and redirect users back to the original URLs. It also tracks URL usage statistics such as click count.
- Shorten long URLs
- Generate unique short codes
- Redirect shortened URLs to original URLs
- Track click count statistics
- REST API based backend
- Responsive frontend UI
- Input validation and error handling
- Localhost development setup
- React
- Vite
- Axios
- CSS
- Spring Boot
- Spring Web
- Spring Data JPA
- Hibernate
- Maven
- H2 Database (Local Development)
URL-Shortener/
│
├── frontend/
│ ├── src/
│ ├── public/
│ ├── package.json
│ └── vite.config.js
│
├── backend/
│ ├── src/
│ ├── pom.xml
│ └── application.properties
│
└── README.md
POST /shorten{
"originalUrl": "https://example.com"
}{
"shortUrl": "http://localhost:8080/abc123",
"shortCode": "abc123"
}GET /{shortCode}Redirects to original URL.
GET /stats/{shortCode}{
"shortCode": "abc123",
"originalUrl": "https://example.com",
"clickCount": 5,
"shortUrl": "http://localhost:8080/abc123"
}Install:
- Node.js (v18 or above)
- Java 17
- Maven
- Git
Open terminal inside:
backend
Run:
mvn clean install
mvn spring-boot:runBackend runs on:
http://localhost:8080
Health check:
http://localhost:8080/health
Open terminal inside:
frontend
Install dependencies:
npm installRun frontend:
npm run devFrontend runs on:
http://localhost:5173
The application includes:
- Global exception handling
- URL validation
- Invalid short code handling
- Backend connectivity checks
Planned future improvements include:
- Deployment of frontend and backend to cloud platforms
- PostgreSQL integration for production database support
- User authentication and account management
- Custom short URL aliases
- URL expiration support
- Analytics dashboard
- QR code generation for shortened URLs
- Rate limiting and security enhancements
- Docker containerization
- CI/CD pipeline integration
- Current setup is optimized for localhost development.
- H2 database is currently used for local storage.
- Production deployment configuration will be added in future updates.
Kush Dani