This repository contains a Therapist Booking Project built using GraphQL and TypeScript. The project aims to create a platform where users can book appointments with therapists for counseling sessions.
- User authentication and authorization
- Search for available therapists and their specialties
- Schedule and manage therapy appointments
- View upcoming and past appointments
- Rate and review therapists based on their services
Register users
Login users
Create review (Auth required)
Find all review
User details
Find all users (Admin role required)
Create therapist by admin (Admin role required)
Therapist count
Find therapist by location
Get all therapist appoinemnt (therapist role required)
Change Appoinemnt status by therapist
Prerequisites
Before running this project, make sure you have the following prerequisites installed on your system:
- Node.js (https://nodejs.org)
- npm (Node Package Manager) or yarn (https://yarnpkg.com)
Installation
Clone this repository to your local machine using:
git clone https://github.com/BaseMax/TherapistBookingGraphQLTS.git
Navigate to the project directory:
cd TherapistBookingGraphQLTS
Install the project dependencies: Using npm:
npm install
Or using yarn:
yarn install
npx prisma migrate dev --name init
Configuration
Create a .env
file in the root directory and add the following environment variables:
# Set enviornment variable :
DATABASE_URL="postgresql://username:password@localhost:5432/your-database?schema=public"
Configure any other necessary environment variables based on your specific setup.
To start the development server, run the following command:
Using npm:
npm run start:dev
Or using yarn:
yarn dev
The server should now be running on http://localhost:3000
(or the port you specified in the .env file). You can access the GraphQL Playground to interact with the API and test various queries and mutations.
The GraphQL API provides the following endpoints:
POST /graphql
: The main endpoint for executing GraphQL queries and mutations.
You can explore the available schema and operations using the GraphQL Playground available at the server's root URL.
query GetTherapists($specialty: String, $location: String, $available: Boolean) {
therapists(specialty: $specialty, location: $location, available: $available) {
id
name
specialty
location
available
}
}
query GetTherapistById($therapistId: ID!) {
therapist(id: $therapistId) {
id
name
specialty
location
available
reviews {
id
rating
comment
}
}
}
query GetAppointments {
appointments {
id
therapist {
id
name
}
date
status
}
}
query GetTherapistSpecialties {
therapistSpecialties {
id
name
}
}
query GetUser {
me {
id
name
email
}
}
query GetTherapistReviews($therapistId: ID!) {
therapistReviews(therapistId: $therapistId) {
id
rating
comment
user {
id
name
}
}
}
GetAvailableAppointments: Fetch a list of available appointments for a specific therapist within a given date range.
query GetAvailableAppointments($therapistId: ID!, $startDate: String!, $endDate: String!) {
availableAppointments(therapistId: $therapistId, startDate: $startDate, endDate: $endDate) {
id
therapist {
id
name
}
date
}
}
query GetUserAppointments($startDate: String!, $endDate: String!) {
userAppointments(startDate: $startDate, endDate: $endDate) {
id
therapist {
id
name
}
date
status
}
}
query GetTherapistAvailabilities($therapistId: ID!) {
therapistAvailabilities(therapistId: $therapistId) {
dayOfWeek
startTime
endTime
}
}
query GetTherapistsByLocation($location: String!, $radius: Float!) {
therapistsByLocation(location: $location, radius: $radius) {
id
name
specialty
location
available
}
}
query GetUpcomingAppointments {
upcomingAppointments {
id
therapist {
id
name
}
date
status
}
}
query GetPastAppointments {
pastAppointments {
id
therapist {
id
name
}
date
status
}
}
query GetTherapistsBySpecialty($specialty: String!) {
therapistsBySpecialty(specialty: $specialty) {
id
name
specialty
location
available
}
}
query GetTherapistCount {
therapistCount
}
query GetUserReviews {
userReviews {
id
therapist {
id
name
}
rating
comment
}
}
GetUserRatings: Get the average rating and the total number of reviews given by the authenticated user.
query GetUserRatings {
userRatings {
averageRating
totalReviews
}
}
GetTherapistRating: Get the average rating and the total number of reviews for a specific therapist.
query GetTherapistRating($therapistId: ID!) {
therapistRating(therapistId: $therapistId) {
averageRating
totalReviews
}
}
query GetUserBookedTherapists {
userBookedTherapists {
id
name
specialty
location
available
}
}
query GetTherapistAvailability($therapistId: ID!, $date: String!) {
therapistAvailability(therapistId: $therapistId, date: $date) {
available
startTime
endTime
}
}
GetUserUpcomingTherapists: Fetch a list of therapists for whom the authenticated user has upcoming appointments.
query GetUserUpcomingTherapists {
userUpcomingTherapists {
id
name
specialty
location
available
}
}
query GetTherapistSchedules($therapistIds: [ID!]!, $startDate: String!, $endDate: String!) {
therapistSchedules(therapistIds: $therapistIds, startDate: $startDate, endDate: $endDate) {
therapist {
id
name
}
schedule {
dayOfWeek
startTime
endTime
}
}
}
GetUserReviewsByRating: Fetch reviews given by the authenticated user based on the specified rating.
query GetUserReviewsByRating($rating: Int!) {
userReviewsByRating(rating: $rating) {
id
therapist {
id
name
}
rating
comment
}
}
query GetTherapistsByLanguage($language: String!) {
therapistsByLanguage(language: $language) {
id
name
specialty
location
available
}
}
query GetTherapistRatingsInRange($minRating: Float!, $maxRating: Float!) {
therapistsByRatingRange(minRating: $minRating, maxRating: $maxRating) {
id
name
specialty
location
available
}
}
GetUserTherapistsBySpecialty: Fetch therapists in a specific specialty who were booked by the authenticated user.
query GetUserTherapistsBySpecialty($specialty: String!) {
userTherapistsBySpecialty(specialty: $specialty) {
id
name
specialty
location
available
}
}
query GetTherapistBookedDates($therapistId: ID!) {
therapistBookedDates(therapistId: $therapistId) {
date
}
}
GetUserTherapistsByLocation: Fetch therapists within a certain radius of the authenticated user's location.
query GetUserTherapistsByLocation($radius: Float!) {
userTherapistsByLocation(radius: $radius) {
id
name
specialty
location
available
}
}
GetTherapistByLocationAndSpecialty: Fetch therapists within a certain radius of a specified location and offering a specific specialty.
query GetTherapistByLocationAndSpecialty($location: String!, $radius: Float!, $specialty: String!) {
therapistsByLocationAndSpecialty(location: $location, radius: $radius, specialty: $specialty) {
id
name
specialty
location
available
}
}
GetUserTherapistsWithUpcomingAvailability: Fetch therapists who have upcoming available slots within a specified date range, and whom the authenticated user has not booked.
query GetUserTherapistsWithUpcomingAvailability($startDate: String!, $endDate: String!) {
userTherapistsWithUpcomingAvailability(startDate: $startDate, endDate: $endDate) {
id
name
specialty
location
available
}
}
query GetTherapistAppointmentsByStatus($therapistId: ID!, $status: AppointmentStatus!) {
therapistAppointmentsByStatus(therapistId: $therapistId, status: $status) {
id
date
status
user {
id
name
}
}
}
GetTherapistsByReviewRating: Fetch therapists based on their average review rating falling within a specified range.
query GetTherapistsByReviewRating($minRating: Float!, $maxRating: Float!) {
therapistsByReviewRating(minRating: $minRating, maxRating: $maxRating) {
id
name
specialty
location
available
}
}
GetUserFavoriteTherapists: Fetch a list of therapists marked as favorites by the authenticated user.
query GetUserFavoriteTherapists {
userFavoriteTherapists {
id
name
specialty
location
available
}
}
query GetTherapistsByYearsOfExperience($minExperience: Int!) {
therapistsByYearsOfExperience(minExperience: $minExperience) {
id
name
specialty
location
available
yearsOfExperience
}
}
query GetUserTherapistAvailability($date: String!, $time: String!) {
userTherapistAvailability(date: $date, time: $time) {
id
name
specialty
location
available
}
}
mutation UpdateUserProfile($input: UserProfileInput!) {
updateUserProfile(input: $input) {
id
name
email
}
}
mutation DeleteUser {
deleteUser
}
mutation CreateTherapist($input: TherapistInput!) {
createTherapist(input: $input) {
id
name
specialty
location
available
}
}
mutation UpdateTherapist($therapistId: ID!, $input: TherapistInput!) {
updateTherapist(id: $therapistId, input: $input) {
id
name
specialty
location
available
}
}
mutation DeleteTherapist($therapistId: ID!) {
deleteTherapist(id: $therapistId)
}
mutation ApproveAppointment($appointmentId: ID!) {
approveAppointment(id: $appointmentId) {
id
therapist {
id
name
}
date
status
}
}
mutation RejectAppointment($appointmentId: ID!, $reason: String!) {
rejectAppointment(id: $appointmentId, reason: $reason) {
id
therapist {
id
name
}
date
status
}
}
mutation AddTherapistToFavorites($therapistId: ID!) {
addTherapistToFavorites(therapistId: $therapistId) {
id
name
specialty
location
available
}
}
RemoveTherapistFromFavorites: Remove a therapist from the authenticated user's list of favorite therapists.
mutation RemoveTherapistFromFavorites($therapistId: ID!) {
removeTherapistFromFavorites(therapistId: $therapistId) {
id
name
specialty
location
available
}
}
mutation CreateTherapistReview($therapistId: ID!, $rating: Int!, $comment: String) {
createTherapistReview(therapistId: $therapistId, rating: $rating, comment: $comment) {
id
rating
comment
user {
id
name
}
}
}
mutation UpdateTherapistReview($reviewId: ID!, $rating: Int!, $comment: String) {
updateTherapistReview(id: $reviewId, rating: $rating, comment: $comment) {
id
rating
comment
user {
id
name
}
}
}
mutation DeleteTherapistReview($reviewId: ID!) {
deleteTherapistReview(id: $reviewId)
}
mutation CreateTherapistAvailability($therapistId: ID!, $availability: [AvailabilityInput!]!) {
createTherapistAvailability(therapistId: $therapistId, availability: $availability) {
id
dayOfWeek
startTime
endTime
}
}
mutation UpdateTherapistAvailability($availabilityId: ID!, $startTime: String!, $endTime: String!) {
updateTherapistAvailability(id: $availabilityId, startTime: $startTime, endTime: $endTime) {
id
dayOfWeek
startTime
endTime
}
}
mutation DeleteTherapistAvailability($availabilityId: ID!) {
deleteTherapistAvailability(id: $availabilityId)
}
mutation CreateTherapistSpecialty($name: String!) {
createTherapistSpecialty(name: $name) {
id
name
}
}
mutation UpdateTherapistSpecialty($specialtyId: ID!, $name: String!) {
updateTherapistSpecialty(id: $specialtyId, name: $name) {
id
name
}
}
mutation DeleteTherapistSpecialty($specialtyId: ID!) {
deleteTherapistSpecialty(id: $specialtyId)
}
CreateAppointmentRequest: Request a therapy appointment with a specific therapist. This mutation allows users to request a booking, which the therapist can then approve or reject.
mutation CreateAppointmentRequest($therapistId: ID!, $date: String!) {
createAppointmentRequest(therapistId: $therapistId, date: $date) {
id
therapist {
id
name
}
date
status
}
}
UpdateAppointmentRequest: Update an existing appointment request. This mutation allows users to reschedule or modify the details of their pending appointment request.
mutation UpdateAppointmentRequest($requestId: ID!, $date: String!) {
updateAppointmentRequest(id: $requestId, date: $date) {
id
therapist {
id
name
}
date
status
}
}
CancelAppointmentRequest: Cancel a pending appointment request. This mutation allows users to cancel an appointment request before it is approved or rejected by the therapist.
mutation CancelAppointmentRequest($requestId: ID!) {
cancelAppointmentRequest(id: $requestId) {
id
therapist {
id
name
}
date
status
}
}
ApproveAppointmentRequest: Approve a pending appointment request as a therapist. This mutation allows therapists to accept a user's appointment request and schedule the session.
mutation ApproveAppointmentRequest($requestId: ID!) {
approveAppointmentRequest(id: $requestId) {
id
therapist {
id
name
}
date
status
}
}
RejectAppointmentRequest: Reject a pending appointment request as a therapist. This mutation allows therapists to decline a user's appointment request, providing an optional reason for the rejection.
mutation RejectAppointmentRequest($requestId: ID!, $reason: String) {
rejectAppointmentRequest(id: $requestId, reason: $reason) {
id
therapist {
id
name
}
date
status
}
}
UpdateTherapistStatus: Update the availability status of a therapist. This mutation allows therapists to mark their availability as "available" or "unavailable."
mutation UpdateTherapistStatus($available: Boolean!) {
updateTherapistStatus(available: $available) {
id
name
specialty
location
available
}
}
UpdateTherapistDetails: Update various details of a therapist's profile, such as their name, location, or years of experience.
mutation UpdateTherapistDetails($input: TherapistInput!) {
updateTherapistDetails(input: $input) {
id
name
specialty
location
available
}
}
CreateTherapistProfile: Create a new therapist profile. This mutation is used by therapists to join the platform and provide their information.
mutation CreateTherapistProfile($input: TherapistInput!) {
createTherapistProfile(input: $input) {
id
name
specialty
location
available
}
}
DeleteTherapistProfile: Delete a therapist's profile. This mutation allows therapists to leave the platform and remove their profile and associated data.
mutation DeleteTherapistProfile {
deleteTherapistProfile
}
Contributions to this project are welcome! If you find any issues or want to add new features, please follow the standard GitHub workflow:
- Fork the repository.
- Create a new branch with a descriptive name.
- Commit your changes and push the branch to your fork.
- Submit a pull request with a detailed explanation of your changes.
This project is licensed under the MIT License. Feel free to use and modify the code as per the terms of the license.
Copyright 2023, Max Base