Skip to content

eChanneling-Revamp/Doctor-App-Backend

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

25 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Doctor App Backend

A comprehensive backend service for an online doctor consultation and appointment scheduling system built with TypeScript, Express.js, Prisma ORM, and PostgreSQL.

πŸ“‹ Overview

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.

πŸ› οΈ Tech Stack

  • 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

πŸ“¦ Dependencies

Core Dependencies

{
  "@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"
}

Development Dependencies

{
  "nodemon": "^3.1.11",
  "prisma": "^5.22.0",
  "ts-node": "^10.9.2",
  "typescript": "^5.9.3"
}

πŸš€ Getting Started

Prerequisites

  • Node.js (v16 or higher)
  • PostgreSQL database
  • npm or yarn package manager

Installation

  1. Clone the repository
git clone https://github.com/eChanneling-Revamp/Doctor-App-Backend.git
cd Doctor-App-Backend
  1. Install dependencies
npm install
  1. Setup environment variables Create a .env file in the root directory:
DATABASE_URL="postgresql://username:password@localhost:5432/doctor_app"
JWT_SECRET="your_jwt_secret_key"
PORT=3000
NODE_ENV=development
  1. Initialize Prisma and database
npx prisma migrate dev --name init
npx prisma generate
  1. Start the development server
npm run dev

The server will start on http://localhost:3000

πŸ“œ Available Scripts

# Development mode with auto-reload
npm run dev

# Build TypeScript to JavaScript
npm run build

# Start production server
npm start

πŸ—οΈ Project Structure

src/
β”œβ”€β”€ 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

πŸ”‘ Key Features

Authentication & Security

  • βœ… 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 Management

  • βœ… Doctor profile management
  • βœ… Income and earnings tracking
  • βœ… Schedule management

Appointment System

  • βœ… Appointment creation and scheduling
  • βœ… Appointment status tracking
  • βœ… Appointment cancellation and rescheduling
  • βœ… Appointment history

Session Management

  • βœ… Consultation session creation
  • βœ… Session status updates
  • βœ… Session history and tracking

Prescriptions

  • βœ… Prescription creation and management
  • βœ… Prescription history
  • βœ… PDF prescription generation

πŸ“ Recent Commits & Development

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

πŸ” Environment Configuration

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

🀝 Team Contributors

  • sakuni rajapaksha - Lead developer
  • Udara-E - Full stack developer
  • NuwangiSubasingha - Backend developer
  • Sakith Umagiliya - Initial setup

πŸ“š API Documentation

Authentication Endpoints

  • POST /auth/register - User registration
  • POST /auth/login - User login
  • POST /auth/logout - User logout
  • POST /auth/send-otp - Send OTP for verification
  • POST /auth/verify-otp - Verify OTP
  • POST /auth/reset-password - Reset password

Appointment Endpoints

  • GET /appointments - Get all appointments
  • POST /appointments - Create new appointment
  • GET /appointments/:id - Get appointment by ID
  • PUT /appointments/:id - Update appointment
  • DELETE /appointments/:id - Cancel appointment

Session Endpoints

  • GET /sessions - Get all sessions
  • POST /sessions - Create new session
  • GET /sessions/:id - Get session by ID
  • PUT /sessions/:id - Update session

Prescription Endpoints

  • GET /prescriptions - Get all prescriptions
  • POST /prescriptions - Create new prescription
  • GET /prescriptions/:id - Get prescription by ID
  • GET /prescriptions/:id/pdf - Generate prescription PDF

Income Endpoints

  • GET /income - Get income data
  • GET /income/monthly - Get monthly income

πŸ› Error Handling

The API uses standard HTTP status codes:

  • 200 - Success
  • 201 - Created
  • 400 - Bad Request
  • 401 - Unauthorized
  • 403 - Forbidden
  • 404 - Not Found
  • 500 - Internal Server Error

πŸ”„ Database Migrations

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 reset

πŸ“¦ Prisma Studio

Explore your database visually with:

npx prisma studio

🚦 Testing

Testing framework to be implemented

πŸ“ž Support & Contact

For issues or questions:

πŸ“„ License

ISC License - See LICENSE file for details

🎯 Future Enhancements

  • 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

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors