https://github.com/marceloxhenrique/url-shortener
A Spring Boot URL shortening service that generates secure, random short URLs from long URLs.
https://github.com/marceloxhenrique/url-shortener
java postgresql spring-boot
Last synced: 5 months ago
JSON representation
A Spring Boot URL shortening service that generates secure, random short URLs from long URLs.
- Host: GitHub
- URL: https://github.com/marceloxhenrique/url-shortener
- Owner: marceloxhenrique
- Created: 2025-11-02T18:58:07.000Z (8 months ago)
- Default Branch: main
- Last Pushed: 2025-11-26T22:47:27.000Z (7 months ago)
- Last Synced: 2025-11-29T17:52:06.583Z (7 months ago)
- Topics: java, postgresql, spring-boot
- Language: Java
- Homepage:
- Size: 24.4 KB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# ShortURL App
A simple URL shortening service built with **Spring Boot**. Generate short URLs from long URLs safely and efficiently.
---
## Features
- Create short URLs using random Base62 codes
---
## Tech Stack
- Java 17+
- Spring Boot
- Spring Data JPA
- PostgreSQL
- Maven
---
## Getting Started
### Prerequisites
- Java 17+
- Maven
- Git
- PostgreSQL
- Docker
### Run Locally
#### 1. Clone the repository:
```bash
git clone https://github.com/marceloxhenrique/url-shortener.git
```
#### 2. Navigate to the project directory
```bash
cd url-shortener
```
#### 3. Install the project
```bash
mvn clean install
```
#### 4. Create .env file with environment variables
```bash
POSTGRES_USER=youruser
POSTGRES_PASSWORD=yourpassword
POSTGRES_DATA_SOURCE=jdbc:postgresql://localhost:5433/urlshortener
URL_BASE=http://localhost:8080
POSTGRES_DB=urlshortener
```
#### 4.1 Run PostgreSQL using Docker (optional)
Start the database:
```bash
docker-compose up -d
```
This will start a PostgreSQL container with the environment variables defined in your .env file.
The database will be available at: localhost:5433
#### 5 Setup application.properties
```bash
spring.application.name=urlshortener
spring.sql.init.platform=postgres
spring.datasource.username=${POSTGRES_USER}
spring.datasource.password=${POSTGRES_PASSWORD}
spring.datasource.url=${POSTGRES_DATA_SOURCE}
url.base=${URL_BASE}
spring.jpa.hibernate.ddl-auto=update
spring.jpa.properties.hibernate.jdbc.lob.non_contextual_creation=true
```
#### 6. Running the application
```bash
mvn spring-boot:run
```