See the wiki for background on this project.
fibserver is a simple REST server implemented with Spring, for calculating fibonacci sequences. It also comes with an AngularJS front end to demonstrate calling the REST server. It's all glued together with JHipster, which provides monitoring and maintenance screens and other features.
These technologies were chosen specifically for their focus on extensibility and maintainability in a production environment, the key requirement of the project. To learn more about the technology choices, please see Technology Choices.
The front end for the application looks like this:
Type a number between 0 and 200 in the input to print out a fibonacci sequence.
An authenticated user can see health checks for a running instance of the server.
Authenticated users can test calls to the REST services:
An authenticated user can view metrics for a running instance of the server.
This will also show number of server errors per HTTP request.
It may be useful to check the performance statistics for services in production. Authenticated users can check service time in milliseconds for getFibonacciSequence
on the Metrics page, Services Statistics section.
The application is deployed to the EMC Pivotal Cloud Foundry where it can be managed, e.g.
- View the logs
- Scale the application by adjusting number of instances
- Adjust memory available to the instances
These instructions apply to OSX 10.8.2.
- Install Java from the Oracle website.
- Install Maven
- Install Git if not already installed
- Install Node.js from https://nodejs.org/
- Install Yeoman:
sudo npm install -g yo
- Install Bower:
sudo npm install -g bower
- Install Grunt:
sudo npm install -g grunt-cli
- Install JHipster:
sudo npm install -g generator-jhipster
- Check out the project :
git clone https://github.com/lucrussell/fibserver
- Run
mvn spring-boot:run
(or runsrc/main/java/com/mycompany/myapp/Application.java
in your IDE) - Browse to http://localhost:8080
- Create an account on Pivotal Cloud Foundry
- Install the cf CLI here
- Run
yo jhipster:cloudfoundry
Here are a few key parts of the application:
- FibonacciServiceTest.java: Unit test for the FibonacciService.
- FibonacciService.java: This contains the business logic for the calculation.
- FibonacciResource: Exposes the service to POST requests with a REST API.
- main.controller.js: AngularJS file backing main.html. Makes calls to the REST service.
- main.html: HTML page to interact with the service.
You can run mvn:test
on the command line, or run all the tests under src/main/test
in your IDE.
Grunt tests might fail. Ensure they can run by setting up PHANTOMJS_BIN env var, see here.