A full-stack appointment booking system built with Express.js backend and React frontend. This application allows users to schedule appointments and integrates with Google Calendar and email notifications.
appointment-booking/
├── backend/ # Express.js server
├── frontend/ # React + Vite application
└── README.md # This file
- Appointment Scheduling: Book appointments with an intuitive form interface
- Google Calendar Integration: Sync appointments with Google Calendar
- Form Validation: Client-side validation with React Hook Form
- Toast Notifications: User-friendly feedback with React Hot Toast
- CORS Support: Secure cross-origin communication
- Node.js with Express.js
- Google APIs to send emails
- CORS for cross-origin requests
- dotenv for environment configuration
- React 19 with Vite
- React Hook Form for form management
- React Hot Toast for notifications
- Vite for fast development and building
- Node.js (v14 or higher)
- npm or yarn
- Google OAuth credentials (for calendar integration)
- Email service credentials (for Nodemailer)
-
Navigate to the backend directory:
cd backend -
Install dependencies:
npm install
-
Create a
.envfile based on.env.example:cp .env.example .env
-
Configure your environment variables:
- Google OAuth credentials
- Other necessary configurations
-
Navigate to the frontend directory:
cd frontend -
Install dependencies:
npm install
Backend:
cd backend
npm startThe backend server will start on http://localhost:3000 (or your configured port).
Frontend:
cd frontend
npm run devThe frontend will start on http://localhost:5173 (default Vite port).
Frontend:
cd frontend
npm run buildThis creates an optimized production build in the dist/ directory.
Frontend Preview:
cd frontend
npm run previewCopy .env.example to .env and configure:
PORT- Server port (default: 3000)- Google cloud API credentials (Gmail API)
- backend/server.js - Express server entry point
- backend/get-refresh-token.js - Google OAuth token management
- frontend/src/App.jsx - Main React component
- frontend/src/components/BookingForm.jsx - Appointment booking form
- frontend/vite.config.js - Vite configuration
The get-refresh-token.js script helps you obtain a refresh token for Gmail API integration. This token is required for the application to send appointment emails.
How to use:
-
Ensure you have Google OAuth credentials (Client ID and Client Secret) from Google Cloud Console
-
Add these to your
.envfile:CLIENT_ID=your_client_id_here CLIENT_SECRET=your_client_secret_here -
Run the script from the backend directory:
cd backend node get-refresh-token.js -
The script will display an authorization URL. Open it in your browser and authorize the application.
-
Copy the authorization code from the callback page and paste it into the terminal prompt.
-
The script will output your refresh token. Add it to your
.envfile:GMAIL_REFRESH_TOKEN=your_refresh_token_here
Important: Keep your refresh token secure and never commit it to version control. The refresh token allows the application to send emails on your behalf.
Health check endpoint to verify the server is running.
Response:
{ "ok": true }Books an appointment and sends a calendar invite via Gmail.
Request Body:
{
"name": "string",
"email": "string",
"date": "YYYY-MM-DD",
"time": "HH:MM"
}Response:
{
"success": true,
"id": "gmail_message_id"
}Error Response:
{
"success": false,
"error": "error_message"
}- Create a new branch for your feature
- Make your changes
- Commit with clear messages
- Push to your branch
- Create a pull request
ISC
ArianMakiabadi