GithubHelp home page GithubHelp logo

tnas / alticci-sequence Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 6.01 MB

Altice Labs Technical Exercise

Java 37.84% Dockerfile 2.46% TypeScript 31.11% CSS 16.29% HTML 11.16% Shell 1.14%
angular-14 java-17 spring-boot swagger2 docker docker-compose

alticci-sequence's Introduction

Altice Labs Technical Exercise

Table of contents

Description

Deverá ser implementado um serviço REST utilizando uma framework JAVA que devolve um valor da sequência Alticci.

Opcionalmente poderá ser implementado um GUI web simples em JavaScript para consultar o serviço.

A sequência Alticci - a(n) - é definida da seguinte forma:

n=0 => a(0) = 0
n=1 => a(1) = 1
n=2 => a(2) = 1
n>2 => a(n) = a(n-3) + a(n-2)

Exemplo dos primeiros valores da sequência:

0
1
1
1
2
2
3
4
5
7
9
[…]

O endpoint a criar será da forma <baseurl>/alticci/{n} em que o {n} representa o índice da sequência para o qual pretendemos obter o valor.

O serviço implementado deverá tirar partido de cálculos passados para acelerar cálculos futuros (caching).

Resposta deverá incluir:

  • Código fonte
  • Documentação das APIs ReST – formato Open API (Swagger)
  • Instruções para execução (em containers ou outra)

Caso existam dúvidas em relação a qualquer ponto que possa influenciar a implementação, o candidato deverá tomar decisões e avançar de acordo com os pressupostos assumidos (que devem ser incluídos na resposta ao exercício).

Tech Stack

  • JDK 17
  • Spring Boot 2.7.6 (Java framework)
  • Maven 3.6.3
  • Swagger 2
  • Angular 14
  • Junit 5 (Unit tests)
  • Docker 20.10.21

Implementation

The API computes the Alticci sequence up to the limit of 1000 elements.

Run Locally

To run the application locally, execute both the front-end (SPA application) and back-end (Restful API).

Restful API

In the backend folder, run the command mvn install to build the application. Such a command also prepares the application for the containerization.

In the backend/target folder, execute the command java -jar alticci-0.0.1-SNAPSHOT.jar to run the API on port 8080.

Single Page Application

In the frontend folder, execute the command ng serve --open to run the application.

To build the application in preparation for containerization, run the command ng build --configuration=production.

Containerization

The application can be run in three ways.

Docker

A Dockerfile was created for each application part - back-end and front-end. A bash script has been prepared to facilitate the Docker image building and container creation.

Inside each application folder (backend and frontend), run the script through the ./docker_build_run.sh command.

Note 1: You must give execution permission to the bash script. For this, run the command chmod +x docker_build_run.sh.

Note 2: The application build is not part of the Docker image building and container creation phases. It means that, before run docker or docker-compose commands, both applications must be built. In other words, the Restful API .jar file must be generated, as well as the SPA static files.

Docker Compose

Another way to run the application is using the docker-compose.yml file available in the root folder of the project. In that folder run the command docker-compose up. Once both containers are running, access the application via the URL http://localhost:8000.

Docker Hub

The simplest way to have the application running on localhost is using the Docker images available on the Docker Hub. Again, the Docker Compose can be used for this.

In the dockerhub folder, just run the docker-compose up command.

Note: This way to run the application eliminates the need to build the back-end (.jarfile) and the front-end (SPA static files) locally.

API Documentation

The Restful API has been documented following the Open API standard. The Swagger was employed for such documentation. It is available at http://localhost:8080/swagger-ui/.

alticci-sequence's People

Contributors

tnas avatar

Watchers

 avatar

alticci-sequence's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.