A comprehensive healthcare management system API that facilitates medical appointments, patient management, and healthcare service delivery. Built with modern technologies and following industry best practices.
Live site: Zen doc
ZenDoc Backend is a robust healthcare technology platform that connects patients with healthcare providers through a digital appointment booking and management system. The platform supports multi-role user management, comprehensive medical record keeping, and integrated payment processing.
- Multi-Role User Management: Super Admin, Admin, Doctor, and Patient roles with role-based access control
- Appointment System: Complete scheduling, booking, and management of medical appointments
- Doctor Management: Profile management, specialties, schedules, and availability tracking
- Patient Care: Health records, prescriptions, medical reports, and patient reviews
- Payment Integration: SSL Commerce payment gateway integration for secure transactions
- File Management: Cloudinary integration for profile photos and medical documents
- Email Notifications: Automated email system for appointment confirmations and updates
- Runtime: Node.js with TypeScript (strict mode)
- Framework: Express.js with async/await patterns
- Database: PostgreSQL with Prisma ORM
- Authentication: JWT with role-based access control
- File Upload: Multer + Cloudinary integration
- Payment: SSL Commerce Gateway
- Email: Nodemailer for transactional emails
- Validation: Zod schemas for all inputs
- Security: bcrypt for password hashing
- Testing: Vitest with comprehensive test coverage
- Package Manager: pnpm
- Code Quality: ESLint + Prettier with pre-commit hooks
- Git Hooks: Husky for automated code quality checks
- Type Checking: Strict TypeScript configuration
- Database Management: Prisma CLI for migrations and schema management
- Node.js (v18 or higher)
- PostgreSQL database
- pnpm package manager
- Git
-
Clone the repository
git clone https://github.com/Zihad550/zendoc-backend cd zendoc-backend -
Install dependencies
pnpm install
-
Environment Setup
- Create a
.envfile in the root directory and copy the content of.env.example
- Create a
-
Database Setup
# Generate Prisma client pnpm db:generate # Run database migrations pnpm db:migrate
-
Start Development Server
pnpm dev
The server will start on http://localhost:8000
pnpm dev # Start development server with hot reload
pnpm build # Build TypeScript to JavaScript
pnpm start # Start production serverpnpm db:generate # Generate Prisma client after schema changes
pnpm db:migrate # Apply database migrations
pnpm db:deploy # Deploy migrations to production
pnpm db:studio # Open Prisma Studio for database managementpnpm lint # Run ESLint
pnpm lint:fix # Fix ESLint issues automatically
pnpm format # Format code with Prettier
pnpm format:check # Check code formatting
pnpm type:check # Run TypeScript type checkingsrc/
βββ app/
β βββ config/ # Environment configuration
β βββ database/ # Prisma client setup
β βββ errors/ # Custom error classes
β βββ interfaces/ # TypeScript interfaces
β βββ middlewares/ # Express middlewares
β βββ modules/ # Feature modules (MVC pattern)
β β βββ admin/ # Admin management
β β βββ appointment/ # Appointment system
β β βββ auth/ # Authentication
β β βββ doctor/ # Doctor management
β β βββ patient/ # Patient management
β β βββ payment/ # Payment processing
β β βββ prescription/ # Prescription management
β β βββ review/ # Review system
β β βββ ... # Other modules
β βββ routes/ # Route aggregation
β βββ utils/ # Shared utilities
βββ app.ts # Express app configuration
βββ server.ts # Server startup
The system implements JWT-based authentication with role-based access control:
- Super Admin: Full system access and management
- Admin: Administrative functions and user management
- Doctor: Medical practice management and patient interaction
- Patient: Personal health records and appointment booking
The application uses PostgreSQL with Prisma ORM. Key entities include:
- Users: Base user authentication and role management
- Doctors: Medical professional profiles and specialties
- Patients: Patient profiles and health data
- Appointments: Scheduling and booking system
- Prescriptions: Medical prescriptions and follow-ups
- Payments: Transaction management
- Reviews: Patient feedback system
- Development:
http://localhost:8000/api/v1 - Production:
https://your-domain.com/api/v1
POST /auth/login- User loginPOST /auth/refresh-token- Refresh access tokenPOST /auth/forgot-password- Request password resetPOST /auth/reset-password- Reset password
POST /user/create-admin- Create admin userPOST /user/create-doctor- Create doctor userPOST /user/create-patient- Create patient userGET /user/profile- Get user profilePATCH /user/profile- Update user profile
POST /appointment- Book appointmentGET /appointment- Get appointmentsPATCH /appointment/:id- Update appointmentDELETE /appointment/:id- Cancel appointment
GET /doctor- Get doctors listGET /doctor/:id- Get doctor detailsPATCH /doctor/:id- Update doctor profileGET /doctor/:id/schedules- Get doctor schedules
GET /patient- Get patients listGET /patient/:id- Get patient detailsPATCH /patient/:id- Update patient profile
The project is configured for Vercel deployment:
-
Build the project
pnpm build
-
Deploy to Vercel
vercel --prod
Ensure all required environment variables are configured in your deployment platform.
For production deployment:
pnpm db:deploy- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- Follow TypeScript strict mode guidelines
- Use ESLint and Prettier configurations
- Follow the existing project structure and naming conventions
This project is licensed under the ISC License.
For support and questions:
- Create an issue in the repository
- Contact the development team
- Check the documentation and examples
- Prisma Documentation
- Express.js Documentation
- TypeScript Documentation
- SSL Commerce Documentation
- Cloudinary Documentation
Built with β€οΈ for better healthcare management