/manufacturate

Web platform for creating and publishing ratings of manufacturers.

Primary LanguageTypeScriptMIT LicenseMIT

Manufacturate

Manufacturate is a web platform for creating evidence-based ratings of manufacturers. It is developed using modern web technologies such as Next.js, React and TypeScript.

This repository contains implementation for personal care products segment called Fair about care. However, it is customizable to any kind of a product.

Running the application

First,the MongoDB database needs to be set up, next the environmental variables must be configured. Then, the application can be run locally or deployed.

Dependencies

  • MongoDB database
  • node.js
  • Yarn

0. Clone the repository

1. Set up the database

Create the MongoDB database -- I recommend setting up the shared cluster at MongoDB Atlas for free. Then, copy the database connection URI and the database name.

2. Set environmental variables

Create .env.local file and set following environmental variables:

  • NEXTAUTH_URL denoting canonical URL of the application -- put https://localhost:3000 if you want to run the app locally;
  • SECRET which is a random string used to hash tokens, sign cookies, and generate keys;
  • JWT_SIGNING_PRIVATE_KEY that is a key used to sign the token,this key must be generated by HS512 algorithm;
  • JWT_ENCRYPTION_KEY which is a A256GCM key used for encryption of the JWT;
  • MONGODB_URI specifying the connection URI to the MongoDB database -- use copied URI from previous step;
  • MONGODB_DB_NAME which stands for the name of the database that is used -- use DB name from previous step;

To generate keys for encryption you can use JS package node-jose or generate keys online here.

Using node-jose

JWT_ENCRYPTION_KEY: jose newkey -s 256 -o -a A256GCM

JWT_SIGNING_PRIVATE_KEY: jose newkey -s 256 -t oct -a HS512 If you want to run application locally, your .env.local file might look like:

NEXTAUTH_URL=http://localhost:3000
SECRET=super123123random19283912370and2d6Xe0NmHySeCrEt
JWT_SIGNING_PRIVATE_KEY={"kty":"oct","kid":"wodw0CQ1KG21
  BZ6qcE0nZNIsML-yHd6Xe0NmHyMhzIo","alg":"HS512","k":"WyEWb
  GCUeOKUwOh6juU9pmoj9PjW5JbgN-80utVDH3g"}
JWT_ENCRYPTION_KEY={"kty":"oct","kid":"B2C6Y4FQrJ5KSyREkk
  vRDwttIizi7ZrnkolQ0CdiGAM","alg":"A256GCM","k":"mffv4RlgW
  eXBCrQM0EVLliVHtsjflqZGAGDh4QT218Y"}
MONGODB_URI=mongodb+srv://user:password@db.url.mongodb.net/
  test?retryWrites=true&w=majority
MONGODB_DB_NAME=test

3. Install JS dependencies and run the server

Run yarn command in terminal to install the dependencies. If you were successful, now build the application and run the server with command yarn build && yarn start. The application will now build and the run on port 3000 on localhost. During the build, database will be initialized and indexed and the administrator account will be created with username admin and password admin.