Skip to content

mdarkanurl/MedHub

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

33 Commits
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

MedHub - Medical Management System

A microservices-based medical management application built with Node.js, TypeScript, and PostgreSQL.

πŸ₯ Overview

MedHub is a healthcare management platform built with a microservices architecture. The system is designed to handle user authentication, administrative functions, and email communications for medical facilities.

πŸ—οΈ Architecture

MedHub follows a microservices architecture with three main services:

  • Users Service - Authentication and user management
  • Admin Service - Administrative functions and facility management
  • Email Service - Communication and notification system

Technology Stack

  • Backend: Node.js with TypeScript
  • Database: PostgreSQL with Prisma ORM
  • Message Queue: RabbitMQ for inter-service communication
  • Authentication: JWT tokens
  • Email: Resend for email notifications
  • Validation: Zod for schema validation

πŸš€ Features

πŸ” Authentication & Authorization

  • User registration and login
  • JWT-based authentication
  • Password recovery system
  • Account verification
  • Profile management

πŸ‘₯ User Management

  • User profile creation and updates
  • Account deletion
  • Token refresh mechanism

πŸ“§ Communication

  • Email service integration
  • Notification system via RabbitMQ

🏒 Admin Management

  • Administrative dashboard
  • Facility management
  • User oversight and control

πŸ› οΈ Installation & Setup

Prerequisites

  • Node.js (v18 or higher)
  • PostgreSQL database
  • RabbitMQ server
  • npm or yarn

1. Clone the Repository

git clone <repository-url>
cd MedHub

2. Environment Setup

Create .env files for each service:

Users Service (services/users/.env)

DATABASE_URL="postgresql://username:password@localhost:5432/medhub_users"
JWT_SECRET="your-jwt-secret"
JWT_REFRESH_SECRET="your-refresh-secret"
RABBITMQ_URL="amqp://localhost:5672"

Admin Service (services/admin/.env)

DATABASE_URL="postgresql://username:password@localhost:5432/medhub_admin"
RABBITMQ_URL="amqp://localhost:5672"

Email Service (services/email/.env)

RABBITMQ_URL="amqp://localhost:5672"
RESEND_API_KEY="your-resend-api-key"

3. Install Dependencies

# Install dependencies for all services
cd services/users && npm install
cd ../admin && npm install
cd ../email && npm install

4. Database Setup

# Run migrations for each service
cd services/users && npm run migrate:dev
cd ../admin && npm run migrate:dev
cd ../email && npm run migrate:dev

5. Start Services

# Start all services in separate terminals

# Terminal 1 - Users Service
cd services/users && npm run dev

# Terminal 2 - Admin Service
cd services/admin && npm run dev

# Terminal 3 - Email Service
cd services/email && npm run dev

πŸ“‹ API Documentation

Users Service

Authentication Endpoints

POST /api/signup                    # User registration
POST /api/login                     # User login
GET  /api/logout                    # User logout
GET  /api/get-me                    # Get current user
POST /api/refresh-token             # Refresh access token
POST /api/verify-account            # Verify account
POST /api/forgot-password           # Password recovery
POST /api/reset-password            # Verify password reset code
PUT  /api/change-password           # Change password
POST /api/delete-account            # Delete account
PUT  /api/update-profile            # Update profile

Admin Service

Doctor Management

POST /api/doctors                   # Create new doctor profile

Appointment Management

POST /api/appointments              # Create new appointment slot
POST /api/book-appointments         # Book appointment for patient

Email Service

# Email service endpoints for notifications
# Account verification emails
# Password reset notifications
# Appointment reminders
# (Implementation in progress)

πŸ”„ Service Communication

RabbitMQ Integration

Services communicate through RabbitMQ message queue for:

  • Email notifications
  • Inter-service messaging
  • Event-driven architecture

πŸ“ Project Structure

