Skip to content

TonyDotDev/qbench-bi-dashboard

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

7 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

BI Dashboard - Sample Throughput Analytics

A modern React-based business intelligence dashboard for tracking laboratory sample processing throughput with interactive charts and real-time data visualization.

๐Ÿš€ How to Run Locally

Prerequisites

  • Node.js: >=18.0.0 (see .nvmrc)
  • npm: >=9.0.0 (enforced package manager)
  • Git: Latest version

Quick Start

# Clone the repository
git clone <repository-url>
cd bi-dashboard

# Switch to correct Node version
nvm use

# Install dependencies
npm install

# Start development server
npm run dev

Open http://localhost:5173 to view the dashboard.

Available Scripts

npm run dev              # Start development server
npm run build            # Build for production
npm run preview          # Preview production build
npm run test             # Run tests
npm run test:watch       # Run tests in watch mode
npm run storybook        # Start Storybook for component development
npm run lint             # Run ESLint
npm run type-check       # Run TypeScript type checking

๐Ÿ—๏ธ Architecture & Design System Choices

Frontend Architecture

React 19 + TypeScript + Vite

  • React 19: Latest features with improved performance and concurrent rendering
  • TypeScript: Strict type safety for better developer experience and fewer runtime errors
  • Vite: Fast development server and optimized builds with HMR

Component Architecture

