Skip to content

🔢 API for fetching and analyzing integer sequences.

Notifications You must be signed in to change notification settings

BSski/random-ints-st-dev-api

Repository files navigation

Random Integers' Standard Deviation API

Build Status Maintainability CodeFactor

Demo Screenshot

🎆 Live demo 🎆

[Heroku retracted its free tier, therefore all my demos are unavailable until further notice.]

Table of contents

📜 Project description

This is a recruitment task for a Junior Software Developer position.

The project is a REST service supporting the following GET operation:

/random/mean?requests={r}&length={l}

which performs {r} concurrent requests to random.org API asking for {l} number of random integers.

Additionally, the application calculates standard deviation of each drawn integers set and of the sum of all sets.

The project also has a Semaphore CI/CD pipeline with deployment to Heroku via Docker container: CI/CD screenshot

I decided to use runtime.GOMAXPROCS(1), since random.org guidelines (https://www.random.org/clients/) prohibit sending simultaneous requests by automated clients. In accordance with the guidelines the timeout is set to 180 seconds.

🔨 Technologies used

  • random.org API
  • Go 1.18
  • go-chi/chi/v5 5.0.7
  • google/go-cmp 0.5.8
  • joho/godotenv 1.4.0
  • montanaflynn/stats 0.6.6
  • cosmtrek/air 1.40.4
  • Docker

🛠️ Deployment

If you want to run the application, you have to supply your own API key and your email address (the guidelines require random.org API client's email supplied in the "User-Agent" header) in the .env file .

  1. Create an .env file basing on .env_sample_file from the repository. Set PORT to 8080.

  2. Run docker run --env-file .env -p 8080:8080 bsski/random-ints-st-dev-api:latest in the .env file directory.

  3. Access localhost:8080/random/mean?requests=2&length=3.

🔐 Environment variables

To run this project, you have to set up the following environment variables in the .env file (the values below are exemplary):

RANDOM_ORG_API_KEY=af83r3m2-mv82-z327-12m9238hjqdn
[email protected]
PORT=8080

⬆️ Room for improvement

  • more tests

👷 Author

About

🔢 API for fetching and analyzing integer sequences.

Topics

Resources

Stars

Watchers

Forks