brettkolodny / mancala_ex

Mancala on the web powered by Rust, Elixir/OTP, and Phoenix

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

MancalaEx

Multiplayer Mancala implemented using Elixir/OTP, Phoenix, LiveView, and Rust.

Check it out!

http://www.mancala.brettkolodny.com

How it works

This project is made up of three main parts:

  1. The Phoenix web framework
  2. An OTP game server
  3. NIFs written in Rust

Phoenix

Within Phoenix is the code that handles the website's routes, and player authentication, and front end code written with built in Eex templates and LiveView. This code ensures that the player's data is present before they join a game, the game they are creating exists or is available to be created, and then communicates to the game server to dynamically display the current state of the player's game.

Game Server

The game server is built upon Erlang's GenServer architecture and exposes an api for the code within Phoenix to interact with different game instances in order to update the game based on the player's input. Each time a game is created a new game server is created, and registered within a supervisor process that oversees every game server. This ensures that if a game server were to crash it is restarted without affecting the rest of the application, and that games are deleted after enough time has passed. The game server calls the rust NIFs to determine the new state of the game.

Rust NIFs

The game logic itself is implemented using Rust NIFs (native implemented functions). This code is responsible for determining the game's state after a player's turn and determining if the game has a winner.

AWS

This application is hosted on an AWS EC2 instance.

About

Mancala on the web powered by Rust, Elixir/OTP, and Phoenix


Languages

Language:Elixir 68.6%Language:SCSS 14.7%Language:HTML 7.2%Language:Rust 5.2%Language:JavaScript 4.3%