Patient Management β Profiles, timelines, blood groups, allergies
Doctor Directory β Specializations, license tracking, affiliations
Prescriptions β Create, dispense, and track Rx with one click
Billing & Invoicing β POS-style sales, PDF invoices, email receipts
π¦ Inventory Intelligence
Stock Batches β Track expiry dates, batch numbers, quantities
Low-Stock Alerts β Automated reorder level notifications
Expiry Warnings β Proactive alerts before medicines expire
Supplier Management β Full supplier database with contact info
Live Dashboard β Revenue charts, top medicines, KPI cards
Sales Analysis β Date-range reports with visual charts
Inventory Reports β Stock health, expiry analysis
Audit Logs β Complete user activity trail for compliance
JWT Authentication β Stateless, token-based auth
TOTP Two-Factor Auth β Google Authenticator + backup codes
Role-Based Access β Admin / Pharmacist / Doctor / Staff
Email Verification β OTP-verified account & email changes
Session Management β View & revoke active sessions per device
Dark Mode
Light Mode
Palette
Teal on charcoal
Clinical blue on white
Best for
Night shifts
Bright pharmacies
Key UX features
β¨οΈ Command Palette (Ctrl+K) β jump anywhere instantly
π Dark / Light theme toggle β persistent per user
π Global search β patients, medicines, doctors in one box
π Sortable, paginated tables β column sorting + per-page control on every table
π Real-time toast notifications
πΌοΈ Cloudinary avatars β profile pictures stored in the cloud
ποΈ Project Structure
pharmadesk/
βββ client/ # React + Vite frontend
β βββ src/
β βββ components/ # Reusable UI (Toast, Modal, Charts, Skeletonβ¦)
β βββ context/ # Auth, Theme, Sidebar, Shortcuts
β βββ pages/ # Full-page route components
β βββ services/ # Axios API layer
β βββ utils/ # generateInvoice, useSortPaginateβ¦
βββ server/ # Node.js + Express backend
βββ db/ # MySQL schema & migration scripts
βββ middleware/ # auth, auditLog, permissions
βββ routes/ # REST API route handlers
βββ services/ # email, expiryAlerts
Requirement
Version
Node.js
β₯ 18
MySQL
β₯ 8.0
npm
β₯ 9
git clone https://github.com/your-username/pharmadesk.git
cd pharmadesk
# Backend
cd server && npm install
# Frontend
cd ../client && npm install
2 Β· Configure Environment
cp server/.env.example server/.env
# Then edit server/.env with your values
# Database
DB_HOST = localhost
DB_USER = root
DB_PASSWORD = your_password
DB_NAME = pharmadesk
# Auth
JWT_SECRET = your_super_long_random_secret
# Email (for OTP verification & receipts)
SMTP_HOST = smtp.gmail.com
SMTP_PORT = 587
SMTP_USER = your@gmail.com
SMTP_PASS = your_app_password
# Cloudinary (for profile pictures)
CLOUDINARY_CLOUD_NAME = your_cloud_name
CLOUDINARY_API_KEY = your_api_key
CLOUDINARY_API_SECRET = your_api_secret
# Create the database first
mysql -u root -p -e " CREATE DATABASE pharmadesk;"
# Run schema
mysql -u root -p pharmadesk < server/db/schema.sql
# Seed initial admin account
cd server && node create-admin.js
# Terminal 1 β Backend (port 5000)
cd server && npm run dev
# Terminal 2 β Frontend (port 5173)
cd client && npm run dev
Open http://localhost:5173 β admin credentials are printed by create-admin.js.
Feature
Admin
Pharmacist
Doctor
Staff
User Management
β
β
β
β
Billing & Sales
β
β
β
β
Prescriptions
β
β
β
β
Inventory
β
β
β
β
Audit Logs
β
β
β
β
Reports
β
β
β
β
π Security Architecture
Feature
Implementation
Passwords
bcrypt (cost 10)
Sessions
JWT + DB session table
2FA
TOTP (otplib) + 8 backup codes
Email OTPs
6-digit, 10-min expiry, single-use
Email change
Password + OTP double verification
Audit trail
Every CRUD action logged with user/IP/timestamp
Frontend
Backend
Method
Endpoint
Description
POST
/api/auth/login
Login + 2FA check
POST
/api/auth/register
Register with email verification
POST
/api/auth/forgot-password
Send password reset OTP
PUT
/api/auth/change-password
Change password (authenticated)
POST
/api/auth/request-email-change
Send OTP to new email
POST
/api/2fa/setup
Generate QR code for TOTP
POST
/api/2fa/disable
Disable 2FA (requires password)
POST
/api/upload/avatar
Upload profile picture to Cloudinary
GET
/api/patients
List patients (search, pagination)
GET
/api/inventory/overview
Stock overview + alerts
POST
/api/billing
Create sale / invoice
GET
/api/reports/dashboard
Dashboard KPIs
Fork the repository
Create a feature branch: git checkout -b feature/amazing-feature
Commit your changes: git commit -m 'Add amazing feature'
Push to the branch: git push origin feature/amazing-feature
Open a Pull Request