Skip to content
This repository has been archived by the owner on Mar 22, 2018. It is now read-only.

Architecture

Jan Paul Posma edited this page May 15, 2014 · 1 revision

= Software Architecture =

== GIT == We’re using Codebase to store our git repo’s. https://factlink.codebasehq.com/

== Software == In order to be able to run Factlink on a server, the following software needs to be present: Nginx + Phusion Passenger Ruby 1.9.2 (using RVM is recommended, https://rvm.beginrescueend.com/) Ruby on Rails 3.0.5 MongoDB 1.8.2 Redis 2.2.x Solr (latest stable, 3.3.0?)

== Ruby on Rails gems ==

devise # User authentication mongoid # ActiveModel orm mongoid_taggable # Mongoid extension for tagging objects redis # Redis wrapper for Ruby sunspot_rails # Solr wrapper for Rails vinova_sunspot_rails # Sunspot patched for use with ActiveModel

== ImageMagick ==

Please see: http://stackoverflow.com/questions/2838307/why-is-this-rmagick-call-generating-a-segmentation-fault

install using:

brew install -f imagemagick --disable-openmp

== Components ==

Factlink currently exists of the following components: core js-library chrome-extension

== Component overview ==

=== core ===

This is the main Ruby on Rails application and the core of Factlink. It serves the web front-end, client and handles all the back-end processing.

MongoDB is used as our NoSQL document store and stores all our default models: Users, Sites and Factlinks. Factlinks (:displaystring, :created_at) are indexed by Solr to make full text search possible.

Redis is used for storing opinions of a user on a Factlink. Each Factlink has three sorted sets (factlink:[factlink_id]:beliefs||doubts||disbeliefs) which contain the authority of the user on this fact (not implemented) and the user_id.

Redis is also used for storing the belief, doubts and disbeliefs of a user, for easy access from the User model. For this we are using a regular set. (user:[user_id]:beliefs||doubts||disbeliefs)

=== js-library === This library contains the javascript currently used by the Chrome Extension. It provides the ‘on-page’ Factlink functionality, like showing the popup and adding a Factlink on a page.

== Redis choice ==

We are currently using two data stores: Mongodb and Redis. The model layer we have is currently split over these two stores.

The choice for using two stores was based on the assumption that doing full-text search is faster in Mongodb with Solr, and the set based operations are faster in Redis. However, currently such fast set operations from Redis are not needed at all. The full text-indexing from solr in mongodb is used for finding facts based on search queries.

Currently, the following parts are stored in Redis: Facts Fact relations Opinions Sites User

In Mongo, the following parts are stored: Fact data User

So, the fact and the user are divided in two stores. This demands coupling between the two data layers. For the coupling with mongodb ActiveRecord is used. For the coupling with Redis this was not possible, and after some search Ohm was used.

To get to the current situation, a lot of work is done. This lead to a working version and knowledge about both systems. However, the introduction of Redis reduced the speed of the team while not yet adding value.

== Installation manual ==

Ruby on Rails uses WEBrick development webserver, so no need to install anything for that. The same holds for Solr, for the development environment a jar is used, and a Jetty server is included in the Gem.

As a package manager, ‘brew’ could be used. It can be found at: http://mxcl.github.com/homebrew/.

For Mongodb and Redis, the following commands need to be executed (watch out! you should execute some commands after installation to ensure it runs and to start it after you startup your system, see your commandline).

$ brew install mongodb $ brew install redis

The factlink files can be obtained by using git. Our current repro can be found on: https://factlink.codebasehq.com/

$ git clone

After pulling them, make sure you run a ‘bundle install’ in every directory, to install all the required Gems to the project.

factlink-core requires Solr to run. There is a local development instance of Solr available installed with the Gem. Start solr:

$ rake sunspot:solr:start (if you run into errors starting solr, comment the lines in lib/tasks/test_reed.rake. These lines run a db:seed before every ‘rake’ command, but is not possible yet since solr is not running’)

factlink-core has a seed file to pre-fill the database with some content:

$

To have a complete set up running on your development machine, host the static files on a local webserver on port 80 (for example, use the python simple http server: python -m SimpleHTTPServer 80, required root though to access port 80)

Make sure to install the Chrome extension and point the options to the correct URL’s and ports.

== Running the site locally ==

Remember to start the following servers: Redis Mongo Sunspot Ruby on Rails

start the followin heartbeats: rake fact_graph:recalculate rake channels:recalculate

== DTAP ==