How mohamedboukthir/doctor-appointment-booking-mern-stack works
Project Type and Purpose
• This is a full‑stack web application built with the MERN stack (MongoDB, Express, React, Node.js) plus Stripe for payments.
• Purpose: Allow patients to sign up/in, browse doctors, book appointments, leave reviews, and pay via Stripe.
File Structure
• Top‐level splits: “frontend/” (React client) and “backend/” (Node/Express API).
• backend/Controllers, backend/Routes, backend/models → MVC pattern.
• backend/auth/verifyToken.js → JWT‑based auth middleware.
• Configuration: .env.example for secrets, package.json, index.js as entry point.
• frontend/src → React components, pages, routes, utils, assets. Vite for bundling, Tailwind for styling.
Extract Insights from README
• Confirms MERN stack, Stripe integration for payments, core flows (book appointments, user auth).
Main Components & Interactions
a. Frontend (React SPA)
• Pages (Home, Login, Signup, Doctors list/details, Feedback, Contact)
• Components (Header/Footer, DoctorCard, ServiceList, FaqList, etc.)
• Router (frontend/src/routes/Routers.jsx) handles client‑side navigation
• Util (formatDate) for UI data formatting
b. Backend (Node.js + Express)
• Routes: /auth, /user, /doctor, /review (defined under backend/Routes/*.js)
• Controllers: Business logic for each route (CRUD operations in backend/Controllers)
• Models: Mongoose schemas for User, Doctor, Booking, Review
• Auth Middleware: verifyToken protects endpoints requiring authentication
c. Database
• MongoDB (cloud or local), stores users, doctors, bookings, reviews
d. External Services
• Stripe: handles payment intents & webhooks
• (Optional) Email provider or SMS for notifications
Architectural Patterns & Principles
• Client‑Server: React SPA ↔ RESTful Express API
• MVC on Server: Models ↔ Controllers ↔ Routes
• JWT Authentication: Stateless token flow
• Third‑Party Integration: Stripe as external payment processor
• Single Page Application: Frontend routing & state
a. Layers & Components
1. Client Layer (Browser)
• React App
• UI Components & Router
2. API Layer (Server)
• Express Server
• Auth Middleware (verifyToken)
• Controllers (authController, userController, doctorController, reviewController)
• Routes (auth.js, user.js, doctor.js, review.js)
3. Data Layer
• MongoDB Database (collections: Users, Doctors, Bookings, Reviews)
4. External Service
• Stripe API
b. Data Flows & Interactions
• User submits booking → React calls POST /doctor/book → verifyToken → BookingSchema → MongoDB
• User signup/login → React calls POST /auth/signup or /auth/login → authController → returns JWT
• Payment flow → React requests payment intent from Express → Express calls Stripe API → Stripe responds → React displays payment form
• Review posting → React calls POST /review → verifyToken → ReviewSchema → MongoDB
– Frontend → Backend (HTTP requests)
– Backend → Database (DB queries)
– Backend ↔ Stripe (HTTPS calls)
– Blue for UI components
– Green for API/server components
– Orange for database
– Purple for external services
– Rectangles for services/modules
– Clouds for third‑party