Code Monkey home page Code Monkey logo

sentry's Introduction

Sentry

A RFID doorlock application that integrates with Cobot using Particle Photons.

Note: we are currently under active development. This project is not yet ready to use. Stay tuned!

screenshot

Overview

Sentry is a doorlock access control system using RFID cards, Particle Photons (WIFI connected Arduinos) and Cobot (a co-working space management system).

Sentry consists of two parts:

  • The server
  • The door lock(s)

The server

The brains of Sentry is a Node.js server that

  • Connects to Cobot, getting an updated list of memberships and logging checkins
  • Connects to Particle's API to send and receive messages from the Photons
  • Displays a list of memberships and their current status
  • Displays all connected door lock devices and allows manual syncronization
  • Manual and automatic syncing (a redis job running every 5 minutes) of membership information from Cobot
  • Secured behind HTTP basic authentication (set ADMIN_USERNAME and ADMIN_PASSWORD)
  • Fully deployable to cloud hosts like Heroku or Docker
  • All memberships and checkins are stored in MongoDB so they can be retrieved and logged independently of a connection with Cobot (if Cobot goes down, your system will still work, at least in a limited capacity)

The server supports the concept of "unlimited" plans which are not limited by day passes as well as "staff" plans which allow unlimited access. See the src/config/config.js file for environment configs that control these properties.

Code for the server is located in src/ and the tests live in test/

Static assets (css, js, images) are located in public/. src/assets contains SCSS and ES2015/6/7 JavaScript that will get compiled/transpiled to plain CSS/ES5.

The door locks

The door locks, powered by Particle Photons:

  • Read a scanned RFID card (from a 125khz RFID card using a standard RFID reader)
  • Authenticate the card against a local list of access tokens retrieved from the Node.js server
  • Log checkins into the space locally (who, what time, what door and if it succeeded or not)
  • Periodically syncronize with the Node.js server by sending any recent checkins and then receiving an updated list of access tokens.
  • Uses various means to open the door including an electronic door latch, a servo or some other means yet to be devised.
  • Works with or without WIFI and can have an optional battery backup (syncing of course won't work without WIFI but the local cards will still read properly)
  • Supports writing a display messager to a display including support for color coded messages (green for success, blue for "ready" and red for errors)

The door receives a list of all members within a Cobot account so that it can display a relevant message to a user like:

Hello John, sorry but you're out of day passes. Go to https://chimera.cobot.me to buy more!

Or:

Welcome in Jane, make something awesome today!

These messages are customizable via the admin so you can personalize things to fit your space and community.

Code for the door locks lives in firmware/

Setup

Dependencies:

  • Node v5.x
  • MongoDB

The following should get you setup:

# Install nvm to manage your node versions (optional)
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.29.0/install.sh | bash

# Install the proper node version (looking at the ".nvmrc" file)
nvm install
nvm use

# Install dependencies
npm install

Developing

  • Run the dev server: npm run watch
  • Run the tests: npm test
  • Watch tests: npm run watch-test
  • Wipe and seed the database with sample data: npm run seed

Cobot Integration

To integrate with Cobot, you will need to create an Oauth2 client, update your local configuration and then serve your application. See below for details.

First, copy over the sample environment config file:

cp .env.example .env

Now, create an OAuth2 application on Cobot with the following info (tweak as desired):

  • Name: My Doorlock
  • Main Application URL: http://my-doorlock-app.ngrok.io
  • Redirect URL: http://my-doorlock-app.ngrok.io/auth/cobot/callback
  • Scope: checkin, checkin_tokens, read, read_check_ins, read_memberships, and write

Next, copy your client ID and secret to COBOT_CLIENT_ID and COBOT_CLIENT_SECRET respectively into your .env file. Then set APP_URL to your ngrok address (e.g. http://my-doorlock-app.ngrok.io).

Finally, you will need to serve the application locally using something like ngrok so that you can forward external requests to your local machine:

# In one tab:
npm run watch

# In another tab:
ngrok http --subdomain my-doorlock-app 5555

Now you should be able to open up http://my-doorlock-app.ngrok.io and see your application.

Production

You can run the application with npm start or using foreman foreman start.

You will need to add the Heroku Scheduler app to your Heroku app and then create a job that calls npm run sync-memberships like so:

Deploy

Deploying to something like Heroku:

  • Push to Heroku
  • Setup a MongoDB host (e.g. MongoLab or similar)
  • Set your environment configs (e.g. heroku config:set ...)

Screenshots

Memberships list:

memberships

Device list:

devices

Login with Particle:

Particle login

Authenticate with Cobot

cobot auth

Credits

Developed by Dana Woodman and Alex Wayne of BIG for Chimera Art Space, the first (and coolest) makerspace in Sonoma County, California.

See credits.md for a full list of the awesome people and groups that made this project possible.

License

Copyright © 2015 Built By BIG LLC.

Licensed under an MIT license. See license.md.

sentry's People

Contributors

alexjwayne avatar danawoodman avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

nationofmakers

sentry's Issues

Login flow

  • Authenticate with Cobot (OAuth2)
  • show user info and list of available spaces
  • user chooses to create account for a space
  • create Account for space
  • show plans manager

Plan admin

Add section where a list of all plans are visible and the user can indicate if a plan is "unlimited" or "staff". This will replace the existing environment variables for that.

Allow configuring of Plan types

  • Sync with Cobot the list of plans.
  • Create a Plan model that has:
    • name
    • cobotId
    • unlimitedAccess (boolean) false
    • staff (boolean) false
  • When a member is synced and they have a plan not in our list, create a plan in the DB

Replace the COBOT_STAFF_PLANS and COBOT_UNLIMITED_PLANS settings in favor of this.

Create a job to keep the plans in sync.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.