Kon is a game in which users answer a number of questions about which year was "better" for their crop return. They have the option to respond with one of the two years, that they were equal or simply "I don't know." Based on their response, they will gain a number of points according to data from satellites, weather stations and other users.
Kon is a python application using a flask extension which uses a SQL database, interacted with through SQLAlchemy, and a front end using HTML files and JavaScript programs which use JQuery. I used the first 5 lessons of a flask tutorial from Miguel Grinberg at https://blog.miguelgrinberg.com/post/the-flask-mega-tutorial-part-i-hello-world to get started. His application has many similarities to ours because of this and is a good guide to how Kon was built.
In order to start Kon, you will need to have these python modules installed: flask, flask-wtf, python-dotenv, flask-sqlalchemy, flask-migrate and flask-login. pip install module-name will likely do the trick on your terminal. Enter the "kon" directory and type in "source venv/bin/activate" for Mac's terminal or "venv\Scripts\activate" for Window's to activate your virtual environment. Then type "flask run" or, if that doesn't work, "python -m flask run" to start the application.
All javascript is in the static folder in the app directory and all html files are in the templates folder. game.html is the html page for the actual game screen and kon.js is the JavaScript which goes with it. login.html, register.html and base.html all use flask-wtf web forms, which are explained well in chapter 3 of the tutorial linked above. base.html is the base template used by every other html which includes a navbar which allows you to login or logout and go to the game. Any files which include the word "DEMO" are the ones used for a seminar testing kon's functionality using data from NYC winters. The files which include "OG" are the files for kon before this seminar. Edit the files which include neither of these words because those are the most up to date. I left the DEMO and OG files in case someone needs to go back and look at them.
forms.py sets up the login and register forms. Info about this can be found in the tutorial if you need to change the forms for some reason.
models.py sets up the database, which includes tables for Users and Votes. If you need to change the structure of the database, update models.py and then make sure to migrate and upgrade the changes with "python -m flask db migrate" and "python -m flask db upgrade." More info can be found in chapter 4 of the online tutorial. Each user has an id number, a username, an email, a password (which is hashed for security purposes), a score, a location and a link to their votes. Each vote has an id number, 2 years to compare, an answer to that comparison and the user_id for who voted.
The majority of kon's functionality is stored in routes.py, which is the main flask application. It is commented on throughout to make it easy to understand.