pablolopesk8 / autocomplete-datamanipulation

Auto complete and Data Manipulation service to resolve the Challenge for hiring process on Dito

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

autocomplete-datamanipulation

Auto complete and Data Manipulation service to resolve the Challenge for hiring process on Dito

Overview

This repository contains an API service, a Database service and a Frontend service.
Those services, integrated, provide ways to POST events, GET events and GET timeline.

Language and Libraries

NodeJS, was chosen as language to develop the API.
Some libraries was used with NodeJS:

  1. Express - used to manage and to configure the routes of API
  2. BodyParser - used because of the necessity to parsing the requests
  3. Request Pomisse Native - used to enable the use of promisses natively, with async / await
  4. Dotenv - used to store enviroment variables
  5. Cors - used to avoid errors when accessing the API in a localhost browser

ReactJS was chosen as language to build the frontend interface.
One library was used with ReactJS:

  1. AutoSuggest - used to create an auto complete component.

Linter

Used ESLint with the basic NodeJS configuration. The linter is configurated only in development enviroment.

Enviroment Variables

To store common variables that will be use in some parts of code, was used Dotenv.
There is one .env example file on repository. You need to create a .env file and put your own values here. Remember, your .env file will not be commited to the repository.

Validator

To get validation of data, was used AJV.

Database

MongoDB was used as storage. The reasons for this choice are, mainly, the speed and the simplicity of the data.
For connect and execute operations in database, was used Mongoose.
MongoDB was configured with auth to provide more security.

Server

In development mode, was used Nodemon.

Microservices

Docker was chosen to create to services for this application:

  1. NodeJS Server: a simple server, with the minimum configuration, running node and exposing the port 3005
  2. MongoDB Server: a server with minimum configuration, running MondoDB and exposing the port 3006
  3. Frontend Server: a simple server, using NodeJS, NPM and Webpackage and exposing the port 3007

Endpoints

In the API there are 3 endpoints:

  1. GET a list of events, filtering by name
  2. POST a new event
  3. GET a timeline, with a list of events

For more details about the API, use the file (docs/dito_autocomplete.postman_collection.json) with Postman.

Running

To running this project, the best way is up the docker, because it will up NodeJS, MongoDB and Frontend services. And all are integrated. For this, use

docker-compose up -d

If you want to run only the NodeJS service, you can run (inside /api folder)

npm run start:dev

If you want to run only the Frontend service, you can run (inside /front folder)

npm start

If you run only NodeJS service, you need start manually the container of database. And your connection with mongo, configured on env file, must be done using localhost:exposed_port.

Tests

For the tests was used Mocha as library to execute and to describe the tests. For the assertion and validation was used ShouldJS. For faker returns and throws of server, was used Sinon. And for HTTP tests was used Supertest.
To run the tests, run (inside /api folder)

npm test

My suggestion is to run the tests outside a container. For this, you need to update the env file changing the MONGODB_HOST and MONGODB_PORT to your localhost configuration, like localhost and 3006

IDE

The VSCode was chosen as the IDE to develop this API. Was created config about that IDE and the file is [docs/vscode.config.json] with configurations about Debug using mocha, that can be used for anybody.

About

Auto complete and Data Manipulation service to resolve the Challenge for hiring process on Dito

License:Apache License 2.0


Languages

Language:JavaScript 97.9%Language:Dockerfile 1.9%Language:HTML 0.2%