- Admin dashboard
- User Dashboard
- Functional Chessboard
- Working Game Finding Mechanism
- Realtime Gameplay
- Engine evaluation at /api/stockfish
- Simple Global Chat at /chat
These are the likely goals that would be achieved in the near future (in order of decreasing priority)
- Pawn promotion
- Enforce End game condition
- Create a proper game lobby
- Make user profile page for logged in users
- Styling and more Functionality for Global Chat
- Store people's games and devise rating system
Curently the live view of application is hosted on https://playchesswebsite.herokuapp.com/
Feel free to check it out.
To be able to run the project, you should either be having libraries mentioned in requirements.txt in your PC(The same version) or you can create your virtual env with all these libraries in few simple steps! (Recommended)
$ python -m venv env # where env is name of our virtual environment
$ source env/bin/activate
$ (env) pip install -r requirements.txt
Open windows power shell and change directory to the same as main directory of project (where readme.md is)
Write in the following commands to set up your virtualenv
> pip install virtualenv # if virtualenv isn't installed
> virtualenv env # where env is name of virtual env
> env/Scripts/activate
> (env) pip install -r requirements.txt
NOTE: If you aren't able to activate the environment, you may need to change your execution policy. It's really simple, open powershell as an admin and write the following command ->
> Set-ExecutionPolicy -ExecutionPolicy Unrestricted
This script is an easy interface to navigate through the webapp. Currently this script can create an admin, run the development server and for individuals having access to heroku credentials (where the site is hosted), concurrently push changes to both origin and heroku branch at the same time. You can also see different interfaces of this script by just typing python manage.py. It's different interfaces are as follows->
$ python manage.py create_admin
- This will prompt you to type in your desired username and password!
- NOTE: your username can only contain alphanumeric characters and an underscore! Failing to adhere to username restrictions will result in error. However since you're in an interactive app, you will be reprompted to enter your username and password!
$ python manage.py commitall
- Now your changes would be pushed to both the heroku and the origin remotes
$ python manage.py logs
- It shows you the latest heroku logs of live server. You must be having the heroku credentials for this command to work
$ python manage.py dev
- It'll start a dev Gunicorn server on port 8000
- NOTE: Donot use flask development server as it will only serve one client at a time and would only move to the second client when done with 1st. The game finding mechanism won't be able to execute.
$ python manage.py shell
- It opens the production shell
- The default url http://127.0.0.1:8000/ routes to the website's homepage.
- Use http://127.0.0.1:8000/admin/ to access the admin interface
- Use http://127.0.0.1:8000/blog/ to access the blog interface (NOT MADE)
- Use http://127.0.0.1:8000/chat/ to access the global chat and chat with other players.
- Use http://127.0.0.1:8000/api/stockfish to access the stockfish api.
Unit tests are written in Tests folder. You're free to add your own unit tests and improve app's
vulnerability to unwanted bugs on changes. To run unit tests, simply write the following
command in command line ->
$ pytest
This would run all the unit tests present in files starting with prefix test*.py.
- It's important for the test file and the testing methods to start with the prefix "test" for pytest to detect them and run the tests.
- If you want to test on protected views, import login from client.py and and call login method before writing tests.
from .client import login from .client import client def test_your_custom_view(client): login(client) # Now proceed with your tests
- If you want to test some functionality of chessboard which doesnt have a route, you can just import the chessboard class and perform tests on it
from PlayChess import Chessboard from .client import client def test_chessboard(client): chessboard = Chessboard() # Now proceed testing this instance of Chessboard class
- You can also access the database in testing. Just import the db instance from PlayChess module
from PlayChess import db from .client import client def test_database(client): # Now proceed with your tests. # To access database, just use this db instance (db is a PyMongo instance) # Eg-> To search a user, db.users.find_one({"username": "abc"})
To run this flask app->
- Download the zip or fork the repo
- Set up virtual env as prescribed
- Get the .env file from owner of this repo and place it in correct directory
- Go to the main directory(where manage.py is) through terminal and run the following command->
- Goto http://127.0.0.1:8000/ on your browser and play around around with the app!
- To exit the application, press Ctrl+C
- Do drop in your suggestions via pull requests <3
$ python manage.py dev
- This project is only compatible with python3
- Currently this project doesnt work on a windows environment. Please stay connected for further updates
- Documentation regarding certain aspects like chessboard class, stockfish api will be made available later