The architecture is frontend - backend. The project can be run with a docker-compose file that runs everything. The pipeline allows the build and test of the project at every commit, and deploy the main branch.
The backend is written in Rust, and the frontend in Typescript. They communicate via WebSocket.
---
title: Architecture
---
flowchart TB
subgraph Docker
Nginx[[Nginx :80]] -- / --> Frontend
Nginx -- /ws --> Backend
Frontend -.-> Objects
Backend -.-> Objects
end
Client -- http --> Nginx
LoadTesting -- Websocket --> Backend
---
title: Interactions
---
sequenceDiagram
participant Frontend
participant Backend
note over Backend,Frontend: Initialization
Frontend ->> Backend: Initiate Websocket Connection
Frontend ->> Backend: Username
Backend ->> Frontend: ID
Backend ->> Frontend: State of the board
note over Backend,Frontend: Every 300ms
Backend ->> Backend: Game Loop
Backend ->> Frontend: Changes
note over Backend,Frontend: User Input
Frontend ->> Frontend: User Input
Frontend ->> Backend: Direction
- webassembly : run the rust code in the browser and interact with the page
- websocket : communicate between the front and back
- serde : transforms rust object instances to json
- basic functionnalities
- select username
- the player can move on a grid
- the player can eat an apple and grow
- on the walls, loop back
- death
- the player loose if it hits any snake (himself or another player)
- the player loose if it hits a wall
- loosing / winning screen
- if a player loose, a popup shows
- at the end, a scoreboard is shown
- advance player movement
- handle rollback