The application was developed on a Mac running BigSur with the following environment:
- Ruby v 2.7.3 (via rbenv)
- Bundler v 2.1.4
- Ruby
- Sinatra
The api was run on an Ubuntu 20.04 virtual machine via VM Fusion.
-
I created a new VM and installed the following packages via apt:
-
build-essential
-
curl
-
file
-
git
-
imagemagick
-
libmagickwand-dev
-
ghostscript
-
I used RVM and installed Ruby v2.7.3
-
For the client, I installed nvm and installed v12.16.1
-
I then installed yarn via npm.
The API uses ImageMagick to convert PDF files to images. A functionality that has been disabled in Ubuntu and requires editing the ImageMagick policy.xml file. Run the following (if you need to on your machine of VM) A VM is recommended.
- Use whatever text editing method you like to edit the following file
/etc/ImageMagick-6/policy.xml
- Comment out or delete the following line:
<policy domain="coder" rights="none" pattern="PDF" />
- Pull Repo to local environment
- Run the following at the project's root
- Run
bundle install
to install required Gems - Run
ruby start_rackup
to start the application in local development mode - The application will run at http://localhost:9292/api/
- Run
- API uses JWT for authentication.
- As a proof of concept, a self signed certificate was used to create a long lived token (6 months) that is embeded in the client.
- The API embeds the public keys from the certificate in order to validate the long lived token.
- As a POC, no database was created, instead a flat JSON file is used to store and retreive data for the client.
- The Dockerfile needs to be updated to account for the ImageMagick policy issues and to install ImageMagick and Ghostscript in the image.