In Common is a collaborative recommendation engine which utilizes the graph database system Neo4j. It is data-agnostic in the sense that the engine has no knowledge about the data model and requires no data migration or set up. With its minimal RESTful API, it is almost a drop-in solution.
Since this is part of my ongoing MSc project, README will be improved by October.
The main model behind this engine is an event of the type Relationship which has the following data fields:
- a subject type (e.g. user)
- a subjectID (e.g. 123)
- a relationship (e.g. viewed)
- a object type (e.g. product)
- a objectID (e.g. SKU001)
Based on this model two graph nodes with the appropriate label and IDs are created (if they do not exist already) and a relationship with the appropriate label added (or a counter increased if there is already one).
The recommendation are computed based on RecommendationRequest which has the following data fields:
- a subject type (e.g. user)
- a subjectID (e.g. 123)
- a relationship (e.g. viewed)
- a object type (e.g. product)
Notice that the objectID is missing compared to a Relationship model.
The following query is then performed:
Return objects of type object which subjects of type subject, who have relationship the same objects of type object as the subject of type subject and ID subjectID has relationship, have relationship which subjectID has not yet.
Events are managed by POST and DELETE requests. Recommendations are fetched via GET.
POST /engine Adds an event. Request body should have a JSON representation of the Relationship model.
DELETE /engine Removes an event. Request body should have a JSON representation of the Relationship model.
GET /recommendation Gets recommendations. The fields of the RecommendationRequest model are passed as a query string.
Go 1.4 and Neo4j are required.
$ git clone https://github.com/halk/in-common
$ cd in-common
$ go get github.com/mattn/gom
$ gom install
$ gom build
$ inCommon
# will be looked up in $GOPATH
Please see recowise-vagrant for provisioning details. You can use supervisord to daemonize it.
$ cd in-common
$ gom test ./...
Documentation can be found on GoDoc.