Initial commit. The core logic mostly implemented. The REST api stuff is not.