Skip to content

Latest commit

Β 

History

History
174 lines (128 loc) Β· 2.81 KB

File metadata and controls

174 lines (128 loc) Β· 2.81 KB

πŸš€ Linkly – URL Shortener

A full-stack production-ready URL shortener built with Spring Boot, React, PostgreSQL, Docker, and JWT Authentication.

Live Demo: Frontend β†’ https://linksshort.netlify.app

Backend β†’ https://url-shortener-backend-latest.onrender.com

✨ Features

πŸ” JWT-based Authentication (Login / Register)

πŸ”— Shorten long URLs

πŸ“Š Click analytics tracking

πŸ‘€ User-based URL management

🐳 Dockerized backend

☁️ Cloud deployed (Render + Netlify)

πŸ›‘ Spring Security 6 with CORS configuration

πŸ—„ PostgreSQL (Neon Cloud Database)

πŸ— Tech Stack Backend

  • Java 18

  • Spring Boot 4

  • Spring Security

  • Spring Data JPA

  • PostgreSQL

  • JWT (io.jsonwebtoken)

  • Docker

Frontend

  • React (Vite)
  • Tailwind CSS
  • React libraries(@mui/material, @emotion/react and emotion/styled)
  • Data Handling(Axios, React Query, chart.js)
  • Utlity tools (day.js)

Deployment

  • DockerHub

  • Render (Backend)

  • Netlify (Frontend)

  • Neon (PostgreSQL)

πŸ“‚ Project Structure

linkly/
β”‚
β”œβ”€β”€ backend/
β”‚   β”œβ”€β”€ controller/
β”‚   β”œβ”€β”€ service/
β”‚   β”œβ”€β”€ repository/
β”‚   β”œβ”€β”€ entity/
β”‚   β”œβ”€β”€ security/
β”‚   β”œβ”€β”€ Dockerfile
β”‚   └── pom.xml
β”‚
β”œβ”€β”€ frontend/
β”‚   β”œβ”€β”€ components/
β”‚   β”œβ”€β”€ pages/
β”‚   β”œβ”€β”€ api/
β”‚   └── package.json

πŸ” Environment Variables

Backend requires these environment variables:

SPRING_DATASOURCE_URL=
SPRING_DATASOURCE_USERNAME=
SPRING_DATASOURCE_PASSWORD=
JWT_SECRET=
JWT_EXPIRATION=
FRONTEND_URL=

Frontend requires:

VITE_BACKEND_URL= https://url-shortener-backend-latest.onrender.com
VITE_REACT_FRONT_END_URL= https://linksshort.netlify.app

🐳 Run Backend with Docker

Build JAR:

mvn clean package -DskipTests

Build Docker image:

docker build -t url-shortener-backend .

Run container:

docker run -p 8080:8080 url-shortener-backend

πŸ’» Run Locally Backend

mvn spring-boot:run

Frontend

npm install
npm run dev

πŸ“Š API Endpoints Authentication

POST /api/auth/public/register
POST /api/auth/public/login

URL Operations

POST /api/urls/shorten
GET /api/urls
GET /api/urls/analytics/{shortUrl}

πŸ”₯ Deployment Architecture

React (Netlify)
        ↓
Spring Boot (Render - Dockerized)
        ↓
PostgreSQL (Neon Cloud)

πŸ›‘ Security

  • Stateless JWT authentication

  • Custom CORS configuration

  • Protected endpoints using Spring Security

  • Password hashing using BCrypt

πŸ“ˆ Future Improvements

  • Custom domain support

  • Refresh token implementation

  • Rate limiting

  • Redis caching for analytics

  • Swagger documentation

  • Custom error response handler

πŸ‘¨β€πŸ’» Author

Shubham Kumar

Full Stack developer | Java Backend Developer | Spring Boot Enthusiast

⭐ If You Like This Project

Give it a ⭐ on GitHub!