bi-dashboard/
โ”œโ”€โ”€ .husky/                          # Git hooks configuration
โ”œโ”€โ”€ .storybook/                      # Storybook configuration
โ”œโ”€โ”€ .vscode/                         # VS Code workspace settings
โ”œโ”€โ”€ public/                          # Static assets
โ”œโ”€โ”€ src/
โ”‚   โ”œโ”€โ”€ api/                         # Data layer & API integration
โ”‚   โ”‚   โ”œโ”€โ”€ index.ts                 # API exports
โ”‚   โ”‚   โ”œโ”€โ”€ sampleThroughputApi.ts   # API client for sample data
โ”‚   โ”‚   โ”œโ”€โ”€ sample_throughput_data.json # Mock data
โ”‚   โ”‚   โ””โ”€โ”€ useSampleThroughput.ts   # React hook for data fetching
โ”‚   โ”‚
โ”‚   โ”œโ”€โ”€ components/                  # React components
โ”‚   โ”‚   โ”œโ”€โ”€ cards/                   # Layout & container components
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ DashboardCard.tsx    # Main dashboard card wrapper
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ constants.ts         # Card configuration constants
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ index.ts             # Card exports
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ variants.ts          # Card styling variants
โ”‚   โ”‚   โ”‚
โ”‚   โ”‚   โ”œโ”€โ”€ charts/                  # Data visualization components
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ LineChart.tsx        # Interactive line chart with tooltips
โ”‚   โ”‚   โ”‚
โ”‚   โ”‚   โ”œโ”€โ”€ inputs/                  # Form & input components
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ DateRangePicker/     # Date selection component
โ”‚   โ”‚   โ”‚
โ”‚   โ”‚   โ”œโ”€โ”€ layouts/                 # Layout components
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ DashboardLayout.tsx  # Main dashboard layout
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ index.ts             # Layout exports
โ”‚   โ”‚   โ”‚
โ”‚   โ”‚   โ”œโ”€โ”€ Typography/              # Text components
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ Typography.tsx       # Typography component
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ typographyVariants.ts # Typography styles
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ index.ts             # Typography exports
โ”‚   โ”‚   โ”‚
โ”‚   โ”‚   โ””โ”€โ”€ ui/                      # Reusable UI components (shadcn/ui)
โ”‚   โ”‚       โ”œโ”€โ”€ button/              # Button component
โ”‚   โ”‚       โ”œโ”€โ”€ calendar.tsx         # Calendar component
โ”‚   โ”‚       โ”œโ”€โ”€ card.tsx             # Card component
โ”‚   โ”‚       โ”œโ”€โ”€ chart.tsx            # Chart container
โ”‚   โ”‚       โ”œโ”€โ”€ label.tsx            # Label component
โ”‚   โ”‚       โ”œโ”€โ”€ popover.tsx          # Popover component
โ”‚   โ”‚       โ””โ”€โ”€ index.ts             # UI exports
โ”‚   โ”‚
โ”‚   โ”œโ”€โ”€ context/                     # Global state management
โ”‚   โ”‚   โ”œโ”€โ”€ dashboard/               # Dashboard-specific context
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ DashboardContext.tsx # Main dashboard context
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ useDashboardContext.ts # Context hook
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ index.ts             # Context exports
โ”‚   โ”‚   โ””โ”€โ”€ index.ts                 # Context exports
โ”‚   โ”‚
โ”‚   โ”œโ”€โ”€ lib/                         # Utilities & helpers
โ”‚   โ”‚   โ”œโ”€โ”€ auth/                    # Authentication utilities
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ useMockAuth.ts       # Mock authentication hook
โ”‚   โ”‚   โ”œโ”€โ”€ date.ts                  # Date formatting utilities
โ”‚   โ”‚   โ””โ”€โ”€ utils.ts                 # General utilities
โ”‚   โ”‚
โ”‚   โ”œโ”€โ”€ pages/                       # Page-level components
โ”‚   โ”‚   โ”œโ”€โ”€ DashboardPage.tsx        # Main dashboard page
โ”‚   โ”‚   โ”œโ”€โ”€ LoginPage.tsx            # Login page
โ”‚   โ”‚   โ””โ”€โ”€ UnauthorizedPage.tsx     # Unauthorized access page
โ”‚   โ”‚
โ”‚   โ”œโ”€โ”€ routes/                      # Routing configuration
โ”‚   โ”‚   โ”œโ”€โ”€ applyGuardsAndLayouts.tsx # Route guard application
โ”‚   โ”‚   โ”œโ”€โ”€ AppRouter.tsx            # Main router component
โ”‚   โ”‚   โ”œโ”€โ”€ layouts.tsx              # Layout wrapper
โ”‚   โ”‚   โ”œโ”€โ”€ paths.ts                 # Route path constants
โ”‚   โ”‚   โ”œโ”€โ”€ RouteGuard.tsx           # Route protection component
โ”‚   โ”‚   โ”œโ”€โ”€ routes.tsx               # Route definitions
โ”‚   โ”‚   โ””โ”€โ”€ index.ts                 # Route exports
โ”‚   โ”‚
โ”‚   โ”œโ”€โ”€ test/                        # Test configuration
โ”‚   โ”‚   โ””โ”€โ”€ setup.ts                 # Test setup file
โ”‚   โ”‚
โ”‚   โ”œโ”€โ”€ App.css                      # App-specific styles
โ”‚   โ”œโ”€โ”€ App.tsx                      # Main application component
โ”‚   โ”œโ”€โ”€ index.css                    # Global styles & CSS variables
โ”‚   โ”œโ”€โ”€ main.tsx                     # Application entry point
โ”‚   โ””โ”€โ”€ vite-env.d.ts                # Vite type definitions
โ”‚
โ”œโ”€โ”€ .eslintrc.js                     # ESLint configuration
โ”œโ”€โ”€ .nvmrc                           # Node version specification
โ”œโ”€โ”€ .npmrc                           # npm configuration
โ”œโ”€โ”€ .prettierrc                      # Prettier configuration
โ”œโ”€โ”€ components.json                  # shadcn/ui configuration
โ”œโ”€โ”€ package.json                     # Dependencies & scripts
โ”œโ”€โ”€ tailwind.config.ts               # Tailwind CSS configuration
โ”œโ”€โ”€ tsconfig.json                    # TypeScript configuration
โ”œโ”€โ”€ tsconfig.app.json                # App-specific TypeScript config
โ”œโ”€โ”€ tsconfig.node.json               # Node-specific TypeScript config
โ”œโ”€โ”€ vite.config.ts                   # Vite configuration
โ””โ”€โ”€ vitest.shims.d.ts                # Vitest type definitions

Design System

Tailwind CSS v4 with OKLCH Colors

  • OKLCH Color Space: Better color perception and accessibility
  • Design Tokens: Consistent spacing, typography, and color variables
  • Responsive Design: Mobile-first approach with breakpoint system

shadcn/ui Component Library

  • Accessible Components: Built with ARIA standards and keyboard navigation
  • Customizable: Themeable through CSS variables
  • Type-Safe: Full TypeScript support with proper prop types

Chart System

  • Recharts: React-native charting library with accessibility features
  • Custom Tooltips: Enhanced with detailed information and ARIA labels
  • Responsive: Adapts to different screen sizes and orientations

Data Architecture

API Layer

interface SampleThroughputData {
  date: string;
  lab: string;
  sample_type: string;
  count: number;
  status: 'complete' | 'processing' | 'pending' | 'failed';
}

State Management

  • React Context: For global dashboard state (date ranges, filters)
  • Custom Hooks: For data fetching and transformation
  • Local State: Component-specific state with useState/useReducer

Testing Strategy

Vitest + Testing Library

  • Unit Tests: Component behavior and utility functions
  • Accessibility Tests: ARIA compliance and keyboard navigation

