/reputation-service

🚀 Interep back-end and front-end.

Primary LanguageTypeScriptMIT LicenseMIT

Interep reputation service

Interep back-end and front-end.

GitHub Workflow Status Coveralls DeepScan grade Linter eslint Code style prettier Repository top language

Please, visit our web app or our documentation website for more details.


Code overview

This repository contains the frontend and backend code of the Interep application.

The backend code consists mainly of APIs, controllers and core functions. Next.js maps the application's page and api routes to files in the src/pages directory. Each API is associated with a handler/controller in the src/controllers directory, which checks that the request parameters are correct. If these checks are passed and the request needs more complex logic, the core functions are used, otherwise the db methods are called directly.

The frontend consists of the pages defined in the src/pages directory. These pages are React components that in turn use the shared components in the components directory. The style of the Web application is defined in the src/styles directory, while src/context and src/hooks contain React contexts and hooks respectively.

The services in the src/services folder usually contain external services APIs, while the src/tasks folder contains tasks that run externally to Next.js. Finally, the src/config.ts file contains the environment variables and data about the Ethereum network and contracts.

The code is usually organized in modules (e.g. src/core/groups), where each function corresponds to a file with the same name, and an index.ts file exports all the functions of the module. Each module also contains an index.test.ts file where Jest tests are defined for each function in the module. Test files follow a standard structure for each module.

Install

Clone this repository and install the dependencies:

git clone https://github.com/interep-project/reputation-service.git
cd reputation-service
yarn

Usage

Copy the .env.example file and rename it .env.

All environment variables need to be provided. The format for the MongoDB URI is described here.

Running tests

yarn test

Seeding

To seed the db you can run:

yarn db:seed-zero-hashes # required

If you want to reset the db you can run:

yarn db:reset # it will insert the zero hashes

Running Interep (development)

yarn dev

The pages auto-update as you edit files.

To test all the features, you will need to deploy the Interep contracts in a local network.

Running Interep (production)

NODE_ENV === 'production'

Build

yarn build

Start the server

yarn start