This project is a web-based application that allows users to manage their availability slots and for admins to schedule meetings based on those slots. It consists of a React frontend and an Express.js backend, with MongoDB used for data storage.
- Frontend: Developed using React, responsible for user interactions and displaying availability slots.
- Backend: Developed using Express.js, responsible for API endpoints and business logic.
- Database: MongoDB, used to store user data, availability slots, and scheduled meetings.
-
Frontend (React):
- The
UserPanelcomponent allows users to add, view, and delete their availability slots. - The user’s availability is fetched from the backend and displayed in a list.
- A modal (currently commented out) is used for editing slots.
- The
-
Backend (Express.js):
- API endpoints are provided for managing availability and scheduling meetings.
- Middleware is not used for user identification; the
userIdis included directly in the URL.
-
Database (MongoDB):
- User Schema:
import mongoose from "mongoose"; const availabilitySchema = new mongoose.Schema({ date: { type: Date, required: true }, slots: [ { _id: { type: mongoose.Schema.Types.ObjectId, auto: true }, start: { type: Date, required: true }, end: { type: Date, required: true }, duration: { type: Number, required: true }, // in minutes }, ], }); const userSchema = new mongoose.Schema({ email: { type: String, required: true, unique: true }, role: { type: String, enum: ["admin", "user"], required: true }, availability: [availabilitySchema], sessions: [{ type: mongoose.Schema.Types.ObjectId, ref: "Session" }], }); const User = mongoose.model("User", userSchema); export default User;
- User Schema:
- Node.js (v14 or later)
- MongoDB
-
Install Node.js:
- Download and install Node.js from the Node.js official website.
-
Clone the repository:
git clone https://github.com/your-username/your-repository.git cd your-repository
-
Navigate to the backend directory:
cd backend -
Install backend dependencies:
npm install
Backend Dependencies:
express: Web framework for Node.jsmongoose: MongoDB object modeling toolcors: Middleware for handling CORSdotenv: Loads environment variables from a .env filebody-parser: Middleware for parsing incoming requests
-
Create a
.envfile:Inside the
backenddirectory, create a.envfile and add the following variables:MONGO_URI=mongodb://localhost:27017/your-database PORT=5000
Replace
mongodb://localhost:27017/your-databasewith your MongoDB connection string. -
Run the backend server:
npm start
The backend will run on http://localhost:5000.
-
Navigate to the frontend directory:
cd ../frontend -
Install frontend dependencies:
npm install
Frontend Dependencies:
react: JavaScript library for building user interfacesaxios: Promise-based HTTP client for making HTTP requestsreact-dom: Provides DOM-specific methods for Reactreact-scripts: Scripts and configuration used by Create React App
-
Run the frontend:
npm run dev
The frontend will be available at http://localhost:3000.
To run the full stack:
-
Start the backend (if not already running):
cd backend npm start -
Start the frontend:
cd ../frontend npm run devYou can access the application at:
- http://localhost:3000 for the frontend
- http://localhost:5000 for the backend API.
- Users: Can manage their availability by adding, viewing, and deleting slots.
- Admins: Can schedule meetings for users based on their availability.
This project is licensed under the MIT License. See the LICENSE file for details.