Ayla: Home Server

The "homeserver" is a Node.js app (built on top of Expresser), coded mainly using CoffeeScript and considered the "brain" of the system. The real deal happens on the backend but there's some frontend magic as well, using Stylus and Jade templates.

Requirements

The main things:
  • Node.js 0.10
  • Python 2.7
  • MongoDB
  • SMTP server
And if you're running on Windows:
  • Cygwin (bash, grep, make)
  • .NET Framework SDK 2.0 (vcbuild.exe)
It doesn't really matter which OS you're using, although specific features might not work so well on specific systems (for example bluetooth related things are not implemented for OS X, yet). For logging I am using Logentries, but you could also log to local files as well. By default the server will look for the files ssl.key and ssl.cer to create a secure HTTPs connection (you can get free certificates from www.startssl.com).

Most Node.js related settings are coming from Expresser and not Ayla itself, so please have a look on its documentation for some overview.

My main development machine runs Windows 8.1, my work machine is a MacBook and my test server is a Raspberry Pi with Raspbian running 24/7 at my house. The home server seems to run fine on all these environments.

Implementation structure

  • /assets Dynamic frontend files (more on Frontend)
    • /js Client cofeescript and javascript files
    • /css Client stylus and css files
  • /data Files downloaded and managed by the homeserver
    • /cameraSnaps All camera snapshots, files are timestamps
    • /emailTemplates Templates for emails sent by the server, base.html is the base template
  • /public Public files (fonts, images, etc)
  • /server The server coffeescript files
    • /api modules to connect to external devices and services (more on API Modules)
    • /emailActions Custom email actions (handled by the EmailManager)
    • /manager Server managers handling different subjects like weather, lights, etc
  • /views Jade view templates

Please note that some of the above paths can be customized by changing the settings.

Integrating with external devices and services

The /server/api.coffee file is responsible for iterating and starting all API Modules. These modules inherit from a BaseApi class and must implement init, start and stop methods.

Making use of API modules data.

The /server/manager.coffee file is responsible for iterating and starting all Managers. But what is a Manager, you might ask? While the API modules are there to fetch and send data to external devices and services, the managers exist to process and make good use of this data.

Last edited Oct 8, 2014 at 7:17 PM by igoramadas, version 13

Comments

No comments yet.