______ __ __
/ ____// /__ __ ___ / / ___ _____ _____
/ / / // / / // _ \ ______ / / / _ \ / ___// ___/
/ /___ / // /_/ // __//_____// /___/ __/(__ )(__ )
\____//_/ \__,_/ \___/ /_____/\___//____//____/
This project is using the fastapi framework in addition to click for providing an clue-less game that can be played in the terminal and on your browser.
clueless
is our project root
pyproject.toml
defines our project's requirements.
clueless/main.py
defines the entry points for the application, namely:
- The terminal entry point
clue play
- The web serving command
clue serve
clueless/app
contains all the application logic including
- The fastapi webapp definitions
- Web app logic including UI/UX
- Core logic
clueless/app/core
contains all the core game logic such as
- Game Loop
- Characters
- Players
- Rooms
Make sure you have at least python 3.9 installed.
python --version
Make a virtual environment
python -m venv venv
. ./venv/bin/activate
Install dependencies
pip install .
When we get to deploying the stack we may want to use docker.
To build and stand up the stack following the steps. (Must have docker and docker compose installed).
docker compose build
Standup
docker compose up
Run the following command
clue play
clue serve
Alternatively, you can use docker
docker compose up --build
The Clue-less stack now uses a user authentication system via fastapi-users
.
Generally users will need to register and login. The frontend will need to keep
the session information when logged in. The general process for testing this is:
- Stand up the stack with the prior instructions.
- Visit the docs page at http://0.0.0.0:80/docs
- Register for a new account at http://0.0.0.0/docs#/auth/register_register_api_auth_register_post
- Provide a username (email) and password)
- Log in to the docs by clicking on the authorization button at the top of the page.
- Provide your username and password. You don't need to provide anything else.
- You are now authenticated and logged in to the docs, you can test the endpoints now.
graph TD;
Register-->Login;
Login-->ClueLess_Code;
When the user logs in, the following payload
{
"username": "my_email@email.com",
"password": "password"
}
is sent to /api/auth/login/jwt/login
as a POST REQUEST
You will receive a response
{
"access_token": "<TOKEN>",
"token_type": "bearer"
}
Use this token to authenticate when sending requests to the backend
headers = {
'Authorization': 'Bearer <TOKEN>',
}
Games are centered around game rooms. They're basically a lobby for you to wait in before your game starts.
- Stand up the stack with the prior instructions.
- Visit the docs page at http://0.0.0.0:80/docs
- Log in to the docs by clicking on the authorization button at the top of the page.
- Provide your username and password. You don't need to provide anything else.
- Visit the create room doc. http://0.0.0.0/docs#/room/create_room_api_room__post
- Click Try it out
- Create a room with the payload of: and send
{
"name": "My Game"
}
- You will receive the response
{
"name": "My Game",
"player_limit": 6,
"is_started": false,
"host": "f4b8215d-5e3d-4444-9228-e0e5da5fad09",
"id": "a943d563-828b-414e-98a5-dd37828770dd",
"room_key": "pVn6",
"users": [
"f4b8215d-5e3d-4444-9228-e0e5da5fad09"
]
}
- Visit the rooms UI page to see your room. http://0.0.0.0/rooms
graph TD;
Login-->Create_Room;
Login-->Join_Room;
- Stand up the stack with the prior instructions.
- Visit the docs page at http://0.0.0.0:80/docs
- Log in to the docs by clicking on the authorization button at the top of the page.
- Provide your username and password. You don't need to provide anything else.
- Visit the join room doc. http://0.0.0.0/docs#/room/join_game_api_room___id__join__post
- Click Try it out
- Provide the room key or ID
- You will have joined the room