NPS API (Net Promoter Score)
Calculation of the NPS of a company, in which it is provided based on the evaluation of the users. The company can calculate the NPS for the diverses subjects it selects. Learn more
- π‘ Project
- π Documentation (to learn about developing an API)
- β References (materials)
- π¨ Author
- π License
know the project, the technologies used for its construction and if you want to use the API, see how to use it.
The construction of this NPS API (Net Promoter Score) was to facilitate the evaluation process of a company for example. This questionnaire will be sent to the user's e-mail (which may have the text and style you want), where he will give his rating in relation to the subject and thus the NPS will be calculated based on the evaluation of all users.
The process is based on 3 things as a basis:
π€ π β The survey, the user, and the user evaluation,
Survey email for evaluation (Title and description) β User β User evaluation β Saved evaluation correlating the user, the survey and the evaluation β Total NPS calculation, see an example:
- Codes: Node.js && Typescript β ts-node
- Server: Express
- Database:
- SQLite
- Migrations: Typeorm
- Reflect Metadata
- ID Generator: UUID
- Send Mail: Nodemailer
- Tests: Jest Tests
- API Validation: Yup
β Check the file: package.json
- Code Editor: Visual Studio Code
- Terminal: Git Bash
- Package Manager: NPM or Yarn
- API REST Tests: Insomnia
- Database Queries: Beekeeper Studio
Before we see how to use the API, let's understand a little bit about some things about it
π² See data modeling to understand a little about its structure:
To perform your cloning we need the Gitbash terminal, which we will do using commands that already automate some processes...
# To clone repository
$ git clone https://github.com/FelipePDS/nps.git
# Open
$ cd nps
Before all install the dependencies (technologies used):
$ yarn add
# OR
$ npm install
Run the Database:
# Execution made with Typeorm (run the migrations and the database)
$ yarn typeorm migration:run
# OR
$ npm run typeorm migration:run
If you want to change the server's execution port: Go to the .env file, change 3333
from both the PORT and USER_ANSWER_URL_MAIL to the port you want
Before all execute the server:
$ yarn dev
# OR
$ npm dev
# If you have not changed the port, the access URL will be http://localhost:3333/
To perform the execution tests (API Rest) install the Insomnia. Thus it will be possible to send requests for routes...
Take a look at the router.ts file to check the routes and make requests
See what are the parameters needed to make each type of request (and the routes)
- User
- Survey
- Send Mail
- NPS Calculate
/* baseURL/users (POST Method) */
{
"name": "User Example",
"email": "example@mail.com"
}
/* baseURL/surveys (POST Method) */
{
"title": "Give your evaluation:",
"description": "From 0 to 10, how much would you recommend Rocketseat?"
}
/* baseURL/sendMail (POST Method) */
{
"email": "example@mail.com",
"survey_id": "idOfSomeSearchSavedInTheSystem"
}
baseURL/nps/:survey_id
(GET Method)
See better how it works
Documentation about the development. To download the documentation follow the commands in Gitbash
# create a folder with the name of the directorie and enter it
$ mkdir documentation && cd documentation
# start a git repository to access the repository
$ git init
# crawl the repositorie
$ git remote add -f origin https://github.com/FelipePDS/nps
# active sparse checkout
$ git config core.sparseCheckout true
# Create a file in the path: .git/nps/sparse-checkout
# And insert the name of the subdirectory you want to clone
$ echo '.github/documentation/' >> .git/nps/sparse-checkout
# pull the subdirectory
$ git pull origin master
Font: terminalroot.com.br
The entire project was developed during the π RocketSeat NLW event, and was aided through documentation as well...
This repository and documentation was made by FelipePDS π
MIT License Β β’Β Β© FelipePDS