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.
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.
- The calculation should use the average of the 12 most recent consumption values.
To calculate the annual CO2 savings projection, we consider that generating 1000 kWh in Brazil emits an average of 84kg of CO2.
The SGRN API is built using the NestJS framework, which is a powerful and scalable Node.js framework.
The API offers the following endpoints:
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
To run the API locally, follow these steps:
- Install Node.js (Version 18 or higher is recommended)
- Install yarn:
npm i -g yarn - Unzip the project's .zip file or clone the repository to your local machine
- Navigate to the project's directory:
cd lemon - Install package dependencies:
yarn
- 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
Unit tests and end-to-end tests are written for all major functions and application flows.
To run automated tests:
yarn test
Thank you for using Lemon API! Happy coding! 🚀