Using Fastapi, SQLModel, SQLite
May take a while to start the server (I am using free tier plan)
read/write ratio should be 100/1
should be able to scale-up
short url key length: 8
- random id or uuid
- collision may happen when scale up
- need to check frequently to prevent collisions -> bottleneck
- random is not secure (pseudo random)
- hashing(md5, sha...)
- truncate by taking first n characters may cause collision
- counter (token range)
-> bcrypt + base62 approach
-
Clone the repository
You can clone the repository by running the following command in your terminal:
git clone https://github.com/patty111/url-shorten.git cd url-shorten
-
Install dependencies
pip install poetry && poetry install --no-root
-
Run
uvicorn main:app --port 8000 --reload
orpython3 main.py
navigate to
/docs
endpoint for API documentation demo vid: https://youtu.be/hdOzrbVS8iQ