MediSync is a Medical follow-up & Records Management System built with NestJS, designed to streamline healthcare processes between doctors and patients.
MediSync aims to simplify doctor-patient interactions and provide secure digital healthcare management.
It provides secure authentication, appointment booking, prescription management, and communication modules β all under a modular, scalable backend architecture.
A progressive Node.js framework for building efficient and scalable server-side applications.
- π€ Role-based Authentication (Doctor / Patient)
- π Prescription Creation & Sharing
- π Connection Requests between Doctors & Patients
- π©Ί Medical Specializations Management
- π§Ύ QR Code Verification for Prescriptions
- π‘οΈ Secure endpoints with JWT & Guards
- π§ Modular and Scalable Architecture using NestJS
- π¬ Real-time Chat System (WebSockets) β in-app messaging between doctors and patients
- β‘ Caching with Redis to improve performance and reduce database load
- π§© Google OAuth (OAuth2) integration for social login (Google Sign-In)
- π Auth updates: Device-based sessions and support for multiple auth providers
| Category | Technology |
|---|---|
| Language | TypeScript |
| Framework | NestJS |
| Database | MongoDB with Mongoose |
| Authentication | JWT, bcrypt |
| API Docs | Swagger (OpenAPI 3.0) |
| Validation | class-validator & class-transformer |
| Deployment (optional) | Render / Railway |
| Testing Tools | Postman Collection |
src/
βββ auth/ # Authentication & Authorization
βββ users/ # User management (base)
βββ specializations/ # Medical specializations
βββ prescriptions/ # Prescription management
βββ notifications/ # Real-time notifications
βββ Request/ # Connection requests between doctors and patients
βββ config/ # Application configuration
βββ chat/ # Chat System and (Real-time)
βββ email/ # Email configuration
βββ QR/ # QR code generation & verification
βββ common/ # Shared utilities, guards, decorators
βββ prisma/ # Prisma schema & migrations
- JWT Authentication with refresh token rotation
- Google OAuth with refresh and revoke token rotation
- Role-based Access Control (RBAC && ABAC)
- Data Validation with class-validator
- Device-based Sessions β per-device refresh tokens and session management (list/revoke device sessions)
- Rate Limiting to prevent abuse
- Helmet Security Headers
- CORS Configuration
- Input Sanitization
- Audit Logging for sensitive operations
# Clone repository
git clone https://github.com/ahmedsalah/MediSync-API.git
cd medisync-backend
# Install dependencies
npm install
# Environment setup
cp .env.example .env
# Configure your database and other environment variables
# Database setup
npx prisma migrate dev
npx prisma generate
# Start development server
npm run start:devCreate a .env file in the root directory:
# Database Configuration
DATABASE_URL="postgresql://username:password@localhost:5432/medisync_db?schema=public"
# JWT Configuration
JWT_SECRET="your-super-secret-jwt-key-change-in-production"
JWT_REFRESH_SECRET="your-refresh-token-secret-key"
JWT_EXPIRES_IN="15m"
JWT_REFRESH_EXPIRES_IN="7d"
# Application Configuration
NODE_ENV="development"
PORT=3000
API_PREFIX="api" # Use just 'api' β versioning is handled via URI versioning (e.g. /api/v1)
# File Upload Configuration
MAX_FILE_SIZE=10485760 # 10MB in bytes
UPLOAD_DEST="./uploads"
# Cloudinary Configuration (Optional)
CLOUDINARY_NAME="your-cloudinary-name"
CLOUDINARY_API_KEY="your-api-key"
CLOUDINARY_API_SECRET="your-api-secret"
# Email Configuration (for notifications)
SMTP_HOST="smtp.gmail.com"
SMTP_PORT=587
SMTP_USER="your-email@gmail.com"
SMTP_PASS="your-email-password"
SMTP_FROM="MediSync <noreply@medisync.com>"
# Rate Limiting
THROTTLE_TTL=60 # seconds
THROTTLE_LIMIT=100 # requests per TTL
# Security
CORS_ORIGIN="http://localhost:3000,http://localhost:3001"
COOKIE_SECRET="your-cookie-secret-key"- Node.js 18+
- PostgreSQL 12+
- npm or yarn
Below are screenshots from the live Swagger documentation:
| Module | Preview |
|---|---|
| Authentication | ![]() |
| Users | ![]() |
| Prescriptions | ![]() |
| Specializations | ![]() |
| Connection Requests | ![]() |
| Qr | ![]() |
Each module contains detailed schemas, responses, and error examples.
Below are the main Data Transfer Objects (DTOs) used across the MediSync API.
Each schema defines the structure and validation rules for the request/response payloads.
| DTO | Description |
|---|---|
| RegisterInitDto | Step 1: Select role (Doctor / Patient) during registration |
| RegisterBasicDto | Step 2: Submit basic info (email, password, name, etc.) |
| RegisterVerifyEmailDto | Step 3: Verify userβs email using OTP |
| LoginDto | User login with email and password |
| ForgotPasswordDto | Request password reset via email |
| VerifyOtpDto | Verify OTP for password reset |
| ResetPasswordDto | Set new password after OTP verification |
| ResendOtpDto | Resend verification OTP |
| RefreshTokenDto | Refresh access token using refresh token |
| ChangePasswordDto | Change current password (authenticated users) |
- Device-based Sessions β refresh tokens are bound to specific devices; users can view active device sessions and revoke them (e.g.,
GET /auth/sessions,DELETE /auth/sessions/:id). This improves security for lost/stolen devices. - Local Strategy (email/password) β Passport Local strategy is supported for traditional email/password authentication and works alongside OAuth providers like Google.
This project follows agile development principles with:
- MVP-first approach - core features first
- Iterative development - continuous improvement
- Team collaboration - frontend/backend coordination
- Quality assurance - testing and code review
- User authentication & verification
- Basic appointment booking
- Medical record management
- Admin user management
- Role-based access control
- Google Oauth
- Email notifications for important events
- QR code generation & verification
- Connection requests between doctors and patients
- Notifications system for events like appointment confirmations, requests, and messages
- Chat system for real-time communication between doctors and patients
- File upload/download for medical records
- Advanced file management => ...working
- Detailed analytics
- Mobile API optimization => ...working
- Telemedicine integration
- AI-powered insights
- Multi-language support
- Third-party integrations
- Database Optimization with proper indexing
- Caching Strategy with Redis
- File Storage optimized for medical documents
- API Rate Limiting for stability
- Connection Pooling for database efficiency
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit changes (
git commit -m 'Add amazing feature') - Push to branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
π§βπ» Live Swagger Docs (Demo): https://medisync-api.onrender.com/api-docs
Built with β€οΈ for better healthcare management





