This is the Django + TailwindCSS web app for the TSRS Crypt Hunt.
Attributions
-
Ritwic Verma worked on multiple components of the project; including development support for Windows, the frontend for the login page, and the answer submission flow.
-
The final logo for the event was designed by the Editorial Board of TSRS Moulsari.
Make sure you have the following installed:
- Python
- NodeJS
- Pipenv (for Python dependency management)
Then, follow these steps:
-
Clone the repository
-
Create a
.envfile, and add the following to it:DEBUG=True IS_ONLINE_MODE=False
-
Run
echo "SECRET_KEY=$(openssl rand -base64 32)" >> .env -
Run
pipenv shellto active your pipenv virtual environment -
Run
pipenv installto install the Python dependencies -
Run
python manage.py runserverto run the server
If you want to make changes to the frontend tailwind classes:
python manage.py tailwind installto install the tailwind NPM dependencies into the right structure in the project- If on Windows, set
NPM_BIN_PATHintsrs_crypt_hunt/settings.pyto the defaultnpm.cmdinstall location (UsuallyC:\Program Files\nodejs\npm.cmd). python manage.py tailwind startto start the tailwind watcher
To work with the database:
python manage.py migrate* run this the first time you set up the project. This creates SQL tables based on the migrations defined by the app.python manage.py createsuperuser* run this to create a superuser account. This is the account you will use to log into the Django admin panel atlocalhost:8000/admin.python manage.py makemigrations* run this command to create a new migration file. This is necessary if you make any changes to the database models. After whenever you run this, runpython manage.py migrateto apply the changes to the database.
This is designed for a Heroku deployment, but can be deployed anywhere that supports Python and NodeJS.
For Heroku:
- Create a Heroku app and push the code as normal. Make sure to set the environment variables
- In addition to the automatically detected Python Buildpack, add the NodeJS buildpack to the app. This is to run the root-level
package.jsonwhich compiles the tailwind files
Significance of each root-level directory:
apicontains the code for the Django REST Framework API endpoints. It also contains definitions for non-authentication related database modelsappcontains the code for the Django Web App. This includes atemplatessub directory with the HTML files for the web app.userscontins database logic for authentication.staticcontains the static files for the web app, such as assets, JS files, and CSS files. These are compiled, minified, renamed, and served by whitenoise in productionthemecontains the configuration for TailwindCSS (find more instructions below)tsrs_crypt_huntis generated by Django. The only relevant file here issettings.pyand the root-levelurls.pyfile which is the entry point for all URLs in the Django apputilscontains some utility functions and constants for the entire application
The following Visual Studio Code extensions are recommended to help you work on this project.
- Django
- Django Template language support
- Tailwind CSS IntelliSense
- PostCSS Language Support
- Headwind for sorting Tailwind classes
- IntelliSense for CSS class names in HTML
- Use the
generate_teams()function from/utils/functions.pyto generate house accounts. By default, it generates it based on the list of houses in/utils/constants.py, generating a 3-word passphrase. Make sure to call this function on the server. - Colors are mapped to house names in
/utils/constants.py.
- Tailwind code is defined in the
theme'app'. Tailwind's source code is instatic_src, including thesrc/styles.cssfile,tailwind.config.jsfile, andpostcss.config.jsfile. - If you run the
python manage.py tailwind startcommand, it will start a watcher that will compile the Tailwind code into thestaticdirectory. This is where the compiled CSS file is stored, and is where the Django app will look for it. - Links to the tailwind CSS files are injected into every HTML template using the django template tag
We use a library called django_tailwind to manage this.




