Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
HELP.md
.gradle
build/
!gradle/wrapper/gradle-wrapper.jar
!**/src/main/**/build/
!**/src/test/**/build/

### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
bin/
!**/src/main/**/bin/
!**/src/test/**/bin/

### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr
out/
!**/src/main/**/out/
!**/src/test/**/out/

### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/

### VS Code ###
.vscode/
78 changes: 38 additions & 40 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,41 +1,39 @@
# springboot-url-shortener
SprintBoot URL Shortener 구현 미션 Repository 입니다.

## 요구사항
각 요구사항을 모두 충족할 수 있도록 노력해봅시다.
- [ ] URL 입력폼 제공 및 결과 출력
- [ ] URL Shortening Key는 8 Character 이내로 생성
- [ ] 단축된 URL 요청시 원래 URL로 리다이렉트
- [ ] 단축된 URL에 대한 요청 수 정보저장 (optional)
- [ ] Shortening Key를 생성하는 알고리즘 2개 이상 제공하며 애플리케이션 실행중 동적으로 변경 가능 (optional)


## Short URL Service
### 읽으면 좋은 레퍼런스
- [Naver 단축 URL API](https://developers.naver.com/docs/utils/shortenurl/)
- [짧게 줄인 URL의 실제 URL 확인 원리 및 방법](https://metalkin.tistory.com/50)
- [짧게 줄인 URL 알고리즘 고찰](https://metalkin.tistory.com/53)
- [단축 URL 원리 및 개발](https://blog.siyeol.com/26)

### Short URL의 동작 과정
예시로 bitly를 봅시다
![image1](./image1.png)
![image2](./image2.png)
1. 원본 URL을 입력하고 Shorten 버튼을 클릭합니다.
2. Unique Key를 7문자 생성합니다.
3. Unique Key와 원본 URL을 DB에 저장합니다.
4. bitly.com/{Unique Key} 로 접근하면, DB를 조회하여 원본 URL로 redirect합니다.

### Short URL의 특징
단축 URL서비스는 간편하지만, 단점(위험성)이 있습니다.
링크를 클릭하는 사용자는 단축된 URL만 보고 클릭하기 때문에 어떤 곳으로 이동할지 알 수 없습니다.

- Short URL 서비스는 주로 요청을 Redirect 시킵니다. (Redirect와 Forward의 차이점에 대해 검색해보세요.)
- 긴 URL을 짧은 URL로 압축할 수 있다.
- short url만으로는 어디에 연결되어있는 지 알 수 없다. 때문에 피싱 사이트 등의 보안에 취약하다.
- 광고를 본 뒤에 원본url로 넘겨주기도 한다. 이 과정에서 악성 광고가 나올 수 있다.
- 당연하지만 이미 존재하는 키를 입력하여 들어오는 사람이 존재할 수 있다.
- 기존의 원본 URL 변경되었더라도 단축 URL을 유지하여, 혼란을 방지할 수 있다.

### 예시 사이트
[https://url.kr/](https://url.kr/)
<!--
템플릿은 아직 PR 작성이 익숙하지 않으신 분들을 위해서 제공하는 가이드입니다!
리뷰어 또는 이 PR을 보게 될 다른 사람들이 이 PR을 보는데 참고할 수 있는 내용이 있다면 포함해서 작성해주시면 됩니다.
-->


사용자가 입력한 url에 대해 더 짧은 형태인 단축 url을 제공하는 서비스 입니다



- URL 입력폼 제공 및 결과
- URL Shortening Key는 8 Character 이내로 생성
- 단축된 URL 요청시 원래 URL로 리다이렉트
- 단축된 URL에 대한 요청 수 정보저장
- Shortening Key를 생성하는 알고리즘 2개 이상 제공하며 애플리케이션 실행중 동적으로 변경 가능
- (1) Base62
- (2) 인덱스 번호 자체를 활용
- IP 별 요청 횟수 제한 : Rate Limit Algorithm(Bucket4j) 사용
- 배포 :~~https://shortenworld.kro.kr~~

https://github.com/prgrms-be-devcourse/springboot-url-shortener/assets/49016275/ee090c94-0845-46f3-a5ab-d3b8b652b9a0



- 초기 화면
<img width="400" alt="Screenshot 2023-10-09 at 2 53 20 AM" src="https://github.com/prgrms-be-devcourse/springboot-url-shortener/assets/49016275/766f2c13-1f2e-421d-80ce-bb8b26f383b6">

- 링크 단축하기 / 통계 버튼 클릭시
<img width="400" alt="Screenshot 2023-10-09 at 2 53 39 AM" src="https://github.com/prgrms-be-devcourse/springboot-url-shortener/assets/49016275/081437bc-dea4-4264-bf44-6df0a44deb6f">
<img width="400" alt="Screenshot 2023-10-09 at 2 53 47 AM" src="https://github.com/prgrms-be-devcourse/springboot-url-shortener/assets/49016275/c7151b3e-4c8b-4688-a064-f740f8a6e8be">

- 유효하지 않은 단축 url로 접속한 경우
<img width="400" alt="Screenshot 2023-10-09 at 11 13 27 PM" src="https://github.com/prgrms-be-devcourse/springboot-url-shortener/assets/49016275/f711bd00-569b-4196-9038-e8ee1b7d6b63">


- 같은 IP로 너무 많은 요청을 보낸 경우
<img width="400" alt="Screenshot 2023-10-09 at 10 56 30 PM" src="https://github.com/prgrms-be-devcourse/springboot-url-shortener/assets/49016275/f3c379d3-2eb3-4c6a-b698-31c2638a619c">

41 changes: 41 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
plugins {
id 'java'
id 'org.springframework.boot' version '3.1.4'
id 'io.spring.dependency-management' version '1.1.3'
}

group = 'com.seungwon'
version = '0.0.1-SNAPSHOT'

java {
sourceCompatibility = '17'
}

configurations {
compileOnly {
extendsFrom annotationProcessor
}
}

repositories {
mavenCentral()
}

dependencies {
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-validation'
compileOnly 'org.projectlombok:lombok'
developmentOnly 'org.springframework.boot:spring-boot-devtools'
runtimeOnly 'com.h2database:h2'
annotationProcessor 'org.projectlombok:lombok'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
implementation 'commons-codec:commons-codec:1.9'
implementation 'commons-validator:commons-validator:1.7'
implementation 'com.github.vladimir-bukhtoyarov:bucket4j-core:7.1.0'
}

tasks.named('test') {
useJUnitPlatform()
}
Binary file added gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
7 changes: 7 additions & 0 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2.1-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading