The Elevate backend repository for the SIH 2023 team uses Express framework with MongoDB and plans to transition to PostgreSQL integrated with Prisma ORM. It addresses challenges faced by shovel operators in large-scale mining by enhancing real-time visibility of dumper load statuses. This proactive system aims to reduce workflow inefficiencies, delays, and potential accidents resulting from the lack of immediate load status insight. Its evolution promises improved safety and efficiency in mining operations, while also setting the groundwork for future scalability and enhanced data management through potential database upgrades.
-
Clone the backend repository:
git clone <backend_repository_url>
-
Clone the frontend repository:
git clone <frontend_repository_url>
-
Navigate to the backend repository and install dependencies:
cd <backend_repository_folder> npm install
-
Navigate to the frontend repository and install dependencies:
cd <frontend_repository_folder> npm install
- Create a
.env
file in the backend repository with the following variables:MONGODB_URL=<your_mongodb_connection_string> SALT_WORK_FACTOR=<your_salt_work_factor_value> PORT=3001 SECRET=<your_secret_key>
-
Start the backend server:
cd <backend_repository_folder> npm start
-
Start the frontend server:
cd <frontend_repository_folder> npm start
Make sure to replace <backend_repository_url>
, <frontend_repository_url>
, <your_mongodb_connection_string>
, <your_salt_work_factor_value>
, and <your_secret_key>
with the actual URLs, values, and keys for your setup.
this is a basic representation of the MongoDB schema, whereas hyperledger is suppose to store the present location and filled status of the dumster and other information related to shovel and dumster
User | Dumpster | Shovel | Queries | Announcements | |||
---|---|---|---|---|---|---|---|
_id | _id | _id | _id | _id | |||
id | name | user | content | ||||
name | name | size | description/status/response | createdAt | |||
password | capacity | worker | |||||
total | driver | ||||||
type | status | ||||||
autho | |||||||
lastLogin | |||||||
History | |||||||
queries ⟶ | [User] | ||||||
equipment | [Dumster/Shovel] | ||||||
onModel | ['dumsters', 'shovels'] |
*The folder structure can be found in backend/database/
-
POST /frontend/authenticate
- Description: Authenticates a user based on their email and password.
- Request Body:
{ "email": "user@example.com", "password": "userpassword" }
- Response:
- Successful authentication:
{ success: true, message: 'Authentication succeeded.', autho: 'generatedToken', name: 'userName' }
- Failed authentication:
{ success: false, message: 'Authentication failed. User not found.' }
or{ success: false, message: 'Authentication failed. Wrong password.' }
- Successful authentication:
-
POST /frontend/register
- Description: Registers a new user.
- Request Body:
{ "name": "UserName", "email": "user@example.com", "password": "userpassword", "type": "userType" }
- Response:
- Successful registration:
{ success: true, message: 'Register succeeded', autho: 'generatedToken', type: 'userType' }
- Failed registration:
{ success: false, message: 'Register failed' + errorMessage }
- Successful registration:
-
Middleware: Token Authentication
- Description: Verifies the token for authentication.
- Parameters:
req.headers['Authorization']
- Response:
- Failed to authenticate token:
{ success: false, message: 'Failed to authenticate token.' }
- No token provided:
{ success: false, message: 'No token provided.' }
- Success (if authenticated): Proceeds to the next middleware or endpoint.
- Failed to authenticate token:
-
GET /frontend/users
- Description: Retrieves users based on type and/or name.
- Query Parameters:
type
,name
- Response:
{ success: true, message: 'Get users succeeded', users: [user1, user2, ...] }
or{ success: false, message: 'Get users failed' + errorMessage }
-
DELETE /frontend/queries/:id
- Description: Deletes a query by ID.
- Parameters:
id
(query ID) - Response:
{ success: true, message: 'Delete queries succeeded', query: deletedQuery }
or{ success: false, message: 'Delete queries failed' + errorMessage }
-
PUT /frontend/queries/:id
- Description: Updates a query's status by ID.
- Parameters:
id
(query ID) - Response:
{ success: true, message: 'Update queries succeeded', query: updatedQuery }
or{ success: false, message: 'Update queries failed' + errorMessage }
-
POST /frontend/queries
- Description: Creates a new query and associates it with a user.
- Request Body:
{ "user": "userID", "description": "Query description" }
- Response:
{ success: true, message: 'Post queries succeeded', query: newQuery }
or{ success: false, message: 'Post queries failed' + errorMessage }
-
GET /frontend/queries
- Description: Retrieves queries with a specific status.
- Parameters:
status
- Response:
{ success: true, message: 'Get queries succeeded', queries: [query1, query2, ...] }
or{ success: false, message: 'Get queries failed' + errorMessage }
-
GET /frontend/dumpsters_shovels_summary
- Description: Retrieves a summary of the status of dumpsters and shovels.
- Response:
{ success: true, message: 'Get dumpsters_shovels_summary succeeded', trueDumper: trueDumperCount, falseDumper: falseDumperCount, trueShovel: trueShovelCount, falseShovel: falseShovelCount }
or{ success: false, message: 'Get dumpsters_shovels_summary failed' + errorMessage }
-
GET /frontend/announcements
- Description: Retrieves announcements sorted by creation date.
- Response:
{ success: true, message: 'Get announcements succeeded', announcements: [announcement1, announcement2, ...] }
or{ success: false, message: 'Get announcements failed' + errorMessage }
-
POST /frontend/announcements
- Description: Creates a new announcement.
- Request Body:
{ "content": "Announcement content" }
- Response:
{ success: true, message: 'Post announcements succeeded', announcement: newAnnouncement }
or{ success: false, message: 'Post announcements failed' + errorMessage }
-
GET /frontend/dumpsters_shovels
- Description: Retrieves all dumpsters and shovels along with their respective drivers.
- Response:
{ success: true, message: 'Get dumpsters_shovels succeeded', dumper: [dumper1, dumper2, ...], shovel: [shovel1, shovel2, ...] }
or{ success: false, message: 'Get dumpsters_shovels failed' + errorMessage }
-
POST /frontend/dumpster
- Description: Creates a new dumpster.
- Request Body:
{ "id": "dumpsterID", "name": "DumpsterName", "capacity": "dumpsterCapacity" }
- Response:
{ success: true, message: 'Post dumpster succeeded', dumper: newDumper }
or{ success: false, message: 'Post dumpster failed' + errorMessage }
*the folder structure can be explored as backend/router
*The backend is also suppose to serve the statics i.e. build of react i.e the admin page