• Stars
    star
    173
  • Rank 220,124 (Top 5 %)
  • Language
    CoffeeScript
  • Created almost 10 years ago
  • Updated over 7 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

HapiGer is an http-wrapper around the Good Enough Recommendation engine using the Hapi.js framework

HapiGER

HapiGER logo

Providing good recommendations can create greater user engagement and directly provide value by recommending items the customer might additionally like. However, many applications don't provide recommendations to users because of the difficulty in implementing a custom engine or the pain of using an off-the-shelf engine.

HapiGER is a recommendations service that uses the Good Enough Recommendations (GER), a scalable, simple recommendations engine, and the Hapi.js framework. It has been developed to be easy to integrate, easy to use and very scalable.

Project Site

Quick Start Guide


*** #### Install HapiGER

Install with npm

npm install -g hapiger

***

Start HapiGER

By default it will start with an in-memory event store (events are not persisted)

hapiger

There are also PostgreSQL, RethinkDB and MySQL event stores for persistence and scaling


***

Create a Namespace

The first thing to do is to create a namespace, which is a bucket that person events are put into:

curl -X POST 'http://localhost:3456/namespaces' -d'{
    "namespace": "movies"
  }'

***

Create some Events

An event occurs when a person actions something, e.g. Alice views Harry Potter:

curl -X POST 'http://localhost:3456/events' -d '{
    "events": [
    {
      "namespace": "movies",
      "person":    "Alice",
      "action":    "view",
      "thing":     "Harry Potter"
    }
  ]
}'

Then, Bob also views Harry Potter (now Bob has similar viewing habits to Alice)

curl -X POST 'http://localhost:3456/events' -d '{
    "events": [
    {
      "namespace": "movies",
      "person":    "Bob",
      "action":    "view",
      "thing":     "Harry Potter"
    }
  ]
}'

When a person actions and thing, it serves two purposes in HapiGER:

  1. It is used to measure a persons similarity to other people
  2. It can be a recommendation of that thing

For example, when Bob buys LOTR

curl -X POST 'http://localhost:3456/events' -d '{
    "events": [
    {
      "namespace":  "movies",
      "person":     "Bob",
      "action":     "buy",
      "thing":      "LOTR",
      "expires_at": "2017-10-12"
    }
  ]
}'

This is an action that can be used to find similar people AND it can be seen as Bob recommending LOTR. For an event to be a recommendation as well it must have an expiration date set with expires_at, which is how long the recommendation will be available for.


***

Recommendations

Recommendations can be generated by either passing the name of a person or a thing, the namespace to generate recommendations from, and a configuration which defines how to search for recommendations. The configuration is passed to GER and the available variables are listed in the GER Documentation.

What movies should we recommend Alice?

curl -X POST 'http://localhost:3456/recommendations' -d '{
    "namespace": "movies",
    "person": "Alice",
    "configuration": {
      "actions" : {"view": 5, "buy": 10}
    }
}'

will return:

{
  "recommendations": [
    {
      "thing": "LOTR",
      "weight": 0.44721359549996,
      "last_actioned_at": "2015-10-12T17:04:14+01:00",
      "last_expires_at": "2017-10-12T01:00:00+01:00",
      "people": [
        "Bob"
      ]
    }
  ],
  "neighbourhood": {
    "Bob": 0.44721359549996,
    "Alice": 1
  },
  "confidence": 0.00036398962692384
}

Alice should buy LOTR as it was recommended by Bob with a weight of about 0.4.


What movies should we recommend to someone looking at Harry Potter?

curl -X POST 'http://localhost:3456/recommendations' -d '{
    "namespace": "movies",
    "thing": "Harry Potter",
    "configuration": {
      "actions" : {"view": 5, "buy": 10}
    }
}'

returns

{
  "recommendations": [
    {
      "thing": "LOTR",
      "weight": 0.70710678118655,
      "last_actioned_at": "2015-10-13T08:53:00.885Z",
      "last_expires_at": "2017-10-12T00:00:00.000Z",
      "people": [
        "Bob"
      ]
    }
  ],
  "neighbourhood": {
    "LOTR": 0.70710678118655
  },
  "confidence": 0.0010667601060058
}

The person should buy LOTR as it was recommended by Bob with a weight of about 0.7.

The confidence of these recommendations is low because there are not many events in the system. As you add events the confidence will increase


***

Event Stores

The "in-memory" memory event store is the default, this will not scale well or persist event so is not recommended for production.

