A comprehensive backend service for an online doctor consultation and appointment scheduling system built with TypeScript, Express.js, Prisma ORM, and PostgreSQL.
This project is a RESTful API backend for the eChanneling platform, enabling doctors and patients to manage appointments, sessions, prescriptions, and authentication in a seamless manner. The application includes features like OTP-based authentication, JWT token management, biometric support, password reset, and comprehensive API endpoints for managing medical consultations.
- Runtime: Node.js
- Language: TypeScript (97.6%)
- Framework: Express.js v5.1.0
- Database: PostgreSQL with Prisma ORM v5.22.0
- Database Scripting: PLpgSQL (2.4%)
- Authentication: JWT & bcrypt
- Additional Tools:
- Nodemailer for email notifications
- PDFKit for PDF generation
- Date-fns for date manipulation
- CORS for cross-origin requests
- Dotenv for environment variables
{
"@prisma/client": "^5.22.0",
"bcrypt": "^6.0.0",
"cors": "^2.8.5",
"date-fns": "^4.1.0",
"dotenv": "^17.3.1",
"express": "^5.1.0",
"jsonwebtoken": "^9.0.3",
"nodemailer": "^7.0.10",
"pdfkit": "^0.17.2"
}{
"nodemon": "^3.1.11",
"prisma": "^5.22.0",
"ts-node": "^10.9.2",
"typescript": "^5.9.3"
}- Node.js (v16 or higher)
- PostgreSQL database
- npm or yarn package manager
- Clone the repository
git clone https://github.com/eChanneling-Revamp/Doctor-App-Backend.git
cd Doctor-App-Backend- Install dependencies
npm install- Setup environment variables
Create a
.envfile in the root directory:
DATABASE_URL="postgresql://username:password@localhost:5432/doctor_app"
JWT_SECRET="your_jwt_secret_key"
PORT=3000
NODE_ENV=development- Initialize Prisma and database
npx prisma migrate dev --name init
npx prisma generate- Start the development server
npm run devThe server will start on http://localhost:3000
# Development mode with auto-reload
npm run dev
# Build TypeScript to JavaScript
npm run build
# Start production server
npm startsrc/
βββ controllers/ # Route handlers and business logic
βββ routes/ # API endpoints
βββ middleware/ # Custom middleware (auth, validation, etc.)
βββ models/ # Prisma schema and database models
βββ services/ # Business logic and utilities
βββ config/ # Configuration files
βββ server.ts # Application entry point
- β User registration and login with email verification
- β OTP-based authentication flow
- β JWT token-based session management
- β Password reset functionality
- β Biometric authentication support
- β bcrypt password hashing
- β Doctor profile management
- β Income and earnings tracking
- β Schedule management
- β Appointment creation and scheduling
- β Appointment status tracking
- β Appointment cancellation and rescheduling
- β Appointment history
- β Consultation session creation
- β Session status updates
- β Session history and tracking
- β Prescription creation and management
- β Prescription history
- β PDF prescription generation
The project has active development with recent contributions including:
- Add schedule and appointment APIs with Prisma
- Updated appointment management modules
- Authentication controller updates
- Prescription module enhancements
- Session management system
- Income tracking route and controller
- Full authentication flow with OTP and password reset
Create a .env file with the following variables:
# Database
DATABASE_URL=postgresql://user:password@localhost:5432/doctor_app
# Authentication
JWT_SECRET=your_secret_key_here
# Server
PORT=3000
NODE_ENV=development
# Email (for Nodemailer)
EMAIL_USER=your_email@gmail.com
EMAIL_PASSWORD=your_email_password
# Application
APP_NAME=Doctor App
APP_VERSION=1.0.0- sakuni rajapaksha - Lead developer
- Udara-E - Full stack developer
- NuwangiSubasingha - Backend developer
- Sakith Umagiliya - Initial setup
POST /auth/register- User registrationPOST /auth/login- User loginPOST /auth/logout- User logoutPOST /auth/send-otp- Send OTP for verificationPOST /auth/verify-otp- Verify OTPPOST /auth/reset-password- Reset password
GET /appointments- Get all appointmentsPOST /appointments- Create new appointmentGET /appointments/:id- Get appointment by IDPUT /appointments/:id- Update appointmentDELETE /appointments/:id- Cancel appointment
GET /sessions- Get all sessionsPOST /sessions- Create new sessionGET /sessions/:id- Get session by IDPUT /sessions/:id- Update session
GET /prescriptions- Get all prescriptionsPOST /prescriptions- Create new prescriptionGET /prescriptions/:id- Get prescription by IDGET /prescriptions/:id/pdf- Generate prescription PDF
GET /income- Get income dataGET /income/monthly- Get monthly income
The API uses standard HTTP status codes:
200- Success201- Created400- Bad Request401- Unauthorized403- Forbidden404- Not Found500- Internal Server Error
Run migrations with:
# Create a new migration
npx prisma migrate dev --name migration_name
# Apply migrations to production
npx prisma migrate deploy
# Reset database (development only)
npx prisma migrate resetExplore your database visually with:
npx prisma studioTesting framework to be implemented
For issues or questions:
- GitHub Issues: Report here
- Email: sakunirajapaksha007@gmail.com
ISC License - See LICENSE file for details
- API rate limiting
- Comprehensive API documentation (Swagger/OpenAPI)
- Unit and integration tests
- Docker containerization
- CI/CD pipeline
- Payment gateway integration
- Real-time notifications (WebSocket)
- Video consultation support
Last Updated: May 2026
Repository: eChanneling-Revamp/Doctor-App-Backend