A production-ready full-stack application that allows users to shorten long URLs, monitor click analytics, and manage their personalized links using a responsive interface. ๐ง ๐ก๐ป
- Site: https://graceful-pithivier-bee131.netlify.app/
- Frontend: https://graceful-pithivier-bee131.netlify.app
- Backend API: https://url-shortener-sb-5mgd.onrender.com
This project is split into two major components: ๐ฏ๐ ๏ธ๐ง
- Framework: React.js (Vite setup)
- Styling: Tailwind CSS
- Routing: React Router
- Animations: Framer Motion
- State Management: React Context API
- Framework: Spring Boot (Java)
- Authentication: JWT-based auth (Spring Security)
- Database: PostgreSQL hosted on Neon.tech
- ORM: Spring Data JPA
- Hosting: Docker image deployed via Render
- User registration and login
- JWT token-based secured endpoints
- URL shortening with analytics
- Dashboard to manage links (copy, track clicks, delete)
- Click analytics displayed as bar chart
- Dockerized backend with CI/CD-ready setup
url-shortener-project
โโโ client/ # React frontend
โ โโโ public/
โ โโโ src/
โ โโโ components/ # UI Components
โ โโโ pages/ # Views
โ โโโ services/ # Axios-based API calls
โ โโโ contextApi/ # Global store
โ โโโ App.jsx # Routing entry
โโโ server/ # Spring Boot backend
โ โโโ src/main/java/ # Application code
โ โโโ Dockerfile
โ โโโ application.properties
Create a .env file inside the client folder:
VITE_BACKEND_URL=https://url-shortener-sb-5mgd.onrender.comSet these properties in application.properties:
DATABASE_URL=jdbc:postgresql://<your-neon-url>/neondb
DATABASE_USERNAME=neondb_owner
DATABASE_PASSWORD=your_password
JWT_SECRET=generate_a_random_key
FRONTEND_URL=https://graceful-pithivier-bee131.netlify.appSet these environment variables on Render:
DATABASE_URLDATABASE_USERNAMEDATABASE_PASSWORDJWT_SECRETFRONTEND_URL
- Node.js and npm
- Java 17 or above
- Maven
- Docker (for container build)
-
Go to Netlify
-
Create a new site from Git repo or drag-and-drop build folder.
-
Add environment variable:
VITE_BACKEND_URL=https://url-shortener-sb-5mgd.onrender.com
-
Set build command:
npm run build -
Publish directory:
dist -
Deploy
-
Go to Render
-
Create new Web Service:
- Language: Java
- Build Command:
./mvnw clean install - Start Command:
java -jar target/your-jar-file.jar
-
Add environment variables as above
-
Use PostgreSQL connection string from Neon
-
Deploy
- Sign up at https://neon.tech
- Create new project and branch
- Copy the PostgreSQL URL for use in backend
- Create tables automatically via Spring JPA
- Build image:
docker build -t pramilayadav/url-shortener-sb .- Push to DockerHub:
docker push pramilayadav/url-shortener-sb- To set up environment variables and run inside container (Windows PowerShell):
$env:DATABASE_URL=
$env:DATABASE_USERNAME=
$env:DATABASE_PASSWORD=
$env:JWT_SECRET=
$env:FRONTEND_URL="http://localhost:5173"
$env:DATABASE_DIALECT="org.hibernate.dialect.PostgreSQLDialect"
./mvnw package
docker build -t url-shortener-sb .
docker tag url-shortener-sb pramilayadav/url-shortener-sb:latest
docker push pramilayadav/url-shortener-sb:latest
# Run interactively
docker run -it --rm url-shortener-sb bash
# Or persist
docker run -it url-shortener-sb bash
# View containers
docker ps
docker ps -agit clone https://github.com/<your-username>/url-shortener-project.git
cd url-shortener-projectcd server
./mvnw spring-boot:runcd client
npm install
npm run dev| Method | Endpoint | Description |
|---|---|---|
| POST | /api/auth/public/register | Register user |
| POST | /api/auth/public/login | Login + get JWT token |
| POST | /api/url | Shorten URL (auth) |
| GET | /api/url/my | Get user URLs (auth) |
| GET | /api/url/stats/{id} | Get stats per link |
| GET | /s/{shortUrl} | Redirect |
SignUp
Create new shorted url
Pramila Yadav
This project is licensed under the MIT License. Free for commercial and personal use. ๐ผ๐๐