Storybook

  • Component Documentation: Interactive examples and prop documentation
  • Visual Testing: Component variations and edge cases
  • Design System: Living documentation of UI components

๐Ÿ”ฎ What I'd Improve with More Time

Immediate Improvements (1-2 weeks)

  1. Data Visualization Enhancements

    • Add more chart types (bar charts, pie charts, heatmaps)
    • Implement data aggregation and filtering
    • Add export functionality (CSV, PDF reports)
    • Real-time data updates with WebSocket integration
  2. Performance Optimizations

    • Implement virtual scrolling for large datasets
    • Add data caching with React Query
    • Optimize bundle size with code splitting
    • Add service worker for offline functionality
  3. User Experience

    • Add loading states and skeleton screens
    • Implement error boundaries and retry mechanisms
    • Add keyboard shortcuts for power users
    • Improve mobile responsiveness
  4. Testing

    • Playwright with E2E/integration tests.

Medium-term Enhancements (1-2 months)

  1. Advanced Analytics

    • Trend analysis and forecasting
    • Statistical summaries and KPIs
    • Custom dashboard builder
  2. Accessibility & Internationalization

    • Full i18n support with react-intl
    • Enhanced screen reader support
    • High contrast mode
  3. Backend Integration

    • Real API endpoints with authentication
    • Database integration (PostgreSQL/MongoDB)
    • Caching layer (Redis)
    • API rate limiting and monitoring

๐Ÿค” Assumptions Made

Technical Assumptions

  1. Data Structure

    • Sample data follows a consistent format with date, lab, sample_type, count, and status
    • Status values are limited to: complete, processing, pending, failed
    • Count values are always positive integers
  2. User Requirements

    • Users need to view sample throughput over time
    • Detailed information (lab, sample type, status) is important for tooltips
    • Color-coded status indicators improve data comprehension
  3. Performance Requirements

    • Initial load time should be under 3 seconds
    • Chart interactions should be smooth (60fps)
    • Mobile devices should be supported
  4. Accessibility Requirements

    • WCAG 2.1 AA compliance
    • Keyboard navigation support
    • Screen reader compatibility
    • Color contrast ratios meet standards

๐Ÿค– Use of AI Tools

How AI Assisted in This Project

Development Assistance

  • GitHub Copilot: Used extensively for code completion and boilerplate generation

    • React component structure and TypeScript interfaces
    • Test file generation and assertions
    • Documentation
  • ChatGPT (Claude): Used for architectural decisions and problem-solving

    • Chart component design and Recharts implementation
    • Accessibility improvements and ARIA attributes
    • Color scheme selection and OKLCH color space
    • Testing strategies and best practices

Specific AI Contributions

  1. LineChart Component

    • AI helped design the tooltip structure with proper accessibility
    • Assisted with Recharts configuration and customization
  2. Accessibility Improvements

    • AI identified missing ARIA attributes and semantic HTML
    • Suggested proper heading hierarchy and screen reader support
  3. Styling and Design

    • AI recommended OKLCH color space for better accessibility

Responsible AI Usage

  • Code Review: All AI-generated code was reviewed and modified as needed
  • Understanding: Ensured comprehension of all implemented solutions
  • Customization: Adapted AI suggestions to fit project requirements
  • Testing: Verified AI-generated code with proper tests
  • Documentation: Documented AI contributions transparently

AI Tools Used

  • GitHub Copilot: Real-time code completion and suggestions
  • ChatGPT/Claude: Problem-solving and architectural guidance
  • VS Code Extensions: AI-powered linting and formatting

๐Ÿ“Š Key Features Implemented

Interactive Line Chart

  • Real-time data visualization with hover tooltips
  • Monthly and daily view options
  • Color-coded status indicators
  • Responsive design for all screen sizes

Enhanced Tooltips

  • Detailed information display (lab, sample type, count, status)
  • Accessibility features with ARIA labels
  • Color-coded status badges
  • Semantic HTML structure

Dashboard Layout

  • Responsive card-based layout
  • Loading states and error handling
  • Date range selection
  • Clean, modern UI design

Data Management

  • Type-safe API integration
  • Custom React hooks for data fetching
  • Efficient data transformation and aggregation
  • Error handling

๐Ÿงช Testing Coverage

  • Unit Tests: Component behavior and utility functions
  • Integration Tests: API interactions and data flow
  • Accessibility Tests: ARIA compliance and keyboard navigation
  • Visual Tests: Component rendering and styling
  • Storybook: Interactive component documentation

About

Case study for Senior Frontend Engineer role @ QBench.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published