https://github.com/furkancelikk/url-shortener
URL Shortener
https://github.com/furkancelikk/url-shortener
docker-compose dockerfile exception-handling java javadoc maven mysql spring-boot unit-test url-shortener
Last synced: 4 months ago
JSON representation
URL Shortener
- Host: GitHub
- URL: https://github.com/furkancelikk/url-shortener
- Owner: furkancelikk
- License: mit
- Created: 2024-10-19T16:28:33.000Z (almost 2 years ago)
- Default Branch: master
- Last Pushed: 2024-11-08T17:15:36.000Z (over 1 year ago)
- Last Synced: 2025-06-03T14:26:57.950Z (about 1 year ago)
- Topics: docker-compose, dockerfile, exception-handling, java, javadoc, maven, mysql, spring-boot, unit-test, url-shortener
- Language: Java
- Homepage:
- Size: 39.1 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: Readme.md
- License: LICENSE
Awesome Lists containing this project
README
# URL Shortener
---
Table of Contents
* [About The Project](#about-the-project)
* [Built With](#built-with)
* [Installation](#installation)
* [Set up with Java](#set-up-with-java)
* [Set up with Docker](#setup-with-docker)
---
## About The Project
This project is a URL shortening application designed to make users'long URLs shorter and easier to remember.
Users can save their URLs along with an optional code. If a user does not provide a code,
the system will automatically generate a unique code.
Users can view these URLs using the saved code or access them directly.
---
## Built With
The following technologies, tools etc. have been used in this project:

---
## Installation
There are two different ways to set up the project.
### Set up with Java
> **Prerequisites**
>
> - **Java 17:** Java 17 must be installed on your local machine.
>
> - **Mysql:** You need to have a MySQL instance running on your local machine and create a schema named **url_shortener**.
1. Clone the repo
```shell
git clone https://github.com/furkancelikk/url-shortener.git
```
2. Change the directory
```shell
cd url-shortener
```
3. Pull the dependencies and build the JAR file.
```shell
mvnw clean install
```
4. Change the directory to the **target**
```shell
cd target
```
5. Start the project.
```shell
java -jar app.jar
```
You can access the project at port 8080.
**Note:** The following values are defined as environment variables in the project. If you want to customize these values, you can provide them as parameters when starting the project, as shown below:
| Variable Name | Default Value | Description |
|---------------|---------------|----------------------------|
| DB_HOST | localhost | MySQL host |
| DB_PORT | 3306 | MySQL port |
| SCHEMA_NAME | url | Project schema name |
| DB_USERNAME | root | MySQL username |
| DB_PASSWORD | root | MySQL password |
| CODE_LENGTH | 5 | Auto generated code length |
```shell
java -DCODE_LENGTH=10 -jar app.jar
```
### Setup with Docker
> **Prerequisites**
>
> - **Docker**: Docker must be installed on your local machine.
1. Clone the repo
```shell
git clone https://github.com/furkancelikk/url-shortener.git
```
2. Change the directory
```
cd url-shortener
```
3. Start the project. This command will pull the necessary dependencies, download MySQL as a container, and run the project.
```
docker compose up -d
```
You can access the project at port 8080.
**Note:** When starting the project with Docker, the following values are defined as environment variables. If you wish to customize these values, you can modify them in the [.env](.env) file.
| Variable Name | Value | Description |
|------------------------|---------------------|----------------------------|
| SERVICE_IMAGE_NAME | url-shortener | Project image name |
| SERVICE_CONTAINER_NAME | url-shortener | Project container name |
| SERVICE_PORT | 8080 | Project port |
| DB_CONTAINER_NAME | url-shortener-mysql | MySQL container name |
| DB_PORT | 3306 | MySQL port |
| DB_USERNAME | url-shortener | MySQL user name |
| DB_PASSWORD | p4ssword | MySQL password |
| DB_ROOT_PASSWORD | root | MySQL root password |
| SCHEMA_NAME | url-shortener | MySQL scheme name |
| CODE_LENGTH | 5 | Auto generated code length |
---
#### [](LICENSE)