Skip to content
This repository

RuuviTracker Server

branch: master
README.md

ruuvi-server

Clojure based implementation of RuuviTrackerServer.

See http://www.ruuvitracker.fi/ for more details.

Server works either as standalone application, using a HTTP Servlet container (for example Jetty) or with Heroku cloud.

This software provides only REST and WebSocket APIs. User interface is available in separate project RuuviTracker/ruuvitracker_web.

Discussion

Most of the discussions about development happen on IRCNet channel #ruuvitracker.

There is also a mailing list at https://groups.google.com/forum/?fromgroups#!forum/ruuvitracker-dev

Prerequisites

Implementation

Currently server implements Tracker API and Client API partially.

  • Requests are saved to database, but they are not properly validated yet.

Standalone application

  1. Fetch sources
git clone git://github.com/jsyrjala/ruuvitracker_server.git
  1. Setup database, see src/resources/server-dev-config.clj
  2. Fetch dependencies
lein deps
  1. Create tables to database

    lein run -m ruuvi-server.launcher migrate
    
  2. (Optional) Import example data to database

    lein run -m ruuvi-server.launcher load-example-data
    
  3. Start server
lein ring server
  1. Access web application http://localhost:3001/api/v1-dev/events

Heroku usage

  1. Get sources
git clone git://github.com/RuuviTracker/ruuvitracker_server.git
  1. Create Heroku account
    • Simply create an Heroku account and push code to Heroku.
  2. Create heroku application
heroku create --stack cedar
  1. Add heroku as git remote
git remote add heroku git@heroku.com:APPNAME.git
  1. Configure heroku
heroku addons:add heroku-postgresql:dev
heroku config:add RUUVISERVER_ENV=heroku --app APPNAME
  1. Create tables to database and some content to tables

    heroku run lein run -m ruuvi-server.launcher migrate
    
  2. (Optional) Import example data to database

    heroku run lein run -m ruuvi-server.launcher load-example-data
    
  3. Start heroku process
heroku scale web=1
  1. Access the app http://APPNAME.herokuapp.com/api/v1-dev/events

Database

Server uses PostgreSQL or H2 database engines. See resources/server-XXX-config.clj files for database configuration.

UI develpment

Static html files are located in resources/public. Add javascript ui there.

Continuous Integration

Travis is used as CI.

See http://travis-ci.org/#!/RuuviTracker/ruuvitracker_server

  • master branch:

Guide to source tree

Production code lives under 'src', unit-tests and other automatic tests live under 'test'. Directory 'test-utils' contains scripts usable in manual testing. Directory 'resources' contains data files that are not executable code.

Unit tests are implemented with Midje.

src directory

  • 'ruuvi_server/' contains main functionality of the server.
    • 'launcher.clj' is the starting point. Handles configuration and starts up serveres.
    • 'configuration.clj' contains functions to handle configuration data. It also contains atom that holds current configuration.
    • 'core.clj' sets up basic REST routes for whole software.
    • 'api.clj' is the main starting point for API.
    • 'client_api.clj' contains implementation of client part of API. Clients (web browsers, mobile devices) can get location data via JSON api.
    • 'tracker_api.clj' contains implementation of tracker API. Tracker device can send location and other data using JSON API.
    • 'tracker_security.clj' implements security features used in tracker API. HMAC based message verification.
    • 'util.clj' contains generic utility functions.
    • 'parse.clj' contains input parsing functions.
  • 'lobos/' contains database migration files (a.k.a database schema changes). Migrations are implemented with Lobos frameworks.
  • 'ruuvi_server/database/' contains database access layer, scripts for initally populating the database with test data and connection pooling. Database access is implemented with Korma library.
    • 'entities.clj' contains definitions for ORM entities.
    • 'event_dao.clj' contains DAO functions for manipulating event data.
    • 'pool.clj' constructs a connection pool.

License

Copyright (C) 2012 Juha Syrjälä

BSD License

Something went wrong with that request. Please try again.