Frontend Url - https://ghl-frontend.vercel.app/
Backend Url - https://ghl-production.up.railway.app/
API Docs - https://ghl-production.up.railway.app/api-docs/ (incomplete)
The purpose of this tool (GHL) is to make appointment booking between people a lot easier. The usual process is to exchange mails between people till they find a convenient time.
- NodeJS
- NPM
- Firebase account
ts-nodeinstalled globally (npm install -g ts-node) to run setup script
-
Clone the repository
-
Run
npm install -
Create a
.env.localfile in the root of the project and add the following variables:AVAILABILITY_START_TIME=9 AVAILABILITY_END_TIME=11 DURATION=30 TIMEZONE=America/Los_Angeles -
Create a Firebase project and add initialize Firestore Database
-
Create a service account for the project and add the credential file to
src/config/serviceAccount.json -
Run
ts-node command/setup.tsto create the database structure -
Run
npm run devto start the development server
View the API documentation at API Docs
I have used firestore as the database in this project. there is a single collection called events which consists of the following properties -
- startTime(Timestamp) - session start time
- endTime(Timestamp) - session end time
- metadata(optional object) - was intended to support custom form data like name, email, phone. but did not implement.
For backend application I went for a typescript-express stack. I used the typescript-express-starter template to initialize the project.
- get date range, event duration and timezone in query
- validate input for invalid date range, duration and timezone
- get all time slots in date range, divide time by duration in minutes and store start time of each slot in an array
- filter slots to keep only the ones that fall inside the owner's availability time range
- compare with events to check for conflict that fall within the requested time range (in actual implementation I missed this part and I am camparing with all events. this can be improved)
- for the remaining slots which do not have any conflict, convert the time to user timezone and return to the user.
- get start time and duration in request
- check if slot is in the owner's availability time range
- check for any overlap with existing events
- create event
Run npm run test to run the test suite.
This project is deployed on Railway. The database is hosted on Firebase.