'Grovi' is a place for growers who's willing to take an extra income for their extra harvesting from home gardening or cultivations. The main product for 'Grovi' is a mobile application powered by React-native. This is the backend for that mobile application and the administrator web application which is done using React.
- Mobile application for Growers and Consumers
- Web application for administrators
Grovi uses a number of open source projects to work properly:
- ReactJS - A JavaScript library for building user interfaces
- React-native - Mobile application development tool
- Material UI - A popular React UI framework
- Node.js - Evented I/O for the backend
- Express - Fast node.js network app framework
- PostgreSQL - Relational open source DBMS
- PostGIS - Spatial and Geographic objects for PostgreSQL
- Sequelize - ORM for node.js
-
Install PostgreSQL v13
-
Configure PostGIS
-
Grovi requires Node.js v14+ to run.
Change the directory
cd Backend-API
Create '.env' file in the root folder
Add following details in it
# server
NODE_ENV=development
PORT=5000
HOST=localhost (if you are in production environment, use 'grovi-backend.herokuapp.com')
# authentication
JWT_SECRET=<add a secret(random string with 32 characters would be enough)>
JWT_EXPIRES_IN=90d
TWILIO_ACCOUNT_SID=<your_twilio_account_sid>
TWILIO_AUTH_TOKEN=<your_twilio_auth_token>
TWILIO_PHONE_NUMBER=<your_twilio_phone_number>
SMS_SECRET_KEY=<add a secret(random string with 32 characters would be enough)>
# database
DB_USER=postgres
DB_HOST=localhost
DB_DATABASE=grovi
DB_PWD=admin
DB_PORT=5432
# email
EMAIL_HOST=smtp.mailtrap.io
EMAIL_PORT=2525
EMAIL_USERNAME=<mailtrap_email_username>
EMAIL_PASSWORD=<mailtrap_email_password>
# image upload
IMG_CLOUD_NAME=<cloudinary_cloud_name>
IMG_API_KEY=<cloudinary_api_key>
IMG_API_SECRET=<cloudinary_api_secret>
Install the dependencies and devDependencies and start the server.
npm install
npm start
For production environments...
npm install --production
npm run start:prod
For database environments...
Migrate tables into postgres database
npm run migrate
Undo Migrations for all tables
npm run undoMigrate
Populate all tables with provided data (Seeding)
npm run seed
Undo seeding for all tables
npm run undoSeed
Sequelize documentation for migrations - https://sequelize.org/master/manual/migrations.html
Open http://localhost:5000 and take a look around.
- Connect Github branch to Heroku
- Edit config/config.json file with necessary Heroku db credentials
- Add following code snippet to config/config.json file under 'development', 'test', 'production' objects
"dialectOptions": {
"ssl": {
"require": true,
"rejectUnauthorized": false
}
}
- Change cors in app.js as following
app.use(
cors({
origin: `https://grovi-backend.herokuapp.com:${process.env.PORT}`,
credentials: true,
})
);
- Setup configurations as in config.env
- Setup deployment
- Setup pgAdmin remotely by giving necessary credentials.
- Install postgis and postgis_topology extensions from pgAdmin
- From Heroku dashboard CLI do the migrations
heroku run sequelize-cli db:migrate
heroku run sequelize-cli db:seed:all
MIT
Group No: 15
Member | Index No | Github username |
---|---|---|
J.P.A. Shanaka | 18001582 | ashanaka |
D.D. Liyanaarachch i | 18000932 | DDhanushka |
A. H. Dodampe | 18000462 | anjana-dodampe |
A.C.Vidanagamachchi | 18001769 | asinduvg |
G. H. G. M. Madara | 18020471 | ManulMax |