A minimal full-stack URL shortener built for portfolio and interview purposes.
- 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
- 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)
- url-shortener/
- backend/
- frontend/
- README.md
- Any modern Linux/macOS/Windows environment
- Java 17 (OpenJDK 17)
- Node.js (recommended: latest LTS) and npm
On Linux you can install Java 17 with:
sudo apt update
sudo apt install -y default-jdk curl unzip git
java -versionFollow 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 -vRun locally (development)
Open two terminals.
Terminal A: run backend
cd backend
./mvnw spring-boot:runBackend will listen on:
http://localhost:8080
Terminal B: run frontend
cd frontend
npm install
npm run devFrontend 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/nIkv1qNExpected:
302 Found
Location: https://example.com
-
Storage is in-memory: restarting the backend will remove all generated links.
-
The project is intentionally minimal to stay within a short implementation time.
-
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
-
Backend: Java 17, Spring Boot, Maven
-
Frontend: React, TypeScript, Vite, Tailwind CSS