This repository contains the backend for the RaktSetu project, a Blood Bank Management System designed to streamline blood donation processes, inventory management, and request handling for hospitals. The backend is built using Node.js, Express, and MongoDB.
- Authentication: Manage blood bank staff authentication.
- Blood Bank Management: Handle donor registrations, blood stock, and donation scheduling.
- Hospital Requests: Facilitate blood requests from hospitals and manage availability.
- Emergency Notifications: Send notifications to nearby donors during emergencies.
- Node.js
- Express.js
- MongoDB
- JWT for authentication
- Twilio for SMS notifications
-
Clone the repository:
git clone https://github.com/your-username/raktsetu-backend.git
-
Install the dependencies:
npm install
-
Create a
.envfile in the root of your project with the following variables:MONGO_URI=mongodb://127.0.0.1:27017/your_db_name JWT_SECRET=your_jwt_secret PORT=5000 TWILIO_ACCOUNT_SID=your_twilio_account_sid TWILIO_AUTH_TOKEN=your_twilio_auth_token TWILIO_PHONE_NUMBER=your_twilio_phone_number -
Start the server:
npm start
The server will run on
http://localhost:5000.
- Login
- POST
/api/auth/login - Request Body:
{ "email": "[email protected]", "password": "password123" } - Response:
{ "token": "your_jwt_token", "staff": { "_id": "staff_id", "name": "Staff Name", "email": "[email protected]" } }
- POST
-
Register Donor
- POST
/api/bloodbank/register - Request Body:
{ "name": "John Doe", "email": "[email protected]", "bloodType": "O+", "phone": "1234567890" } - Response:
{ "message": "Donor registered successfully", "donor": { "_id": "donor_id", "name": "John Doe", "email": "[email protected]", "bloodType": "O+", "phone": "1234567890" } }
- POST
-
Update Donor Information
- PUT
/api/bloodbank/donors/:id - Request Body:
{ "name": "John Doe", "email": "[email protected]", "bloodType": "A+", "phone": "0987654321" } - Response:
{ "message": "Donor information updated successfully", "donor": { "_id": "donor_id", "name": "John Doe", "email": "[email protected]", "bloodType": "A+", "phone": "0987654321" } }
- PUT
-
Request Blood
- POST
/api/hospitals/request - Request Body:
{ "hospitalName": "City Hospital", "bloodType": "O+", "units": 3 } - Response:
{ "message": "Request submitted successfully", "request": { "_id": "request_id", "hospitalName": "City Hospital", "bloodType": "O+", "units": 3, "status": "Pending" } }
- POST
-
View Blood Requests
- GET
/api/hospitals/requests - Response:
[ { "_id": "request_id", "hospitalName": "City Hospital", "bloodType": "O+", "units": 3, "status": "Pending" }, { "_id": "request_id2", "hospitalName": "State Hospital", "bloodType": "A-", "units": 2, "status": "Fulfilled" } ]
- GET
- Send Emergency Notification
- POST
/api/notifications/emergency - Request Body:
{ "latitude": 23.0225, "longitude": 72.5714, "bloodType": "O+", "radius": 10 } - Response:
{ "message": "Emergency notifications sent to nearby donors." }
- POST
- Import the API endpoints to Postman using the following JSON collection:
{ "info": { "name": "RaktSetu API", "_postman_id": "uuid", "description": "Postman collection for RaktSetu Backend API", "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json" }, "item": [ { "name": "Auth - Login", "request": { "method": "POST", "header": [], "body": { "mode": "raw", "raw": "{\n \"email\": \"[email protected]\",\n \"password\": \"password123\"\n}" }, "url": { "raw": "http://localhost:5000/api/auth/login", "protocol": "http", "host": ["localhost"], "port": "5000", "path": ["api", "auth", "login"] } } }, { "name": "Blood Bank - Register Donor", "request": { "method": "POST", "header": [], "body": { "mode": "raw", "raw": "{\n \"name\": \"John Doe\",\n \"email\": \"[email protected]\",\n \"bloodType\": \"O+\",\n \"phone\": \"1234567890\"\n}" }, "url": { "raw": "http://localhost:5000/api/bloodbank/register", "protocol": "http", "host": ["localhost"], "port": "5000", "path": ["api", "bloodbank", "register"] } } } ] }
This project is licensed under the MIT License.