Skip to content

Demo application for NGINX Unit - 8 microservices in 8 languages

License

Notifications You must be signed in to change notification settings

lcrilly/unit-calculator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

47 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

UnitCalc 9000

A demo application that implements a simple desktop calculator to highlight various capabilities of NGINX Unit.

UnitCalc screenshot

Application Architecture

UnitCalc 9000 is a web application with the following characteristics:

  • HTML/CSS/JavaScript frontend to render a familiar desktop calculator
  • JSON/REST backend API that implements the mathematical operations
  • Each mathematical operation is implemented as a discrete microservice
    • + Python
    • - Ruby
    • × Java
    • ÷ Node.JS
    • Go
    • PHP
    • x^y Rust (compiled to WebAssembly)
    • 1/x Perl
  • NGINX Unit serves the frontend and backend components on a single port, and without any other dependencies
    • Each of the mathematical operations are routed to their respective application code
    • All other requests are routed to the frontend directory

Installation

Docker

  1. Clone this repo and cd into it
  2. Build Docker image
    • docker build -t unitcalc .
  3. Start the image
    • docker run --name unitcalc -d -p 9000:9000 unitcalc

Debian/Ubuntu

  1. Install Unit (Debian, Ubuntu)
  2. Install all the language modules
    • apt install unit-dev unit-go unit-jsc20 unit-perl unit-php unit-python3.11 unit-ruby unit-wasm
  3. Install the Node.JS dependencies
    • apt install nodejs npm
    • npm install body unit-http
  4. Install the Perl dependencies
    • apt install libplack-perl
    • sudo cpan App:cpanminus && sudo cpanm --notest Plack JSON
  5. Clone this repo and cd into it
  6. Create a local configuration for this directory
  • sed "s|/var/www/unit-calculator|${PWD}|g" < unitconf.json > unitconf_local.json
  1. Start NGINX Unit sudo systemctl start unit
  2. Apply the Unit configuration
    • sudo unitc /config ./unitconf_local.json

macOS

  1. Ensure you have Homebrew installed
  2. Clone this repo and cd into it
  3. Install the prerequisites (this will also create a Unit configuration for the current directory)
    • macos-prep.sh
  4. Start NGINX Unit
    • unitd --control 127.0.0.1:8080
  5. Apply the Unit configuration
    • unitc /config ./unitconf_local.json

Demonstration

About

Demo application for NGINX Unit - 8 microservices in 8 languages

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published