Skip to content

pramilaOM/FullStackURLShortenerApp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

7 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Linklytics: Full-Stack URL Shortener App ๐Ÿš€๐Ÿ”—โœจ

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. ๐Ÿง ๐Ÿ’ก๐Ÿ’ป


โœจ Live Demo ๐Ÿš€๐ŸŒ๐Ÿ”ง


๐Ÿ“„ Project Overview ๐Ÿ’ผ๐Ÿ“š๐Ÿงฉ

This project is split into two major components: ๐ŸŽฏ๐Ÿ› ๏ธ๐Ÿšง

1. Frontend

  • Framework: React.js (Vite setup)
  • Styling: Tailwind CSS
  • Routing: React Router
  • Animations: Framer Motion
  • State Management: React Context API

2. Backend

  • 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

๐Ÿš€ Features ๐Ÿ”โšก๐Ÿ“Š

  • 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

๐Ÿงฑ Project Structure ๐Ÿ—๏ธ๐Ÿ“๐Ÿงญ

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

โš™๏ธ Environment Setup ๐Ÿงช๐Ÿ› ๏ธ๐Ÿ”

1. Frontend Configuration

Create a .env file inside the client folder:

VITE_BACKEND_URL=https://url-shortener-sb-5mgd.onrender.com

2. Backend Configuration

Set 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.app

Set these environment variables on Render:

  • DATABASE_URL
  • DATABASE_USERNAME
  • DATABASE_PASSWORD
  • JWT_SECRET
  • FRONTEND_URL

๐Ÿšซ Prerequisites (Locally) ๐Ÿ–ฅ๏ธ๐Ÿ“ฆ๐Ÿ”ง

  • Node.js and npm
  • Java 17 or above
  • Maven
  • Docker (for container build)

๐Ÿšœ Deployment Steps ๐Ÿšข๐Ÿ› ๏ธ๐Ÿ”

๐Ÿ“ Frontend on Netlify ๐Ÿง‘โ€๐Ÿ’ป๐Ÿ“ฆ๐ŸŒ

  1. Go to Netlify

  2. Create a new site from Git repo or drag-and-drop build folder.

  3. Add environment variable:

    • VITE_BACKEND_URL=https://url-shortener-sb-5mgd.onrender.com
  4. Set build command: npm run build

  5. Publish directory: dist

  6. Deploy

โ›…๏ธ Backend on Render ๐Ÿ”ง๐Ÿงณ๐Ÿ–ฅ๏ธ

  1. Go to Render

  2. Create new Web Service:

    • Language: Java
    • Build Command: ./mvnw clean install
    • Start Command: java -jar target/your-jar-file.jar
  3. Add environment variables as above

  4. Use PostgreSQL connection string from Neon

  5. Deploy

๐Ÿ“Š PostgreSQL on Neon.tech ๐Ÿง ๐Ÿ—ƒ๏ธ๐Ÿ’พ

  1. Sign up at https://neon.tech
  2. Create new project and branch
  3. Copy the PostgreSQL URL for use in backend
  4. Create tables automatically via Spring JPA

๐Ÿ›‚ Docker Image (Optional) ๐Ÿณ๐Ÿ“ฆ๐Ÿ“ค

  1. Build image:
docker build -t pramilayadav/url-shortener-sb .
  1. Push to DockerHub:
docker push pramilayadav/url-shortener-sb
  1. 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 -a

โœ‰๏ธ How to Run Locally ๐Ÿก๐Ÿงชโš™๏ธ

1. Clone Repository

git clone https://github.com/<your-username>/url-shortener-project.git
cd url-shortener-project

2. Run Backend

cd server
./mvnw spring-boot:run

3. Run Frontend

cd client
npm install
npm run dev

๐Ÿšฎ API Endpoints Summary ๐Ÿ”๐ŸŒ๐Ÿงพ

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

๐Ÿ’ช Screenshots ๐Ÿ–ผ๏ธ๐Ÿ“ธ๐Ÿงพ

Login Page

image

SignUp

image

Dashboard

image image

Create new shorted url

image image

Home image

About image


๐ŸŒ Live Demo

https://graceful-pithivier-bee131.netlify.app/


๐Ÿ‘ค Author ๐Ÿ‘ฉโ€๐Ÿ’ป๐Ÿ“๐Ÿ’ผ

Pramila Yadav


๐Ÿ“š License ๐Ÿ“„โš–๏ธ๐Ÿ†“

This project is licensed under the MIT License. Free for commercial and personal use. ๐Ÿ’ผ๐ŸŒ๐Ÿ”“

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages