https://github.com/superthinking/url-shortener-playground
Another url shortener | Playground
https://github.com/superthinking/url-shortener-playground
Last synced: 12 days ago
JSON representation
Another url shortener | Playground
- Host: GitHub
- URL: https://github.com/superthinking/url-shortener-playground
- Owner: SuperThinking
- Created: 2025-07-06T15:45:33.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-07-06T15:54:39.000Z (about 1 year ago)
- Last Synced: 2025-08-08T12:37:58.322Z (12 months ago)
- Language: Python
- Size: 7.81 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# URL SHORTENER PLAYGROUND
To run the application locally:
```bash
make venv
make install-dev
make docker-dev
source .venv/bin/activate
fastapi dev main.py
```
```
Create / View records in database (mongodb):
http://localhost:8084/
username: admin
password: pass
```
```
Shorten a URL:
curl -X 'POST' \
'http://127.0.0.1:8000/shorten?url=haha.com' \
-H 'accept: application/json' \
-d ''
```
```
Resolve a shorten URL:
curl -X 'GET' \
'http://127.0.0.1:8000/resolve/1Ie' \
-H 'accept: application/json'
```
--------------
Working theory in brief
```
- Keeping the length of the shorten url to 7 digits as of now, with characters in range [0-9a-zA-Z] (total 62 characters). Which means total combinations possible 62^7 = 3.5 trillion combinations.
- When the user calls `shorten` endpoint with there "url", we use a distributed counter and base62 encode it to generate a unique short url.
- To maintain this distributed counter range - we use zookeeper.
- Whenever a new service is added to the system or the counter range is exhausted, we use zookeeper to increment and get the next counter.
```