NPS
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
Topics
- Project
- About
- Example of How it Works
- Techs
- Backend
- For Dev
- Use API
- How to Clone
- How to Configure
- How to Run
- Documentation (to learn about developing an API)
- References (materials)
- Author
- License
Project
know the project, the technologies used for its construction and if you want to use the API, see how to use it.
About
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:
Example of How it Works
Techs
Backend
- 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
For Dev
- Code Editor: Visual Studio Code
- Terminal: Git Bash
- Package Manager: NPM or Yarn
- API REST Tests: Insomnia
- Database Queries: Beekeeper Studio
Use API
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:
How to Clone
To perform your cloning we need the Gitbash terminal, which we will do using commands that already automate some processes...
$ git clone https://github.com/FelipePDS/nps.git
# Open
$ cd nps
How to Configure
Before all install the dependencies (technologies used):
# OR
$ npm install
Run 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
How to Run
Before all execute the server:
# 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
User
{
"name": "User Example",
"email": "example@mail.com"
}
Survey
{
"title": "Give your evaluation:",
"description": "From 0 to 10, how much would you recommend Rocketseat?"
}
Send Mail
{
"email": "example@mail.com",
"survey_id": "idOfSomeSearchSavedInTheSystem"
}
NPS Calculate
baseURL/nps/:survey_id (GET Method)
See better how it works
Documentation (to learn about developing an API)
Documentation about the development. To download the documentation follow the commands in Gitbash
$ 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
References (materials)
The entire project was developed during the RocketSeat NLW event, and was aided through documentation as well...
Author
This repository and documentation was made by FelipePDS
License
MIT License * (c) FelipePDS