Skip to content
This repository has been archived by the owner on Jan 14, 2024. It is now read-only.

Latest commit

 

History

History
74 lines (56 loc) · 3.78 KB

README.md

File metadata and controls

74 lines (56 loc) · 3.78 KB

ChaosConnect

The modern, distributed and scalable implementation of a game inspired by Connect Four.

Gameplay

  • There are two main fractions: Yellow vs Red
  • There's only one big playing field for all players
  • Each player can make a move after a certain timeout
  • Other players cannot place a chip close to another chip for a certain timeout
  • If more people join, the timeouts are altered and the playing field scales automatically
    • More people => make playing field wider
    • More people => make playing field slightly higher
    • Less people => Mark (now superfluous) rows and columns as as soon to be deleted, delete after a certain time passed
  • If a disk you placed is part of a 4 disk long line you get points and the associated columns are cleared
  • You get more points if you're on the losing fraction for balance purposes
  • You can exchange your points for perks and skins
  • To ensure fairness, some bots might be added to balance the teams

Running

In order to run all services within docker you can run an alternation of one of the following commands:

# Run services hosted under backed.localhost and frontend.localhost, built locally, run 2 joestar instances
docker-compose -f docker-compose.yml -f docker-compose.dev.yml up --build --scale joestars=2

# Run services under https://ourdomain.com, generating certificates throught Let's Encrypt, using images published to GitHub Packages
docker-compose -f docker-compose.yml -f docker-compose.prod.yml up --scale joestars=5

# Or write your own override file with your domain

Developping

In order to run components in development mode, the folling commands are good to get started:

# Required once at the beginning and afterwards once the protocol buffer contract changes
docker-compose -f docker-compose.gen.yml up

# Svelte Frontend
cd frontend
npm run dev

Technical Implementation

Architecture Overview

Service Names

The service names are all a reference to the popular anime JoJo's Bizarre Adventure.

Service Name
Frontend Doppio
Loadbalancer Speedwagon
Scaling Backend Joestars (Jonathan, Joseph, Jotaro, Josuke, Giorno, Jolyne)
Central Backend Rohan

Frontend

The frontend is written in Svelte. As it's main purpose is to display the current state of the board, we decided that frameworks such as Angular are overkill.

Reverse Proxy

We use Traefik as a reverse proxy to handle load balancing.

Backend

The backend is split into two parts:

  • Scaling: Communicates directly with our Frontend, issues and validates JWT, caches game state and sends game updates to all clients
  • Central: Manages the actual game state, synchronizes requests and handels game logic, stores persistent information, such as user credentials and scores, in a json document

Both backends use Spring Boot with Kotlin.

Database

We decided not to use any database but instead store the (very minimalistic) data in a json document.

Communication

Bidirectional communication is enabled through gRPC. For example, this allows Rohan to send a game update event to all Joestars, which then forward them realtime to all Doppio clients.