A URL Shortener service created using Python, Django, React and GraphQL.
This is a learning project to learn about Queries and Mutations in GraphQL and about Hashing Algorithms.
Clone this repository by running the command
git clone https://github.com/roopeshvs/Crisp.git
For Linux, use
python3 -m venv VENV
For Windows, use
python -m venv VENV
For Linux Bash, use
VENV/bin/activate
For Windows Command Prompt, use
VENV\Scripts\activate.bat
Install the required dependencies by running the command
pip install -r requirements.txt
To create tables in your database, run the commands
For Linux, use
python3 manage.py makemigrations
python3 manage.py migrate
For Windows, use
python manage.py makemigrations
python manage.py migrate
To start the server, run the command
For Linux, use
python3 manage.py runserver
For Windows, use
python manage.py runserver
Head over to http://localhost:8000/graphql/ to visit the beautiful interface provided by GraphiQL.
Replace all the contents on the left pane with the following mutation.
mutation {
createUrl(fullUrl:"https://github.com/roopeshvs/Crisp") {
url {
id
fullUrl
urlHash
clicks
createdAt
}
}
}
You can see your URL Hash at the Right Pane in the GraphiQL interface.
You can now visit the original URL at http://localhost:8000/{urlHash}
Note that only valid URLs will generate an Output.
Get the list of all your shortened URLs using the following query.
query {
urls {
id
fullUrl
urlHash
clicks
createdAt
}
}
Get a Filtered List of your shortened URLs using the following query.
query {
urls(url:"Crisp") {
id
fullUrl
urlHash
clicks
createdAt
}
}
Get a Paginated List of your shortened URLs using the following query.
query {
urls(first: 2, skip: 1) {
id
fullUrl
urlHash
clicks
createdAt
}
}
- Implement Production-Ready Collision, Hashing Functions & Bloom Filter.
- Add User Authentication and OAuth.
Find the React part of Crisp at Crisp React