The recommended event store is PostgreSQL, which can be used with:

hapiger --es pg --esoptions '{
    "connection":"postgres://localhost/hapiger"
  }'

Options are passed to knex.

HapiGER also supports a RethinkDB event store:

hapiger --es rethinkdb --esoptions '{
    "host":"127.0.0.1",
    "port": 28015,
    "db":"hapiger"
  }'

Options passed to rethinkdbdash.

HapiGER also supports a MySQL event store:

hapiger --es mysql --esoptions '{
    "connection": {
      "host": "localhost",
      "port": 3306,
      "user": "root",
      "password": ""
    }
  }'

Options are passed to knex.


***

Compacting the Event Store

The event store needs to be regularly maintained by removing old, outdated, or superfluous events; this is called compacting

curl -X POST 'http://localhost:3456/compact' -d '{
  "namespace": "movies"
}'

***

Namespaces

Namespaces are used to separate events for different applications or categories of things. You can create namespaces by:

curl -X POST 'http://localhost:3456/namespaces' -d'{
    "namespace": "newnamespace"
  }'

To delete a namespace (and all its events!):

curl -X DELETE 'http://localhost:3456/namespaces/movies'

***

Clients

  1. Node.js client ger-client
  2. HapiGER NodeJS client hapigerjs

Changelog

12/10/15 -- Updated README, new version of GER 8/02/15 -- Updated readme and bumped version

More Repositories

1

list_of_recommender_systems

A List of Recommender Systems and Resources
4,314
star
2

ger

Good Enough Recommendation (GER) Engine
CoffeeScript
376
star
3

DR-CoN

Scalable Architecture using Docker, Registrator, Consul, Consul Template Nginx
28
star
4

yeahnah

A Movie Recommendation Site written using Hapi.js, Good Enough Recommendations and The Movie Db
CoffeeScript
23
star
5

asteroids

GoLang implementation of asteroids using Lorca/Webview and WASM
Go
17
star
6

bazel-golang-wasm-proto

Simple site using Bazel Golang WASM and Proto
Go
10
star
7

cuda-gol

Cuda
5
star
8

bazel-docker-tree

spike into using bazel to build docker trees
Dockerfile
5
star
9

elasticbone

Elasticsearch is an awesome document store, with a nice rest api. Backbone is an awesome MVC framework, where the model are defined to interact with a rest api. Elasticbone is an extension making it easy for Backbone models to be connected to Elasticsearch documents.
CoffeeScript
5
star
10

elasticscroll

ElasticScroll implements the scrolling API for ElasticSearch
CoffeeScript
5
star
11

block-map

JavaScript
4
star
12

ger_rethinkdb_esm

An Event Store Manager for Good Enough Recommendations (GER) using RethinkDB
CoffeeScript
4
star
13

bazel-electron

Go
3
star
14

ger-client

A client for the heroku addon (currently alpha) ger
CoffeeScript
3
star
15

nz-atlas

New Zealand Maps Collection
3
star
16

jsalgorithms

Different algorithms created and visualized in JavaScript (for learning purposes)
JavaScript
3
star
17

Thesis

MyThesisPlusScripts
Shell
3
star
18

bazel-python-to-golang

Small Repo demonstrating calling Golang from Python
Starlark
2
star
19

Mash

JavaScript
2
star
20

tessel_twitter_to_morse

Tessel Project that takes a Twitter stream and blinks it out as morse code.
CoffeeScript
1
star
21

brain_elixir

Elixir
1
star
22

rabbit_brain

Asynchronous Neural Networkover Rabbitmq
CoffeeScript
1
star
23

test_promises

CoffeeScript
1
star
24

pathby

Ruby SVG Path Experiment
Ruby
1
star
25

ComponentSystemEvolutionSimulation

A simulation developed for my PhD
Java
1
star
26

rort

Rort (ROger ebeRT) is a movie recommendations engine used as an example of how to use the Good Enough Recommendations (GER) engine Heroku addon
Ruby
1
star
27

ghost_train

This is a port of the Ghost Blogging Engine to be a Ruby On Rails Engine
Ruby
1
star
28

tessel_security_camera

Test security Camera from the Tessel
CoffeeScript
1
star
29

satrpy

This is an attempt to write a SAT Solver in RPython. Its core requirements are understandability, modularity and speed (in that order).
Python
1
star
30

gitpow

gitpow alters your commit message with a proof-of-work to secure its history
Go
1
star
31

papergame

Ruby
1
star