Skip to content

Repository files navigation

Created by: Alexandre Fortes Tondello

Lemon - Eligibility

Not all clients who wish to join Lemon can be accepted at this time. This may be due to regulatory reasons or because it is not beneficial for either the client or Lemon. During the client acquisition process, we perform an eligibility check based on the data in the client's electricity bill. If the client is not eligible, we need to clearly state the reasons. If the client is eligible, we also need to calculate the projected amount of CO2 they would avoid emitting by using clean energy.

Eligibility Criteria

To determine eligibility, we will apply the following criteria:

  • Consumption Class
    • Possible Values: "Comercial", "Residencial", "Industrial", "Poder Público", and "Rural".
    • Eligible: "Comercial", "Residencial" and "Industrial".
  • Tariff Mode
    • Possible Values: "Branca", "Azul", "Verde" and "Convencional".
    • Eligible: "Convencional" and "Branca".
  • Minimum Consumption
    • The calculation should use the average of the 12 most recent consumption values.
      • Clients with a single-phase connection are eligible if their average consumption is greater than or equal to 400 kWh.
      • Clients with a two-phase connection are eligible if their average consumption is greater than or equal to 500 kWh.
      • Clients with a three-phase connection are eligible if their average consumption is greater than or equal to 750 kWh.

Carbon emission savings

To calculate the annual CO2 savings projection, we consider that generating 1000 kWh in Brazil emits an average of 84kg of CO2.

How it works

The SGRN API is built using the NestJS framework, which is a powerful and scalable Node.js framework.

Endpoints

The API offers the following endpoints:

API Endpoints:

  1. POST /eligibility/verify - Verifies whether a client qualifies to become a Lemon customer
Parameter Type Description Example
numeroDoDocumento string (Required) CPF or CNPJ - 11 to 14 decimal characters 14041737706
tipoDeConexao string (Required) Type of connection (1) bifasico
classeDeConsumo string (Required) Consumption class (2) industrial
modalidadeTarifaria string (Required) Tariff Mode (3) verde
historicoDeConsumo number[] (Required) Historical energy consumption - 3 to 12 values [10,20,15]

(1) tiposDeConexao: monofasico, bifasico, trifasico

(2) classesDeConsumo: residencial, industrial, comercial, rural, poderPublico

(3) modalidadesTarifarias: azul, branca, verde, convencional

How to use it

To run the API locally, follow these steps:

  1. Install Node.js (Version 18 or higher is recommended)
  2. Install yarn: npm i -g yarn
  3. Unzip the project's .zip file or clone the repository to your local machine
  4. Navigate to the project's directory: cd lemon
  5. Install package dependencies: yarn

Running the Server

  1. Start the API server:
yarn start

The API server will now be running at http://localhost:3000

You can use tools like Postman or Curl to test the API endpoint at http://localhost:3000/eligibility/verify

Other Information

Automated Tests

Unit tests and end-to-end tests are written for all major functions and application flows.

To run automated tests:

yarn test

Thank you

Thank you for using Lemon API! Happy coding! 🚀

About

Client eligibility verification

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages