Public | Automated Build

Last pushed: 2 years ago
Short Description
palindromer-node
Full Description

Palindromer

A simple RESTful API to submit and view palindromes. Written using the MEAN stack.

Try it out at palindromer.seanreece.com

#Setup
Palindromer is configured to run out of the box using Docker Containers. Getting it running is as easy as running a few scripts to run the containers.

##In production

Install Docker - On EC2

###Mongo Setup
Palindromer uses MongoDB as a database. For convenience, a script has been included to run Mongo in a docker container.

The docker container uses the WiredTiger storage engine by default to make the best use of the limited RAM and disk space on an amazon EC2 instance. Since WiredTiger compresses all documents and indexes by default less RAM and disk space is used.

Start the MongoDB container

$ sh docker_mongo/create_mongo_container.sh

###Node Setup
Start the Node container

$ sh docker_node/create_node_container.sh

The script will pull the latest seanreece/palindromer image from docker hub (image is auto built from master) and run it in production mode on port 80.
The node container is configured to auto start on AMI boot and restart if the node process stops.

##On OSX
Install boot2docker

then start up the Mongo docker container

$ sh docker_mongo/create_mongo_container.sh

Then find the IP of the boot2docker image

$ boot2docker ip

Add the boot2docker ip as the mongo DB server URL in config.js

###Node
Install palindromer dependancies.

$ npm install

Run palindromer

$ node index.js

Tests

Palindromer comes with some basic API tests using mocha and supertest.
To run the tests first make sure palindromer is running locally then execute this command

$ npm test

API Endpoints

###Messages

Architecture

Palindromer is implemented using AWS using the following resources:

  • EC2 (Elastic Compute Cloud)
    • An instance running MongoDB in a docker container. (A replica set should be used in production)
    • An instance running the palindromer node container is configured and an AMI is created. Multiple instances of this AMI will be launched by the ASG.
  • ASG (Auto Scaling Groups)
    • An auto scaling group is used to spawn new EC2 instances using the palinromer node AMI based on load.
  • ELB (Elastic Load Balancer)
    • ELB is used to distribute http requests evenly accross running EC2 instances.

Sequence Diagrams

Some possible use cases shown using sequence diagrams.

###User adds a message

###User requests all messages then deletes a single message

Docker Pull Command
Owner
seanreece
Source Repository