Skip to content

About

An url shortener made with Java and React

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 

Repository files navigation

URL Shortener (Java Spring Boot + React)

A minimal full-stack URL shortener built for portfolio and interview purposes.

Features

Backend (Java, Spring Boot)

  • Create short links via REST API
  • Redirect short code to the original URL (HTTP 302)
  • URL validation (http/https only)
  • In-memory storage (no database) for fast setup and demo purposes
  • Basic error handling with JSON responses

Frontend (React, Vite, Tailwind)

  • Modern UI to create short links
  • Displays the generated short URL and code
  • Copy and open actions
  • Local history stored in browser localStorage
  • Dev proxy to the backend (no CORS setup needed during development)

Project structure

  • url-shortener/
  • backend/
  • frontend/
  • README.md

Requirements

  • Any modern Linux/macOS/Windows environment
  • Java 17 (OpenJDK 17)
  • Node.js (recommended: latest LTS) and npm

Setup

1) Backend setup (Java 17)

On Linux you can install Java 17 with:

sudo apt update
sudo apt install -y default-jdk curl unzip git
java -version

2) Node.js setup (recommended via nvm)

Follow the npm guidance to use a Node version manager, then install the latest LTS version.

Example with nvm:

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash

export NVM_DIR="$HOME/.nvm"
. "$NVM_DIR/nvm.sh"

nvm install --lts
node -v
npm -v

Run locally (development)

Open two terminals.

Terminal A: run backend

cd backend
./mvnw spring-boot:run

Backend will listen on:

http://localhost:8080

Terminal B: run frontend

cd frontend
npm install
npm run dev

Frontend will be available at the URL printed by Vite (usually):

http://localhost:5173

The frontend uses a Vite dev proxy to call the backend at http://localhost:8080.

API Create a short URL

Request:

POST /api/shorten

JSON body: { "url": "https://example.com" }

Example:

curl -i -X POST http://localhost:8080/api/shorten \
  -H "Content-Type: application/json" \
  -d '{"url":"https://example.com"}'

Response (example):

{
  "code": "nIkv1qN",
  "shortUrl": "http://localhost:8080/nIkv1qN"
}

Redirect to the original URL

Request:

GET /{code}

Example:

curl -i http://localhost:8080/nIkv1qN

Expected:

302 Found

Location: https://example.com

Notes and limitations

  • Storage is in-memory: restarting the backend will remove all generated links.

  • The project is intentionally minimal to stay within a short implementation time.

Suggested next steps for production readiness:

  • Persist data with PostgreSQL (or another database) via Spring Data JPA

  • Add rate limiting and abuse protection

  • Add observability (structured logs, metrics, health checks)

  • Add automated tests (unit + integration) and CI pipeline

  • Add configuration for base URL and environments

Tech stack

  • Backend: Java 17, Spring Boot, Maven

  • Frontend: React, TypeScript, Vite, Tailwind CSS

About

An url shortener made with Java and React

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages