A REST API for managing user authentication and medicine tracking.
- 🔧 User Authentication: Secure signup and login functionality using JWT.
- 💊 Medicine Management: Add, update, and delete medicine entries for users.
- ⏰ Event Scheduling: Set dosage, time, and frequency for medication reminders.
- 🔒 Data Security: Password hashing with bcryptjs for secure user data storage.
- 🗄️ Data Persistence: Utilizes MongoDB for persistent data storage.
- 🚀 Easy Setup: Straightforward installation and configuration process.
- ⚙️ Customizable: Easy update dosage ,time,frequency
| Category | Technologies | Documentation |
|---|---|---|
| Backend | Node.js | https://nodejs.org/en/docs/ |
| Framework | Express | https://expressjs.com/ |
| Database | MongoDB | https://www.mongodb.com/docs/ |
| ORM | Mongoose | https://mongoosejs.com/docs/ |
| Authentication | jsonwebtoken | https://www.npmjs.com/package/jsonwebtoken |
| Password Hashing | bcryptjs | https://www.npmjs.com/package/bcryptjs |
| Development | nodemon | https://www.npmjs.com/package/nodemon |
| Environment | dotenv | https://www.npmjs.com/package/dotenv |
- Node.js (v18 or higher)
- MongoDB (running locally or accessible via a connection string)
bash git clone [repo-url] cd server npm install # or yarn install
Create a .env file in the server/ directory with the following variables:
env PORT=3001 JWT_SECRET=exampleKeyforToken
Note
The JWT_SECRET should be a long, random string for security. Do not use the example provided in a production environment.
bash npm start # Start development server
yarn start
The project does not contain explicit testing setup. To implement testing:
-
Install testing libraries such as Jest and Supertest:
bash npm install --save-dev jest supertest
yarn add --dev jest supertest
-
Create test files (e.g.,
*.test.js) to test API endpoints and functionality.
| Method | Endpoint | Body | Response |
|---|---|---|---|
| POST | /auth/signUp | { phoneNumber: "string", password: "string" } |
201 Created, { token: "string", user: { _id: "string", phoneNumber: "string" }} |
| POST | /auth/login | { phoneNumber: "string", password: "string" } |
200 OK, { token: "string", user: { _id: "string", phoneNumber: "string" }} |
| GET | /medicine/:userid | None | 200 OK, { medicines: [ { _id: "string", medicineName: "string" } ] } |
| POST | /medicine/:userid | { medicineName: "string", description: "string", image: "string" } |
201 Created, { message: "Medicine added", medicine: { _id: "string", medicineName: "string" } } |
| PUT | /medicine/:id/:userid | { medicineName: "string", dosage: "string", time: ["string"], frequency: "string", description: "string", image: "string" } |
200 OK, { message: "Medicine updated", medicine: { _id: "string", medicineName: "string" } } |
| DELETE | /medicine/:id/:userid | None | 200 OK, { message: "Medicine deleted" } |
| PUT | /medicine/event/:id/:userid | { dosage: "string", time: ["string"], frequency: "string" } |
200 OK, { message: "Medicine updated", medicine: { _id: "string"} } |
A Dockerfile is not provided. A sample Dockerfile is shown below.
dockerfile FROM node:18-alpine WORKDIR /app COPY package*.json ./ RUN npm install --omit=dev COPY . . EXPOSE 3001 CMD ["node", "app.js"]
To build and run the Docker container:
bash docker build -t medtrack-api . docker run -p 3001:3001 medtrack-api
- Create a new branch with a descriptive name:
feat/new-featureorbugfix/issue-123. - Follow conventional commit message standards. For example:
feat: Add user authentication. - Submit a pull request with a clear description of the changes.