This repository has the code for the frontend and backend internship assignment by VSCodeHelp. It contains:
- Source Code
- Database Queries
- Dummy data to populate database
- Node (^=v16.15.1)
- MongoDB
- XAMPP
If the above are correctly installed, this website should work on Windows, Mac, and Linux. The server uses https configuration, so you will need to get a ceritification. Since, it is a local build currently, this website can be used.
git clone https://github.com/shivpreet16/vsHealth.git
Open the cloned repository in an editor of your choice.
Alternatively, you can also:
1.1. Download repository as a zip folder on your local machine
1.2. Unzip the folder
1.3. Open the folder in an editor of your choice
For a good balance between performance and flexibility, I have used a polygot / hybrid architecture between SQL and NoSQL. Essentially, there are two types of databases at work:
-
SQL: I have used SQL for transaction heavy features. This includes clinic data, time slots, and appointment data.
For the SQL part, I used MySQL from XAMPP. The detailed schema and queries are present in
server > db.md
. However, on running the server, these will get created if they do not already exist.So, to run on local, follow the given steps:
-
Install XAMPP
-
Go to
server > utils > connect.js
-
Go ro XAMPP mySql shell and run the following commands:
-
mysql -u root -r
CREATE DATABASE VSCODEHELP;
-
In the
sqlConnect
function, ensure that host and dialect are set correctly. If you use password, it can be set with the same set of parameters:{ host: "localhost", dialect: "mysql", logging: false, password: "your-password-here", }
-
NoSQL: I have used NoSQL for variable length data that will not change much and is required by simple retrieval and insertion queries. This includes all the doctor profile related data.
The detailed schema can be seen in
server > models > doctors.model.js
To run on local, you must have MongoDB Compass installed. If you are on Windows, you will have to exclusively install MongoDB SH.
After this, go to
server > utils > connect.js
and ensure that the.connect("localhost path")
is correct in themongoConnect()
function.
-
Open terminal and navigate to the folder containing the cloned repo.
-
Move to the server directory
cd server
- Install all packages
npm install
- Create
.env
file in the server directory. Add the following data
PORT=3000
EMAIL_ADDRESS="[email protected]"
EMAIL_PASSWORD="your-password"
BCRYPT_SALT_ROUNDS=10
JWT_SECRET="your-jwt-secret"
If using a gmail, get the app password. Follow these steps: 1. Go to google account settings. 2. 2FA > app passwords. 3. Paste the password you get from google and not the original password.
- Run the server
npm start
Dummy data is available in server > utils > constants.js
and there are APIs to populate the database. Follow the given steps:
- Add doctor details to mongoDB by making a get request to the following:
https://localhost:3000/doctor/putDoctors
- To get all the doctorIds from mongoDB, make a get request to the following:
https://localhost:3000/doctor/getDocId
copy the ids from the console/cmd
3. Paste the array of copied IDs in the constants server > utils > constants.js
folder.
- To populate the clinics table, make a get request to the following:
https://localhost:3000/clinic/insertClinics
- To populate the slots table, make a get request to the following:
https://localhost:3000/doctor/insertSlot
https://localhost:3000/doctor/insertSlotAv
-
Open terminal and navigate to the folder containing the cloned repo.
-
Move to the client directory
cd client
- Install all packages
npm install
- Run the front-end:
npm run dev