Public | Automated Build

Last pushed: 2 years ago
Short Description
Auction game written on node.js and angular.js
Full Description

Auction Game

Auction game built on node.js and angular.js


  • Postgres for persistency
  • Node.js + Express.js for HTTP server and API
  • for efficient client-server event-based communication
  • Passport.js for JWT tokens
  • Angular.js for UI
  • Angular Material for Material design
  • Jade for templating
  • Stylus for CSS
  • Font Awesome and Flaticon icons
  • Gulp for compiling UI
  • Mocha.js and Sinon.js for testing
  • Docker for running and deploying the application everywhere


Web UI is built on Angular.js

  • Angular Material design standards by Angular Material framework
  • Mobile friendly
  • Pure static (can be served using Nginx as a separate application)

<img src="assets/auction-design.png" width="400">

How to Run

The easiest way to run it inside Docker container.

To build docker image, type:

$ docker build -t auction .

Or pull auto-built image from docker hub:

$ docker pull alexeyernest/auction-game

If you don't have Postgres running, run postgres container, for example:

$ docker run -d --name postgres -p 5432:5432 -e POSTGRES_DB=auction -e POSTGRES_USER=auction -e POSTGRES_PASSWORD=auction postgres:9.4

And create db schema using schema.sql:

-- Players

CREATE SEQUENCE players_serial;

CREATE TABLE players (
    id integer PRIMARY KEY DEFAULT nextval('players_serial'),
    name varchar(50),
    coins integer NOT NULL,
    CONSTRAINT player UNIQUE(name)

ALTER SEQUENCE players_serial owned by;

-- Session

CREATE TABLE player_sessions (
    session_id varchar NOT NULL

-- Inventory

CREATE SEQUENCE inventory_serial;

CREATE TABLE inventory (
    id integer PRIMARY KEY DEFAULT nextval('inventory_serial'),
    player_id integer NOT NULL REFERENCES players ON DELETE CASCADE,
    item varchar(100) NOT NULL,
    quantity integer NOT NULL

ALTER SEQUENCE inventory_serial owned by;

CREATE UNIQUE INDEX player_items ON inventory (player_id, item);

-- Auction

CREATE SEQUENCE auction_serial;

CREATE TABLE auctions (
    id integer PRIMARY KEY DEFAULT nextval('auction_serial'),
    created timestamp without time zone NOT NULL,
    start_time timestamp without time zone,
    end_time timestamp without time zone,
    seller integer NOT NULL REFERENCES players ON DELETE CASCADE,
    seller_name varchar(50) NOT NULL,
    item varchar(100) NOT NULL,
    quantity integer NOT NULL,
    min_bid integer NOT NULL,
    bid integer,
    winner integer,
    winner_name varchar(50),
    done boolean DEFAULT FALSE

ALTER SEQUENCE auction_serial owned by;

CREATE INDEX auction_queue ON auctions (start_time, created);
CREATE INDEX auction_latest ON auctions (end_time);
CREATE INDEX auction_current ON auctions (start_time, end_time);

Then run auction container with parameters.

Parameter Description
POSTGRES_CONNECTION Postgres connection string
TOKEN_SECRET Secret string for encrypting JWT tokens
DEBUG Turn on debugging information, should be auction-game:*

For example:

$ docker run -d --name auction -p 8080:8080 -e POSTGRES_CONNECTION=postgres://auction:auction@ -e TOKEN_SECRET=secret -e DEBUG=auction-game:* auction


To run tests you have to install mocha.js:

$ npm install -g mocha

Unit tests:

$ mocha test/unit/ --recursive

Integration tests:

$ mocha test/integration/ --recursive

All tests:

$ mocha test/* --recursive


Latest build is deployed to AWS EC2 Container Service. You can try it by IP address:

Docker Pull Command
Source Repository