Mlaz is a comprehensive medical platform backend that connects patients with doctors, facilitating online consultations, appointment booking, payment processing, and medical content management. The platform provides a complete healthcare ecosystem with features for patients, doctors, and administrators.
- Profile Management: Complete doctor profiles with specializations, experience, bio, and certifications
- Availability Management: Set and manage appointment slots with flexible scheduling
- Patient Consultations: Conduct online meetings with integrated Google Meet
- Medical Content: Create and publish medical blogs and educational content
- AI-Powered Analysis: Advanced patient group analysis using AI for clinical insights and research assistance
- Reporting System: Generate and manage patient reports
- Appointment Management: Confirm, complete, or cancel patient bookings
- Community Engagement: Respond to patient in community posts
- Profile Management: Comprehensive patient profiles with medical history
- Doctor Discovery: Search and filter doctors by specialization, experience, and ratings
- Appointment Booking: Easy booking system with payment integration
- Wallet System: Secure payment processing with Stripe integration
- Medical Content Access: Browse medical blogs and educational content
- Community Platform: Post questions and engage with healthcare professionals
- Online Consultations: Video meetings with doctors via Google Meet
- User Management: Manage doctors, patients, and user verifications
- Content Moderation: Oversee blogs, community posts, and comments
- Report Management: Review and manage patient reports
- Payment Oversight: Monitor all payment transactions
- Category Management: Manage medical specialization categories
- Doctor Approval: Approve and verify doctor accounts
- Node.js with Express.js - RESTful API development
- MongoDB with Mongoose - Database and ODM
- JWT - Authentication and authorization
- Stripe - Secure payment processing
- Webhook Integration - Real-time payment status updates
- Groq AI - Advanced patient analysis and clinical insights
- Google Meet API - Video consultation integration
- Cloudinary - Image and file management
- Nodemailer - Email notifications
mlaz-backend/
├── config/
│ ├── cloudinary.js # Cloudinary configuration
│ └── database.js # MongoDB connection
├── controllers/
│ ├── auth.controller.js # Authentication logic
│ ├── availability.controller.js # Doctor availability
│ ├── blog.controller.js # Medical blog management
│ ├── booking.controller.js # Appointment booking
│ ├── category.controller.js # Medical categories
│ ├── comment.controller.js # Comment system
│ ├── community.controller.js # Community posts
│ ├── doctorAnalysis.controller.js # AI analysis
│ ├── doctorSessionAnalysisReport.controller.js # Diagnosis for completed session
│ ├── payment.controller.js # Payment processing
│ ├── report.controller.js # Medical reports
│ ├── upload.controller.js # File uploads
│ └── user.controller.js # User management
├── middlewares/
│ ├── auth.js # Authentication middleware
│ ├── authValidation.js # Auth input validation
│ ├── uploadMiddleware.js # File upload handling
│ └── *.validator.js # Input validation middlewares
├── models/
│ ├── User.model.js # User schema (patients/doctors/admin)
│ ├── Availability.model.js # Doctor availability
│ ├── Booking.model.js # Appointment bookings
│ ├── blog.model.js # Medical blogs
│ ├── Category.model.js # Medical specializations
│ ├── Comment.model.js # Comments system
│ ├── CommunityPost.model.js # Community discussions
│ ├── DoctorAnalysis.model.js # AI analysis reports
│ ├── DoctorSessionAnalysisReport.model.js # Diagnosis for completed session
│ ├── payment.model.js # Payment transactions
│ ├── Report.model.js # Medical reports
│ └── schema/
│ ├── doctor.js # Doctor-specific fields
│ ├── patient.js # Patient-specific fields
│ └── file.js # File schema
├── routes/
│ └── *.route.js # API route definitions
├── services/
│ └── *.service.js # Business logic layer
├── utils/
│ ├── AppError.js # Error handling
│ ├── cloudinaryUtils.js # Cloudinary utilities
│ ├── emailService.js # Email notifications
│ ├── helpers.js # Helper functions
│ └── queryHelper.js # Database query helpers
├── server.js # Application entry point
└── package.json # Dependencies and scripts
POST /api/auth/register # User registration
POST /api/auth/login # User login
POST /api/auth/verify-email # Email verification
POST /api/auth/forgot-password # Password reset request
POST /api/auth/reset-password # Password reset
GET /api/users/doctors # Get all doctors
GET /api/users/patients # Get all patients (admin only)
GET /api/users/me # Get user profile
GET /api/users/doctors/:id # Get specific doctor
PATCH /api/users/doctors/:id # Update doctor profile
PATCH /api/users/patients/:id # Update patient profile
GET /api/availability/doctor/:doctorId # Get doctor availability
POST /api/availability # Create availability slot
PATCH /api/availability/:id # Update availability
DELETE /api/availability/:id # Delete availability
POST /api/booking # Create booking
GET /api/booking/patient/my # Get patient bookings
GET /api/booking/doctor/my # Get doctor bookings
PATCH /api/booking/:id/confirm # Confirm booking
PATCH /api/booking/:id/complete # Complete booking
PATCH /api/booking/:id/cancel # Cancel booking
GET /api/booking/:id/meetlink # Get meeting link
POST /api/payment/charge # Create payment session
POST /api/payment/webhook # Stripe webhook
GET /api/payment/my # Get user payments
GET /api/payment/all # Get all payments (admin)
GET /api/blog/posts # Get all blogs
POST /api/blog/posts # Create blog (doctor/admin)
PATCH /api/blog/posts/:id # Update blog
DELETE /api/blog/posts/:id # Delete blog
PATCH /api/blog/posts/:id/toggle-like # Like/unlike blog
GET /api/community/posts # Get community posts
POST /api/community/posts # Create post (patient)
PATCH /api/community/posts/:id # Update post
DELETE /api/community/posts/:id # Delete post
PATCH /api/community/posts/:id/toggle-like # Like/unlike post
GET /api/comments/post/:postId # Get post comments
POST /api/comments/post/:postId # Add comment (doctor/admin)
PATCH /api/comments/:id # Update comment
DELETE /api/comments/:id # Delete comment
POST /api/ai/analysis/analysis-tool # Generate patient analysis
GET /api/ai/analysis/my-analyses # Get doctor's analyses
POST /api/reports # Create report (patient)
GET /api/reports # Get all reports (admin)
GET /api/reports/patient/me # Get patient reports
GET /api/reports/doctor/me # Get doctor reports
PATCH /api/reports/:id # Update report status (admin)
POST /api/upload/proxy # Upload files to Cloudinary
GET /api/categories # Get medical categories
POST /api/categories # Create category (admin)
PATCH /api/categories/:id # Update category (admin)
DELETE /api/categories/:id # Delete category (admin)
POST /api/diagnosis/:bookingId # Generate diagnosis report for a completed session (doctor only)
GET /api/diagnosis/my # Get all diagnosis reports created by the logged-in doctor
GET /api/diagnosis/patient/:patientId # Get diagnosis reports for a specific patient (only if a completed session exists between them)
The User model supports three roles: patient, doctor, and admin with role-specific data:
{
name: String,
email: String,
password: String,
phone: String,
gender: ["male", "female", "other"],
dateOfBirth: Date,
role: ["patient", "doctor", "admin"],
isEmailVerified: Boolean,
walletBalance: Number,
userImg: FileSchema,
// Doctor-specific fields
doctorData: {
specializations: [{ id: ObjectId, name: String }],
yearsOfExperience: Number,
bio: String,
certifications: [FileSchema],
availability: [ObjectId],
isApproved: Boolean,
clinicLocation: String,
ratingCount: Number,
ratingNumber: Number
},
// Patient-specific fields
patientData: {
medicalHistory: [String],
}
}{
doctorId: ObjectId,
patientId: ObjectId,
availabilityId: ObjectId,
appointmentDate: Date,
startTime: Date,
endTime: Date,
price: Number,
status: ["confirmed", "cancelled", "completed", "no-show"],
paymentStatus: ["pending", "paid", "refunded"],
diagnosis: String,
meetLink: String,
}- Patients: Can book appointments, access medical content, participate in community
- Doctors: Can manage availability, conduct consultations, create content, analyze patient data
- Admins: Full platform management and oversight capabilities
- Secure token-based authentication
- Role-based route protection
- Token expiration and refresh mechanism
- Secure payment processing
- Webhook handling for real-time updates
- Wallet system for easy transactions
- Payment session management
- User initiates payment through wallet charge
- Stripe checkout session created
- User completes payment on Stripe
- Webhook updates payment status
- User wallet balance updated automatically
- Uses Groq AI with Allam-2-7b model
- Analyzes multiple patient cases simultaneously
- Generates clinical insights and recommendations
- Provides research-level analysis
- Identifies common patterns and risk factors
- Symptom pattern recognition
- Risk factor identification
- Treatment recommendations
- Research insights generation
- Academic reference inclusion
- Node.js (v18 or higher)
- MongoDB
- Stripe account
- Cloudinary account
- Groq API key
PORT=3000
MONGODB_URI=your_mongodb_connection_string
JWT_SECRET=your_jwt_secret
STRIPE_SECRET_KEY=your_stripe_secret_key
STRIPE_WEBHOOK_SECRET=your_stripe_webhook_secret
CLOUDINARY_CLOUD_NAME=your_cloudinary_cloud_name
CLOUDINARY_API_KEY=your_cloudinary_api_key
CLOUDINARY_API_SECRET=your_cloudinary_api_secret
EMAIL_SERVICE=your_email_service
EMAIL_USER=your_email_user
EMAIL_PASS=your_email_password
GROQ_API_KEY=your_groq_api_key
FRONTEND_URL=your_frontend_url
GOOGLE_CLIENT_ID=your_google_client_id
GOOGLE_CLIENT_SECRET=your_google_client_secret- Clone the repository
git clone <repository-url>
cd mlaz-backend- Install dependencies
npm install- Set up environment variables
cp .env.example .env
# Edit .env with your configuration- Start the development server
npm run dev- Start the production server
npm startMlaz Medical Platform - Connecting patients with healthcare professionals through technology 🏥💻