Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[STEP 1-3] url-shortener 기능 정의 #65

Open
wants to merge 2 commits into
base: MyLittleChicken
Choose a base branch
from
Open
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
70 changes: 70 additions & 0 deletions docs/step1/FunctionSpec.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# STEP 1-3
=========


url-shortener 기능 명세서 작성
--------

***

## 목차🧭

- [개요](#개요)
- [배경](#배경)
- [명세](#기능-명세서-)
- [1. url 단축](#1-url-단축)
- [2. url 조회](#2-url-조회)
- [제한사항](#제한사항)
- [참고할 만한 자료](#참고할-만한-자료-)
- [1. 밀러의 매직 넘버7 👈](#1-밀러의-매직-넘버-7-)
***

## 개요📜

>url-shortener 서비스의 기능을 정의하고 문서화 합니다.

***

## 배경🖼️

>버그를 수정하고, 서비스를 개선하려 했지만 기능이 정의된 명세서가 없습니다.
>명확한 기능 정의 없이 기능을 개발하거나 수정하게 되면 서비스는 엉망이 될거라 생각했습니다.

***

# 기능 명세서 📜

## 1. url 단축🔹
- ### 기능 개요
- 원본 url 을 단축된 url 로 변환하는 기능을 제공합니다.

- ### 기능 상세
- 클라이언트로부터 원본 url 을 입력받습니다.
- 입력받은 url 을 변환하여 단축 url(key) 를 생성합니다.
- 생성된 단축 url(key) 을 클라이언트에 반환합니다.


## 2. url 조회🔹
- ### 기능 개요
- 단축된 url(key) 를 원본 url 로 변환하는 기능을 제공합니다.

- ### 기능 상세
- 클라이언트로부터 단축 url 을 입력받습니다.
- 입력받은 단축 url(key) 를 통해 원본 url 을 조회합니다.
- 조회된 원본 url 을 클라이언트에 반환합니다.

***

# 제한사항🚫
## 1. 중복 제한
- 단축 url(key) 는 서비스 내에서 `고유`하며, 하나의 url 을 가르킵니다.

## 2. 길이 제한
- 단축 url(key) 는 `7자리` 의 길이로 표현합니다.
Copy link
Collaborator Author

@MyLittleChicken MyLittleChicken Mar 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

다음과 같은 내용을 고려했습니다.

  • base62 를 통해 encode 하는 경우 최대 약 3.5조(62^7) 까지의 숫자를 7자리의 문자로 표현 가능합니다.
  • epoch time (ms) 를 통해 key 를 생성하는 경우 약 2081년 까지 7자리의 문자로 표현 가능합니다.
  • ms 를 사용하므로 중복 제거를 통해 초당 최대 1000개의 고유한 key 생성이 가능할 것으로 예상됩니다.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

base62 를 통해 hashing 하는 경우 최대 약 3.5조(62^7) 까지의 숫자를 7자리의 문자로 표현 가능합니다.

  • encode vs hash vs encrypt

ms 변환을 통해 초당 최대 1000개의 고유한 key 생성이 가능할 것으로 예상됩니다.

  • 채번 시점 1천개 vs 중복 제거 후 1천개

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

encode vs hash vs encrypt

  • 용어의 혼동이 있었습니다. 정확하게는 encode 가 맞는 표현입니다.
  • encode 는 암호화 시 key 가 필요하지 않으며 복호화 를 통해 원래 형태로 되돌릴 수 있습니다. (양방향)
  • hash 는 마찬가지로 암호화 시 key 가 필요하지 않으며, encode 와 다르게 원래 형태로 되돌릴 수 없습니다. (단방향)
  • encrypt 는 암호화 시 적절한 key 를 필요로 하며, key 를 이용하여 원래 형태로 되돌릴 수 있습니다. (양방향)
  • ref Encryption vs Encoding vs Hashing

채번 시점 1천개 vs 중복 제거 후 1천개

  • 채번 시점에서는 1000개를 초과할 수 있습니다.
  • 고유한 key 생성이라는 단서를 놓고 봤을 때 충분히 의미가 전달될 수 있다고 생각했습니다.
  • 다만 중복 제거 후 1000개가 더 명확한 표현임은 확실합니다.

피드백 주신 내용 두건 모두 반영하여 수정 진행하겠습니다.
감사합니다.


## 3. 형태 제한
- 단축 url(key) 는 `영문 대소문자`와 `숫자`로 구성됩니다.
- `특수문자` 그리고 `공백` 은 사용할 수 없습니다.

## 참고할 만한 자료 👓
### 1. [밀러의 매직 넘버 7](https://story.pxd.co.kr/612) 👈