A professional, feature-rich clinic management and analytics dashboard built with Next.js, Material-UI, and D3.js. This application provides comprehensive insights into clinic operations, patient management, appointments, and revenue analytics.
- Patient Statistics Chart: Interactive line chart showing patient admission trends over 30 days
- Revenue Analytics: Bar chart displaying revenue breakdown by department
- Department Distribution: Pie chart showing patient distribution across departments
- Appointments Trend: Area chart tracking appointment patterns over time
- Total Patients & Active Patients tracking
- Critical Cases monitoring
- Today's Appointments overview
- Monthly Revenue analytics
- Bed Occupancy rates
- Patient Satisfaction scores
- Average Wait Time metrics
- Comprehensive department performance table
- Patient count per department
- Revenue tracking by department
- Appointment statistics
- Satisfaction ratings
- Occupancy utilization rates
- Framework: Next.js 14 with TypeScript
- UI Library: Material-UI (MUI) v5
- Data Visualization: D3.js v7
- Testing: Jest + React Testing Library
- Styling: Emotion (CSS-in-JS)
- Node.js 18+
- npm or yarn
- Clone the repository:
git clone <repository-url>
cd clinic-dashboard- Install dependencies:
npm install- Run the development server:
npm run dev- Open http://localhost:3000 in your browser
npm run dev- Start development servernpm run build- Build production applicationnpm start- Start production servernpm run lint- Run ESLintnpm test- Run test suitenpm run test:watch- Run tests in watch modenpm run test:coverage- Generate test coverage report
clinic-dashboard/
├── src/
│ ├── app/ # Next.js app directory
│ │ ├── layout.tsx # Root layout with MUI theme
│ │ ├── page.tsx # Main dashboard page
│ │ └── theme.ts # MUI theme configuration
│ ├── components/ # React components
│ │ ├── MetricCard.tsx
│ │ ├── PatientStatsChart.tsx
│ │ ├── RevenueChart.tsx
│ │ ├── DepartmentPieChart.tsx
│ │ ├── AppointmentsTrendChart.tsx
│ │ └── DepartmentTable.tsx
│ ├── data/ # Mock data
│ │ └── mockData.ts
│ ├── types/ # TypeScript type definitions
│ │ └── index.ts
│ ├── utils/ # Utility functions
│ │ ├── formatters.ts
│ │ └── calculations.ts
│ └── __tests__/ # Test files
├── package.json
├── tsconfig.json
├── jest.config.js
└── README.md
Displays key performance indicators with optional trend indicators and icons.
Props:
title: Card titlevalue: Main metric value (string or number)subtitle: Optional subtitletrend: Trend direction ('up' | 'down' | 'stable')trendValue: Trend percentage/valueicon: Optional icon componentcolor: Custom color for icon background
D3.js line chart showing patient admission trends over time.
Props:
data: Array of DailyStatstitle: Chart title
D3.js bar chart displaying revenue by department.
Props:
data: Array of Revenue recordstitle: Chart title
D3.js donut chart showing patient distribution across departments.
Props:
data: Array of DepartmentStatstitle: Chart title
D3.js area chart tracking appointment trends.
Props:
data: Array of DailyStatstitle: Chart title
Data table showing comprehensive department performance metrics.
Props:
data: Array of DepartmentStatstitle: Table title
formatCurrency(amount)- Format numbers as USD currencyformatDate(dateString)- Format ISO dates to readable formatformatPercentage(value, decimals)- Format percentage valuesabbreviateNumber(num)- Abbreviate large numbers (K, M)calculatePercentageChange(current, previous)- Calculate percentage changegetStatusColor(status)- Get color code for statustruncateText(text, maxLength)- Truncate text with ellipsis
calculateTotalRevenue(revenues)- Sum total revenuecalculateAverage(values)- Calculate average of numbersgroupRevenueByDepartment(revenues)- Group revenue by departmentcalculateGrowthRate(current, previous)- Calculate growth ratefilterByDateRange(data, start, end)- Filter data by date rangecalculateCompletionRate(appointments)- Calculate appointment completion rategetTrendDirection(current, previous)- Get trend directioncalculatePatientDistribution(patients)- Calculate patient distribution by status
The project includes comprehensive test coverage for all utility functions and components.
Run tests:
npm testGenerate coverage report:
npm run test:coverage- ✅ All utility functions (formatters and calculations)
- ✅ All dashboard components
- ✅ Data visualization components
- ✅ Metric cards and tables
The application uses comprehensive simulated datasets including:
- Patient records (10 sample patients)
- Appointments (8 sample appointments)
- Revenue data (30 days)
- Department statistics (6 departments)
- Daily statistics (30 days)
- Dashboard metrics
Customize the MUI theme in src/app/theme.ts:
- Colors (primary, secondary, success, error, etc.)
- Typography
- Spacing
- Shadows
- Component overrides
Replace mock data in src/data/mockData.ts with real API calls or database queries.
- Server-side rendering with Next.js
- Component-level code splitting
- Optimized D3.js visualizations
- Efficient re-rendering with React hooks
- Memoized calculations
- Chrome (latest)
- Firefox (latest)
- Safari (latest)
- Edge (latest)
This project is licensed under the MIT License.
- 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
For issues and questions, please open an issue on the GitHub repository.