Skip to content

Backend

Sinval de Deus Vieira Júnior edited this page Sep 6, 2021 · 4 revisions

Backend

Introduction

The backend is written using Javascript and the Express framework. It is also integrated with a MongoDB cloud database and the PokeAPI service. You can see here how this was done.

Architecture

The first thought while building the architecture was to make the application less dependent of the external services as possible. Since all the key information is elsewhere, the application needs to make request to get then all the time.

Basic Architecture view

Basic architecture

Controller

The Controller is responsible to communicate the correct response to the user and to call the service to get the requested data.

Service

The Service is responsible for understanding the business logic, it knows where to look for the information and aggregate them.

External layers

The external layers are a protection for the uncontrolled changes. If some external service or database is changed, this components can be easily replaced.

Client

The Client is responsible for knowing how to communicate to the external services and how to build the entities for the application.

  • PokeAPI Client: A Pokémon data is divided in very different aspects (basic, species, evolution, habitats, etc). This client knows how to travel inside the API's data and get each information and build the Application's entity. Example: To get the evolution chain of a Pokémon, first you get their species stats, then you get the Evolution Chain of that Pokémon and you run an algorithm that travels trough the chain and finds the evolution.

Repository

The Repository is responsible for knowing how to communicate with the database.

Clone this wiki locally