Skip to content

apenlor/go-life-server

Repository files navigation

Go Life Server

Codacy Badge License: MIT

Note: This project serves as a playground for testing development workflows and capabilities with Cline, an AI software engineering assistant.

Overview

Go Life Server is a high-performance implementation of Conway's "Game of Life" designed to demonstrate systems engineering mastery. It features a highly concurrent backend capable of processing large grids efficiently and a lightweight frontend for real-time visualization.

Key Features

  • High Concurrency: The backend leverages Go's concurrency primitives (Worker Pools, sync.Mutex, sync.WaitGroup) to distribute grid calculations across multiple CPU cores.
  • TDD Compliance: Core simulation logic is verified using comprehensive Table-Driven Tests to ensure correctness before any API development.
  • Real-time Visualization: The frontend uses HTML5 Canvas and requestAnimationFrame for smooth, high-performance rendering without UI frameworks.
  • Hexagonal Architecture: Strict separation of concerns using Ports & Adapters to decouple the simulation engine from the WebSocket delivery mechanism.
  • Seamless Deployment: Fully containerized with Docker for easy one-command startup.

Architecture

The project follows the Hexagonal Architecture (Ports & Adapters) pattern:

  • Inner Hexagon (Domain): Contains pure Go logic for the simulation (Universe, Rules). Zero external dependencies.
  • Middle Hexagon (Application): Orchestrates the simulation loop and manages concurrency.
  • Outer Hexagon (Adapters):
    • Primary: WebSocket Handler for receiving user commands.
    • Secondary: State Broadcaster for pushing binary updates to the frontend.

Tech Stack

Backend

  • Language: Go 1.25+
  • Transport: gorilla/websocket (Binary protocol)
  • Concepts: Concurrency, Worker Pools, Clean Architecture

Frontend

  • Language: TypeScript
  • Rendering: HTML5 Canvas API
  • Tooling: Vite

Getting Started

Prerequisites

  • Docker & Docker Compose
  • Go 1.25+ (for local development)
  • Make

Running the Application

Launch the entire stack (Backend + Frontend) with a single command:

docker compose up --build -d

The application will be accessible at:

  • Frontend: http://localhost:80
  • Backend: http://localhost:8080 (Internal API)

Development & Testing

Use the included Makefile for common development tasks:

# Run all unit tests
make test

# Run performance benchmarks
make bench

# Clean build artifacts
make clean

License

This project is licensed under the MIT License - see the LICENSE file for details.

About

High-performance Conway's Game of Life server in Go using Hex, with a real-time TypeScript/Canvas frontend.

Topics

Resources

License

Stars

Watchers

Forks

Contributors