Now let me install the necessary packages and start building the dashboard.
Now let me create the data generation module, then the components, and finally the main App. I'll build this step by step:
Now let me create the theme context for dark mode:
Now the KPI cards component:
Now the charts components:
Now the data table component:
Now the filter bar component:
Now the series toggle and the header component:
Now let's create a series toggle component for the trend chart:
Now the main App component that ties everything together:
Now let me update the CSS to include dark mode support and custom styles:
Now let me build the project to check for any issues:
The project builds successfully. Now let me refine the donut chart layout — currently the two donuts are stacked in a column within a narrow xl:col-span-2. Let me adjust the layout so it works better:
Let me also enhance the donut charts to be more visually balanced with centered donuts and proper legends:
The recharts version doesn't support activeIndex on Pie. Let me simplify the donut approach:
The build succeeds. Let me now review the overall layout and make a few enhancements - I want to add a consumption vs received area chart to make it more visually rich, and ensure the center labels in donuts render properly with line breaks:
Now add the consumption chart to App:
The build is successful. Let me review the final output by reading through the main files to make sure everything is cohesive:
Everything looks well structured. Let me verify the final build one more time:
The project builds successfully. Here's a summary of what was built:
HIV Commodities Analytics Dashboard
Architecture
- 10 files across a clean component-based structure
- Fully typed TypeScript with React, Recharts, Tailwind CSS v4
Features Implemented
🏷️ Header
- Branded logo with gradient icon, title, report month, and "Live Data" badge
- Dark/Light mode toggle with smooth transitions
🔍 Filter Bar
- Full-text search across facility, commodity, and region
- Date range selector (3, 6, 12, 18, 24 months) — updates trend charts live
- Region dropdown (8 regions) — filters the data table live
- Commodity dropdown (12 real HIV commodities) — filters the data table live
- Reset button to clear all filters
📊 6 KPI Summary Cards
- Facilities Reporting, Stock-Out Rate, On-Time Reporting, Commodities Dispensed, Avg Months of Stock, Orders Fulfilled
- Each with trend arrow (green ↑ / red ↓) showing percentage change
- Hover lift animation, responsive grid (1→2→3→6 columns)
📈 4 Interactive Charts
- Line Chart — Monthly dispensation trends for Adult ARVs, Pediatric ARVs, Rapid Test Kits, VL Reagents with toggleable series buttons
- Stacked Bar Chart — Regional stock status (In Stock / Below Min / Stocked Out) across 8 regions
- Area Chart — ARV Supply vs Consumption comparison with gradient fills
- 2 Donut Charts — Commodity mix distribution + Stock status breakdown with interactive hover, center labels, and color legends
📋 Sortable Data Table
- 80 rows of facility-level stock data with 10 columns
- Click any header to sort (asc/desc with indicators)
- Filtered live by search, region, and commodity selectors
- Color-coded status badges (Adequate, Below Min, Stocked Out, Overstocked)
- Paginated (10 per page) with page navigation
🌗 Dark Mode
- System preference detection on load
- Full dark theme across all components, charts, tooltips, and table
- Smooth CSS transitions
📱 Fully Responsive
- Mobile-first design scales from phone → tablet → desktop → wide screen
- Horizontal scroll on data table for small screens
- Stacking grid layouts with appropriate breakpoints
Files built: index.html, src/data/generateData.ts, src/context/ThemeContext.tsx, src/components/KPICards.tsx, src/components/TrendChart.tsx, src/components/RegionalBarChart.tsx, src/components/DonutCharts.tsx, src/components/DataTable.tsx, src/components/FilterBar.tsx, src/components/Header.tsx, src/components/SeriesToggle.tsx, src/App.tsx, src/index.css, src/components/ConsumptionChart.tsx