Coursory allows you to search and filter through Stanford courses. It fetches courses from the ExploreCourses API, cleans/munges the data into MongoDB, and indexes courses using Elasticsearch, providing a fast search API akin to Google Instant.
This README will explain how to get coursory running on your local machine.
Install MongoDB and Elasticsearch based on their respective installation instructions. Ensure they're both running and ready to process requests.
You'll need ruby version 2.0.0. You can get this via rvm or rbenv.
Install bundler:
$ gem install bundlerChange into the coursory directory and install the project dependencies:
$ bundle installYou'll need to tell coursory how to connect to MongoDB. Create a .env file in the coursory directory and include the following:
MONGODB_URI: mongodb://127.0.0.1/coursoryYou can change the MongoDB URI if need be. See the connection string URI format for details.
You'll need to seed your database with courses to get the search working. To do so, change into the coursory directory and download an XML file containing all courses from ExploreCourses:
$ curl
"explorecourses.stanford.edu/search?view=xml&filter-coursestatus-Active=on&page=0&catalog=&academicYear=&q=%"
> courses.xmlThen, parse and sync the course data into MongoDB:
$ ./bin/sync_courses.rbMunge/Clean the data to make it easily searchable:
$ ./bin/clean_courses.rbFinally, index it using Elasticsearch:
$ ./bin/index_courses.rbConfirm everything worked by running the REPL:
$ ./bin/repl
[4] pry(main)> Course.where(:code => '144', :subject => 'CS').firstIf you see CS 144, everything should have worked.
Now that you've installed dependencies and set up your database, you can run coursory:
$ rackupMake a request to the search API to see if things are working:
$ curl "localhost:9292/search?query=cs+155"If you see CS 155 as the first search result, you should be good to go!
Consider using the jq command-line tool to
format the JSON readably:
$ curl "localhost:9292/search?query=cs+155" | jq '.'Now, visit http://localhost:9292 in your browser and you should see the working coursory app. Happy developing!