A comprehensive full-stack application for managing pathology laboratory operations, including patient management, test bookings, sample tracking, test results, payment processing, and administrative dashboards.
PathLab is an enterprise-grade laboratory information management system (LIMS) that digitally transforms pathology laboratory operations. The system provides end-to-end workflow automation from test booking through result generation and delivery, serving patients, healthcare providers, laboratory staff, and administrators through intuitive web interfaces backed by a robust REST API.
- Patients: Book tests online, view and download results securely, manage appointments, and track payment history
- Laboratory Technicians: Manage sample collection and tracking, record test results, and handle specimen workflows
- Doctors: Monitor patient test results and access comprehensive medical data
- Administrative Personnel: Oversee laboratory operations, manage users and tests, track financial metrics, and generate analytics
- Pathology Laboratories: Modern diagnostic centers seeking to streamline operations and improve patient experience
- Automate manual laboratory processes and reduce turnaround time
- Minimize human errors in result reporting and data management
- Improve patient experience through digital accessibility and transparency
- Enhance data security with JWT authentication and role-based access control
- Enable real-time tracking of samples and test status
- Provide comprehensive analytics and business intelligence
- Ensure scalability and maintainability through modern architecture
- User registration with email verification
- Secure JWT-based authentication and authorization
- Appointment scheduling and test booking
- Browse comprehensive test catalog with pricing information
- Payment tracking and invoice generation (offline payments)
- Secure digital report access with PDF download
- Historical test results and booking history
- Real-time notifications via email
- Multi-status sample lifecycle tracking (collection pending, collected, in transit, received, tested, discarded)
- Sample collection assignment to lab technicians
- Parametric test result entry and updates
- Quality control measures and validation
- Barcode generation for sample identification
- Centralized test catalog with parameter definitions
- Comprehensive user and staff management
- Business analytics with monthly booking trends
- Test distribution analysis
- Recent activity logs and audit trails
- Role-based access control (ADMIN, LAB_TECH, DOCTOR, PATIENT)
- System-wide statistics and KPIs
- PDF report generation with Freemarker templates
- Customizable report layouts
- Invoice PDF generation for payments
- Digital signature support (planned)
- Export and sharing functionality
- Bulk report processing capabilities
- Cloudinary integration for image storage
- Email notifications for verification, password recovery, and test results
- Caffeine caching for performance optimization
- Database version control with Flyway migrations
- Comprehensive input validation with error handling
- CORS configuration for secure frontend-backend integration
PathLab follows a modern full-stack architecture with clear separation of concerns:
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β React Frontend β
β (TypeScript, Vite, Tailwind CSS) β
β Components β Pages β API Services β Hooks β
ββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββββ
β REST API (JSON)
β JWT Authentication
ββββββββββββββββββββββ΄βββββββββββββββββββββββββββββββββββββ
β Spring Boot Backend β
β Controller β Service β Repository β Entity β
β (Java 21, Spring Security, JPA) β
ββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββββ
β JDBC
ββββββββββββββββββββββ΄βββββββββββββββββββββββββββββββββββββ
β PostgreSQL Database β
β (Relational data storage) β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
External Integrations:
βββ Cloudinary (Image storage)
βββ Email Service (SMTP notifications)
βββ PDF Generation (OpenHTML2PDF + Freemarker)
The backend follows a layered architecture pattern:
Controller Layer (REST endpoints)
β
Service Layer (Business logic)
β
Repository Layer (Data access with Spring Data JPA)
β
Entity/Domain Models
β
PostgreSQL Database
Functional Modules:
- Authentication & Authorization
- Patient Management
- Test Catalog Management
- Booking & Appointment System
- Sample Collection & Tracking
- Test Results Recording
- Payment Processing
- Dashboard & Analytics
- PDF Generation & Email Services
The frontend uses a component-based architecture:
Pages (Route-based screens)
β
Components (Reusable UI with Radix UI)
β
API Services (Backend integration)
β
Hooks (Custom React logic)
β
Contexts (Global state management)
- Runtime: Java 21 (Eclipse Temurin)
- Framework: Spring Boot 3.5.5
- Security: Spring Security with JWT authentication (JJWT 0.11.5)
- Database: PostgreSQL (primary) + Spring Data JPA (Hibernate ORM)
- Migration: Flyway (database version control)
- Email: Spring Mail (SMTP)
- Caching: Caffeine 3.1.8 (in-memory)
- PDF Generation: OpenHTML2PDF with PDFBox
- Templates: Freemarker (PDF and email templates)
- Storage: Cloudinary HTTP5 (cloud image storage)
- Build Tool: Apache Maven 3.9.9
- Utilities: Lombok (boilerplate reduction)
- Framework: React 18.3.1 with TypeScript 5.5.3
- Build Tool: Vite 7.1.2 (fast HMR and optimized builds)
- UI Components: Radix UI (accessible primitives)
- Styling: Tailwind CSS 3.4.13 with custom animations
- Routing: React Router DOM 7.8.0
- Forms: React Hook Form 7.53.0 + Zod 3.23.8 (validation)
- State Management: React Context API
- HTTP Client: Fetch API with custom ApiClient wrapper
- Charts: Recharts 3.1.2
- Date Handling: date-fns 3.6.0 + react-datepicker 8.7.0
- PDF Export: jsPDF 3.0.2 + html2canvas 1.4.1
- Animations: Framer Motion 12.23.12
- Icons: Lucide React 0.539.0 + Radix UI Icons
- Notifications: Sonner 1.5.0 (toast notifications)
- Code Quality: ESLint 9.11.1 with TypeScript support
- Containerization: Docker (multi-stage builds)
- Version Control: Git
- API Documentation: Swagger/OpenAPI (if configured)
- Package Management: Maven (backend), npm (frontend)
- Deployment: Netlify (frontend), Render/Cloud providers (backend)
pathlab/
βββ app/
β βββ pathlab-backend/ # Spring Boot backend application
β β βββ src/
β β β βββ main/
β β β β βββ java/com/pathlab/
β β β β β βββ config/ # Security & app configuration
β β β β β β βββ SecurityConfig.java
β β β β β β βββ CorsConfig.java
β β β β β β βββ FreemarkerConfig.java
β β β β β β
β β β β β βββ controller/ # REST API endpoints
β β β β β β βββ AuthController.java
β β β β β β βββ PatientController.java
β β β β β β βββ BookingsController.java
β β β β β β βββ SampleController.java
β β β β β β βββ PaymentController.java
β β β β β β βββ BookingResultsController.java
β β β β β β βββ DashboardController.java
β β β β β β
β β β β β βββ dto/ # Request/response models
β β β β β β βββ auth/
β β β β β β βββ booking/
β β β β β β βββ patient/
β β β β β β βββ payment/
β β β β β β βββ result/
β β β β β β βββ dashboard/
β β β β β β
β β β β β βββ entity/ # JPA domain entities
β β β β β β βββ User.java
β β β β β β βββ Patient.java
β β β β β β βββ Booking.java
β β β β β β βββ Sample.java
β β β β β β βββ TestEntity.java
β β β β β β βββ TestResult.java
β β β β β β βββ Payment.java
β β β β β β βββ enums/ # Domain enumerations
β β β β β β
β β β β β βββ repository/ # Spring Data JPA repositories
β β β β β β βββ UserRepository.java
β β β β β β βββ PatientRepository.java
β β β β β β βββ BookingRepository.java
β β β β β β βββ SampleRepository.java
β β β β β β βββ TestEntityRepository.java
β β β β β β βββ PaymentRepository.java
β β β β β β
β β β β β βββ service/ # Business logic layer
β β β β β β βββ AuthService.java
β β β β β β βββ PatientService.java
β β β β β β βββ BookingService.java
β β β β β β βββ SampleService.java
β β β β β β βββ TestService.java
β β β β β β βββ TestResultService.java
β β β β β β βββ PaymentService.java
β β β β β β βββ DashboardService.java
β β β β β β βββ EmailService.java
β β β β β β βββ PdfService.java
β β β β β β
β β β β β βββ security/ # JWT filters & handlers
β β β β β β βββ JwtAuthenticationFilter.java
β β β β β β
β β β β β βββ exception/ # Global exception handling
β β β β β β βββ GlobalExceptionHandler.java
β β β β β β
β β β β β βββ util/ # Utility helpers
β β β β β β βββ JwtUtil.java
β β β β β β βββ DateUtils.java
β β β β β β
β β β β β βββ PathLabApplication.java # Spring Boot entry
β β β β β
β β β β βββ resources/
β β β β βββ application.properties # App configuration
β β β β βββ db/migration/ # Flyway migrations
β β β β β βββ V1__init.sql
β β β β βββ templates/ # Freemarker templates
β β β β βββ email/
β β β β β βββ verification.html
β β β β β βββ report-template.html
β β β β βββ invoice.ftl
β β β β βββ report.ftl
β β β β
β β β βββ test/ # Unit & integration tests
β β β
β β βββ Dockerfile # Backend containerization
β β βββ pom.xml # Maven dependencies
β β βββ mvnw / mvnw.cmd # Maven wrapper
β β βββ .gitignore
β β
β βββ pathlab-frontend/ # React frontend application
β βββ src/
β β βββ pages/ # Route-based page components
β β β βββ HomePage.tsx
β β β βββ LoginPage.tsx
β β β βββ PatientDashboard.tsx
β β β βββ AdminDashboard.tsx
β β β βββ BookingPage.tsx
β β β βββ ResultsPage.tsx
β β β βββ ...
β β β
β β βββ components/ # Reusable UI components
β β β βββ ui/ # Radix UI primitives
β β β βββ layout/ # Layout components
β β β βββ forms/ # Form components
β β β βββ ...
β β β
β β βββ api/ # Backend integration
β β β βββ index.ts # Base API client
β β β βββ auth.ts # Auth endpoints
β β β βββ tests.ts # Test management
β β β βββ bookings.ts # Booking endpoints
β β β βββ ...
β β β
β β βββ hooks/ # Custom React hooks
β β β βββ useAuth.ts
β β β βββ useForm.ts
β β β βββ ...
β β β
β β βββ contexts/ # Global state management
β β β βββ AuthContext.tsx
β β β βββ UserContext.tsx
β β β
β β βββ lib/ # Utility functions
β β β βββ utils.ts
β β β
β β βββ App.tsx # Root component
β β βββ main.tsx # Entry point
β β βββ index.css # Global styles
β β βββ vite-env.d.ts # Type definitions
β β
β βββ public/ # Static assets
β βββ index.html # HTML entry point
β βββ vite.config.ts # Vite configuration
β βββ tailwind.config.js # Tailwind CSS config
β βββ tsconfig.json # TypeScript config
β βββ package.json # Dependencies & scripts
β βββ eslint.config.js # ESLint configuration
β βββ netlify.toml # Deployment config
β βββ .gitignore
β
βββ README.md # This file
βββ CONTRIBUTING.md # Contribution guidelines
βββ .git/ # Git version control
Backend:
- Java 21 or later (Eclipse Temurin recommended)
- Maven 3.9.9 or later
- PostgreSQL 12 or later
- Git
Frontend:
- Node.js 18.x or higher
- npm 9.x or higher (or yarn)
-
Install PostgreSQL and create a database:
createdb pathlab
-
Navigate to backend directory:
cd app/pathlab-backend -
Configure environment variables in
application.propertiesor as system environment variables:# Database Configuration DB_URL=jdbc:postgresql://localhost:5432/pathlab DB_USERNAME=postgres DB_PASSWORD=your_password # Cloudinary Configuration CLOUDINARY_CLOUD_NAME=your-cloud-name CLOUDINARY_API_KEY=your-api-key CLOUDINARY_API_SECRET=your-api-secret # Email Configuration MAIL_USERNAME=your-email@gmail.com MAIL_PASSWORD=your-app-password # Security & JWT JWT_SECRET_BASE64=your-base64-encoded-secret # Application URLs PUBLIC_BASE_URL=http://localhost:5173
-
Navigate to frontend directory:
cd app/pathlab-frontend -
Create
.env.localfile in the frontend root:# Backend API Configuration VITE_API_BASE_URL=http://localhost:8080/api # Authentication VITE_AUTH_TIMEOUT=3600000 # Feature Flags VITE_ENABLE_DEMO_MODE=false # Notification Settings VITE_TOAST_DURATION=3000 # Application Name VITE_APP_NAME=Pathology Lab Management System
-
Navigate to backend directory:
cd app/pathlab-backend -
Build the application using Maven:
./mvnw clean package
On Windows:
mvnw.cmd clean package
-
Run the application:
./mvnw spring-boot:run
Or after packaging:
java -jar target/pathlab-0.0.1-SNAPSHOT.jar
-
Verify backend is running:
- Backend API available at:
http://localhost:8080 - API documentation (if Swagger configured):
http://localhost:8080/swagger-ui.html
- Backend API available at:
-
Navigate to frontend directory:
cd app/pathlab-frontend -
Install dependencies:
npm install
-
Start development server:
npm run dev
-
Access the application:
- Frontend available at:
http://localhost:5173(default Vite port)
- Frontend available at:
For development, run both applications simultaneously:
Terminal 1 (Backend):
cd app/pathlab-backend
./mvnw spring-boot:runTerminal 2 (Frontend):
cd app/pathlab-frontend
npm run devThe frontend will proxy API requests to the backend automatically.
Running Tests:
cd app/pathlab-backend
./mvnw testBuilding the Application:
./mvnw clean package -DskipTestsUseful Maven Commands:
# Clean build
./mvnw clean
# Compile only
./mvnw compile
# Run tests
./mvnw test
# Package without tests
./mvnw package -DskipTests
# View dependency tree
./mvnw dependency:tree
# Format code (if spotless configured)
./mvnw spotless:applyAvailable API Endpoints:
Authentication:
POST /api/auth/register/patient
POST /api/auth/register/user
POST /api/auth/login
POST /api/auth/logout
GET /api/auth/verify-email?token=...
POST /api/auth/forgot-password
POST /api/auth/reset-passwordPatient Management:
GET /api/patients
GET /api/patients/{id}
POST /api/patients
PUT /api/patients/{id}
DELETE /api/patients/{id}Bookings:
GET /api/bookings
GET /api/bookings/{id}
POST /api/bookings
PUT /api/bookings/{id}
DELETE /api/bookings/{id}Test Results & PDF Generation:
POST /api/bookings/{bookingId}/tests/{testId}/results
GET /api/bookings/{bookingId}/results
GET /api/bookings/{bookingId}/results/pdf
GET /api/payments/{id}/invoice/pdfAvailable Scripts:
# Start development server with HMR
npm run dev
# Build for production
npm run build
# Preview production build locally
npm run preview
# Run ESLint checks
npm run lintScript Details:
- dev: Starts Vite development server with fast refresh at
http://localhost:5173 - build: Compiles TypeScript and builds optimized production bundle to
dist/ - lint: Analyzes code for errors and style issues using ESLint
- preview: Serves the built application locally for testing
Backend:
- Follow Java naming conventions (PascalCase for classes, camelCase for methods)
- Use Lombok annotations for boilerplate reduction
- Add validation to all DTOs using Jakarta validation annotations
- Include appropriate error handling with custom exceptions
- Write meaningful commit messages
- Document complex business logic
- Test your changes before submitting
Frontend:
- Use TypeScript strict mode for all components
- Follow React Hooks conventions and best practices
- Write self-documenting, readable code
- Use Tailwind CSS utility classes (avoid inline styles)
- Create reusable components following single responsibility principle
- Ensure all components are properly typed
- Document complex logic with comments
- Test changes thoroughly in browser
The backend includes a multi-stage Dockerfile for containerization:
-
Build the Docker image:
cd app/pathlab-backend docker build -t pathlab-backend:latest .
-
Run the container:
docker run -d \ -p 8080:8080 \ -e DB_URL=jdbc:postgresql://postgres:5432/pathlab \ -e DB_USERNAME=postgres \ -e DB_PASSWORD=your_password \ -e MAIL_USERNAME=your-email@gmail.com \ -e MAIL_PASSWORD=your-app-password \ -e JWT_SECRET_BASE64=your-secret \ -e CLOUDINARY_CLOUD_NAME=your-cloud-name \ -e CLOUDINARY_API_KEY=your-api-key \ -e CLOUDINARY_API_SECRET=your-api-secret \ pathlab-backend:latest
The frontend is configured for Netlify deployment (see netlify.toml):
- Build Command:
npm run build - Publish Directory:
dist/ - Node Version: 18.x or higher
Environment Configuration for Deployment:
- Development:
http://localhost:8080/api - Production:
https://pathology-lab-backend-new.onrender.com/api
Backend:
- Environment variables securely configured
- PostgreSQL connection pooling optimized
- HTTPS/TLS enabled for all endpoints
- Logging and monitoring configured
- Rate limiting implemented for API endpoints
- Reverse proxy (Nginx/Apache) configured
- CORS settings updated for production frontend URL
- Secrets management system implemented
- Audit logging enabled for sensitive operations
- Database backups configured
- Health check endpoints verified
Frontend:
- Production API URL configured in environment variables
- Backend API accessibility verified
- Production build tested locally
- TypeScript compilation successful
- ESLint checks passing
- Static assets optimized
- Error tracking configured (e.g., Sentry)
- Analytics implemented (if required)
- Browser compatibility tested
- Performance metrics verified
- Use environment variables for all sensitive configuration
- Enable comprehensive logging and monitoring
- Implement proper error tracking and alerting
- Configure database connection pooling appropriately
- Use a CDN for static assets (frontend)
- Enable compression for API responses
- Implement proper CORS policies
- Set up automated backups for database
- Configure SSL/TLS certificates
- Implement rate limiting and DDoS protection
- Use a reverse proxy for the backend
- Enable API response caching where appropriate
- Monitor application performance and resource usage
-
Enhanced Notifications
- SMS notifications for booking confirmations and results
- Push notifications via Progressive Web App (PWA)
- WhatsApp integration for report delivery
- Configurable notification preferences
-
Payment Integration
- Online payment gateway integration (Stripe, PayPal, Razorpay)
- Automated invoice generation
- Payment reminders and receipts
- Multi-currency support
-
Advanced Analytics
- Comprehensive business intelligence dashboards
- Revenue forecasting and trend analysis
- Patient demographics and test distribution insights
- Exportable reports in multiple formats
-
Mobile Experience
- Progressive Web App (PWA) implementation
- Offline functionality with service workers
- Mobile-optimized dashboards and workflows
- Native mobile app (React Native)
-
Internationalization
- Multi-language support (i18n)
- Localized date and currency formats
- Regional compliance features
-
Enhanced Features
- Document storage for patient records and consents
- Automated scheduling for sample collection
- Integration with external lab equipment APIs
- Real-time booking notifications via WebSockets
- Advanced search and filtering capabilities
- Batch processing for multiple samples/tests
- Digital signature for authorized personnel
- Audit trail with detailed logging
-
UI/UX Improvements
- Dark mode full implementation
- Interactive tutorials and onboarding
- Customizable user preferences
- Accessibility enhancements (WCAG 2.1 AA compliance)
- Advanced data visualization
-
Performance Optimization
- Redis caching for improved performance
- Code splitting and lazy loading (frontend)
- Image optimization and CDN integration
- API response caching strategies
- Database query optimization
- Background job processing
-
Testing & Quality
- Comprehensive unit test coverage
- Integration tests for critical workflows
- End-to-end testing with Playwright/Cypress
- Load testing and performance benchmarks
- Security auditing and penetration testing
-
DevOps & Infrastructure
- CI/CD pipeline automation
- Kubernetes deployment configuration
- Monitoring and alerting with Prometheus/Grafana
- Automated database backups and recovery
- Infrastructure as Code (Terraform)
This project is proprietary software. All rights reserved.
For questions, issues, or contributions, please refer to CONTRIBUTING.md.
Project Maintainers:
- Backend: Mohammad Umar
- Frontend: Mohammad Umar
Repository Links:
- Monorepo:
https://github.com/mohammadumar-dev/pathlab
Built with β€οΈ for modern pathology laboratories