MedHub/
β”œβ”€β”€ services/
β”‚   β”œβ”€β”€ users/                     # Authentication & User Management
β”‚   β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”‚   β”œβ”€β”€ controllers/       # Request handlers
β”‚   β”‚   β”‚   β”œβ”€β”€ middlewares/       # Express middlewares
β”‚   β”‚   β”‚   β”œβ”€β”€ routes/            # API routes
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ v1/            # Version 1 routes
β”‚   β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ signup-route.ts
β”‚   β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ login-route.ts
β”‚   β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ logout-route.ts
β”‚   β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ get-me-route.ts
β”‚   β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ refresh-token-route.ts
β”‚   β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ verify-account-route.ts
β”‚   β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ forgot-password-route.ts
β”‚   β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ verify-forgot-password-code-route.ts
β”‚   β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ change-password-route.ts
β”‚   β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ delete-account.ts
β”‚   β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ update-profile-route.ts
β”‚   β”‚   β”‚   β”‚   β”‚   └── index.ts
β”‚   β”‚   β”‚   β”‚   └── index.ts
β”‚   β”‚   β”‚   β”œβ”€β”€ services/          # Business logic
β”‚   β”‚   β”‚   β”œβ”€β”€ utils/             # Utility functions
β”‚   β”‚   β”‚   β”œβ”€β”€ repo/              # Repository layer
β”‚   β”‚   β”‚   β”œβ”€β”€ schema/            # Validation schemas
β”‚   β”‚   β”‚   β”œβ”€β”€ generated/         # Generated files
β”‚   β”‚   β”‚   β”œβ”€β”€ prisma.ts          # Prisma client
β”‚   β”‚   β”‚   └── index.ts           # Service entry point
β”‚   β”‚   β”œβ”€β”€ prisma/                # Database schema & migrations
β”‚   β”‚   β”‚   β”œβ”€β”€ schema.prisma      # Database schema
β”‚   β”‚   β”‚   └── migrations/        # Database migrations
β”‚   β”‚   β”œβ”€β”€ package.json           # Dependencies
β”‚   β”‚   β”œβ”€β”€ tsconfig.json          # TypeScript config
β”‚   β”‚   └── .gitignore
β”‚   β”œβ”€β”€ admin/                     # Administrative Functions
β”‚   β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”‚   β”œβ”€β”€ controllers/       # Admin request handlers
β”‚   β”‚   β”‚   β”œβ”€β”€ middlewares/       # Admin middlewares
β”‚   β”‚   β”‚   β”œβ”€β”€ routes/            # Admin API routes
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ v1/            # Version 1 admin routes
β”‚   β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ create-doctor-route.ts
β”‚   β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ create-appointment-route.ts
β”‚   β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ book-appointment-route.ts
β”‚   β”‚   β”‚   β”‚   β”‚   └── index.ts
β”‚   β”‚   β”‚   β”‚   └── index.ts
β”‚   β”‚   β”‚   β”œβ”€β”€ services/          # Admin business logic
β”‚   β”‚   β”‚   β”œβ”€β”€ utils/             # Admin utilities
β”‚   β”‚   β”‚   β”œβ”€β”€ repo/              # Admin repository layer
β”‚   β”‚   β”‚   β”œβ”€β”€ schema/            # Admin validation schemas
β”‚   β”‚   β”‚   β”œβ”€β”€ generated/         # Generated admin files
β”‚   β”‚   β”‚   β”œβ”€β”€ prisma.ts          # Admin Prisma client
β”‚   β”‚   β”‚   └── index.ts           # Admin service entry point
β”‚   β”‚   β”œβ”€β”€ prisma/                # Admin database schema
β”‚   β”‚   β”‚   β”œβ”€β”€ schema.prisma      # Admin database schema
β”‚   β”‚   β”‚   └── migrations/        # Admin migrations
β”‚   β”‚   β”œβ”€β”€ package.json           # Admin dependencies
β”‚   β”‚   β”œβ”€β”€ tsconfig.json          # Admin TypeScript config
β”‚   β”‚   └── .gitignore
β”‚   └── email/                     # Email Communication
β”‚       β”œβ”€β”€ src/
β”‚       β”‚   β”œβ”€β”€ controllers/       # Email request handlers
β”‚       β”‚   β”œβ”€β”€ middlewares/       # Email middlewares
β”‚       β”‚   β”œβ”€β”€ routes/            # Email API routes
β”‚       β”‚   β”‚   β”œβ”€β”€ v1/            # Version 1 email routes
β”‚       β”‚   β”‚   └── index.ts
β”‚       β”‚   β”œβ”€β”€ services/          # Email business logic
β”‚       β”‚   β”œβ”€β”€ utils/             # Email utilities
β”‚       β”‚   β”œβ”€β”€ repo/              # Email repository layer
β”‚       β”‚   β”œβ”€β”€ schema/            # Email validation schemas
β”‚       β”‚   β”œβ”€β”€ generated/         # Generated email files
β”‚       β”‚   β”œβ”€β”€ prisma.ts          # Email Prisma client
β”‚       β”‚   └── index.ts           # Email service entry point
β”‚       β”œβ”€β”€ prisma/                # Email database schema
β”‚       β”‚   β”œβ”€β”€ schema.prisma      # Email database schema
β”‚       β”‚   └── migrations/        # Email migrations
β”‚       β”œβ”€β”€ tests/                 # Email service tests
β”‚       β”œβ”€β”€ package.json           # Email dependencies
β”‚       β”œβ”€β”€ tsconfig.json          # Email TypeScript config
β”‚       └── .gitignore
β”œβ”€β”€ README.md                      # This file
└── .gitignore                     # Git ignore rules

πŸ“ License

This project is licensed under the ISC License - see the LICENSE file for details.

πŸ‘¨β€πŸ’» Author

Mohammad Arkan

🚧 Development Status

βœ… Completed

  • Microservices architecture setup
  • User authentication system
  • Database schema with Prisma
  • Email service integration
  • RabbitMQ message queue setup
  • Basic API endpoints for user management
  • Admin service structure
  • Email service structure

πŸ“‹ Future Services

Admin Service Features

  • User management and oversight
  • Facility administration
  • System configuration
  • Role and permission management
  • Administrative dashboard
  • Facility analytics and reporting

Email Service Features

  • Account verification emails
  • Password reset notifications
  • Appointment confirmations
  • Reminder notifications
  • System announcements
  • Custom email templates

⚠️ Project Status

This project is now complete and no further contributions will be accepted.

The MedHub medical management system has been fully implemented with all core features and services. The microservices architecture is complete with user authentication, administrative functions, and email communication systems. All planned features have been delivered and the project is considered finished.

πŸ†˜ Support

For support and questions:

  • Create an issue in the repository
  • Contact with me via this email => mdarkanurl@gmail.com
  • Check the code and try to resolve the problem you face or email me

MedHub - Building the future of healthcare management.

About

MedHub is a microservices-based medical management system built with Node.js and TypeScript.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published