/connect4web

A Connect 4 implementation on a modern web stack.

Primary LanguageC#

Connect4Web

A Connect 4 implementation on a modern web stack

Demo

http://connect4web.azurewebsites.net/

Objective

To implement a lightweight algorithm of the classic Connect Four game satisfying unit and acceptance tests, exposed with a simple REST API and visualised in a SPA web front-end.

Technology Stack

  • .NET 4.6.1
  • C# 6.0
  • ASP.NET MVC5 / WEB API2
  • Owin
  • Autofac
  • Serilog/Seq
  • NUnit
  • Aurelia (routing, templating, binding)
  • ES6/2015
  • NPM and JSPM package managers
  • Gulp
  • Bootstrap
  • Animate.CSS
  • Backstretch

Notable Features

Single Page Application

The SPA design removes page reloads and helps makes API interactions fast and responsive.

Sessionful

ASP.NET sessions (tracked via cookies) retain the state of the player's board even with a full page refresh and single page application reboot. This elapses when the session times-out or the application pool is recycled. The board state is discarded when a game concludes via a win or a draw.

Diagnostics

Serilog has been added to the Owin middleware for Web API 2, with a sink to a configurable Seq instance (http://localhost:5341 by default). All API requests will be logged including any enrich properties.

In-memory board visualisations

To assist debugging and testing, the board can be visualised in a debug watch window:

Future Enhancements

  • Selectable board dimensions on landing page.
  • Integrate Swagger for API testing and self-documentation.
  • Front-end Javascript unit tests.
  • Responsive layout.
  • Port to ASP.NET Core.

Build Instructions

  1. git clone https://github.com/Craigology/connect4web
  2. Build solution in VS2015.
  3. Run tests (requires ReSharper or other test runner support for NUnit).
  4. Install NPM with NodeJS or Chocolatey.
  5. From command prompt (assumes NPM is in %PATH%):
  6. cd src/Connect4.Web
  7. npm install
  8. npm install -g jspm
  9. jspm install -y
  10. npm install -g gulp
  11. gulp build
  12. Debug/launch site in VS2015.