https://github.com/harshproj/whatbytes
Live at:
https://github.com/harshproj/whatbytes
Last synced: about 2 months ago
JSON representation
Live at:
- Host: GitHub
- URL: https://github.com/harshproj/whatbytes
- Owner: HarshProj
- Created: 2025-02-17T13:45:01.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-02-19T07:46:59.000Z (over 1 year ago)
- Last Synced: 2025-02-19T08:22:32.278Z (over 1 year ago)
- Language: JavaScript
- Homepage: https://whatbytes-ebv9.onrender.com
- Size: 35.2 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Healthcare Backend API
## 🚀 Overview
This project is a **backend system** for a healthcare application built using **Node.js, Express.js, and PostgreSQL**. It provides secure authentication and allows managing **patients, doctors, and their assignments**.
## 🏗 Tech Stack
- **Backend**: Node.js, Express.js
- **Database**: PostgreSQL (via Sequelize ORM)
- **Authentication**: JWT (JSON Web Token)
- **Environment Management**: dotenv
## 📌 Features
✅ **User Authentication** (Register/Login)
✅ **Secure JWT-based API access**
✅ **CRUD operations for Patients & Doctors**
✅ **Patient-Doctor Mapping**
✅ **Error Handling & Validation**
## ⚙️ Setup Instructions
### 1️⃣ Clone the Repository
```sh
git clone [https://github.com/your-username/healthcare-backend.git](https://github.com/HarshProj/WhatBytes.git)
```
### 2️⃣ Install Dependencies
```sh
npm install
```
### 4️⃣ Run Database Migrations
```sh
npx sequelize db:migrate
```
### 5️⃣ Start the Server
```sh
npm run dev
```
## 📌 API Endpoints
### 🔐 Authentication APIs
| Method | Endpoint | Description |
|--------|---------|-------------|
| POST | `/api/auth/register` | Register a new user |
| POST | `/api/auth/login` | Login and get JWT token |
### 🏥 Patient Management APIs
| Method | Endpoint | Description |
|--------|---------|-------------|
| POST | `/api/patients` | Add a new patient (Auth required) |
| GET | `/api/patients` | Get all patients of the authenticated user |
| GET | `/api/patients/:id` | Get details of a specific patient |
| PUT | `/api/patients/:id` | Update patient details |
| DELETE | `/api/patients/:id` | Delete a patient record |

### 👨⚕️ Doctor Management APIs
| Method | Endpoint | Description |
|--------|---------|-------------|
| POST | `/api/doctors` | Add a new doctor (Auth required) |
| GET | `/api/doctors` | Retrieve all doctors |
| GET | `/api/doctors/:id` | Get details of a specific doctor |
| PUT | `/api/doctors/:id` | Update doctor details |
| DELETE | `/api/doctors/:id` | Delete a doctor record |

### 🔗 Patient-Doctor Mapping APIs
| Method | Endpoint | Description |
|--------|---------|-------------|
| POST | `/api/mappings` | Assign a doctor to a patient |
| GET | `/api/mappings` | Get all patient-doctor mappings |
| GET | `/api/mappings/:patientId` | Get doctors assigned to a patient |
| DELETE | `/api/mappings/:id` | Remove a doctor from a patient |
## 🔥 Usage Example
### **1️⃣ Register a User**
```http
POST /api/auth/register
```
#### Request Body
```json
{
"name": "John Doe",
"email": "john@example.com",
"password": "securepassword"
}
```
#### Response
```json
{
"message": "User registered successfully",
"token": "your_jwt_token_here"
}
```
### **2️⃣ Add a New Doctor**
```http
POST /api/doctors
Authorization: Bearer
```
#### Request Body
```json
{
"name": "Dr. Smith",
"specialization": "Cardiology",
"experience": 15
}
```
#### Response
```json
{
"id": 1,
"name": "Dr. Smith",
"specialization": "Cardiology",
"experience": 15,
"createdAt": "2025-02-17T12:00:00Z",
"updatedAt": "2025-02-17T12:00:00Z"
}
```
## 🛠 Troubleshooting
**Issue:** `Missing script: "dev"`
- Ensure `package.json` contains:
```json
"scripts": {
"dev": "nodemon index.js",
"start": "node index.js"
}
```
**Issue:** `Error: secretOrPrivateKey must have a value`
- Add `JWT_SECRET` in `.env` file.
## 📜 License
This project is **open-source** under the MIT License.
---
**🚀 Happy Coding!**