CS408 Semester Project
Geometry Jest is to be a web based game for learning about the interactions between points lines and planes.
The website has a backend server built in Rust using the Rocket Framework. The server interacts with a mySQL database using Diesel. The frontend is built in JS with React.
Install WSL onto your computer. I think it's best if we do all builds in there. It works on all versions of Windows 10 Home.
- Rust
-
If you're on WSL run
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh rustup default nightly
in the terminal. This will install rust and set it to the nightly release (might be required for rocket, also cooler).
-
(Optional) Install cargo watch with
cargo install cargo-watch
This will let you edit code and have the server running at the same time, when you save the server will rebuild automatically (more on that later).
I needed to run sudo apt-get install libmysqlclient-dev to do cargo run
-
- NodeJS (npm)
-
Install and update npm/NodeJS with
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
-
Restart after running this command then run
nvm install 17
This will install nvm (Node Version Manager) and NodeJS 17.x.
-
To confirm that npm and NodeJS were installed you can run
npm --verison node -v
These commands will return the npm version (currently 8.x) and NodeJS version (17.x) respectively.
-
Install required packages
npm install
-
- MySQL
-
Create a mySQL table with columns
| id | username | userpass | salt | highscore |
Where id is a Primary Key int, username is a varchar(12) userpass is a char(64), salt is a char(32), and highscore is int.
-
Go into the frontend directory.
To test the frontend with no backend support run
npm ci
npm start
This will start a the frontend portion of the webpage on localhost:3000.
To build the frontend fully run
npm run build
This will create a build
directory that the backend will need to host the webpages.
Go into the server directory
Edit .env.example
file and remove .example
to suit your use.
My .env file
DATABASE_URL=jdbc:mysql://localhost:3306/geojest
SERVER.HOST=127.0.0.1
SERVER.PORT=8000
To run the server run the command
cargo run
This will do nothing but run the server. This is dependent on a build being present at ../frontend/build
being present.
If you would like to run the server and have it automatically rebuild on changes use
cargo watch -x run
This is of course reliant on cargo-watch
being installed.