A comprehensive financial data analysis and reporting tool built with React and TypeScript. Upload CSV or Excel files to generate charts, analyze financial metrics, and export professional reports.
# Clone the repository
git clone https://github.com/2bxtech/financial-dashboard.git
# Install dependencies
cd financial-dashboard
npm install
# Start development server
npm run dev
# Run tests
npm test
# Build for production
npm run buildThe application will be available at http://localhost:5173/
A web application that processes CSV and Excel files to generate financial charts, analyze metrics, and export professional reports. Built with React, TypeScript, and Zustand for state management. Features include comprehensive export functionality, undo/redo operations, chart customization, dark mode support, and client-side data processing for privacy.
- Screenshots available in the
screenshots/directory*
- Drag-and-drop file upload interface
- Comprehensive export system (CSV, Excel, PNG, PDF reports)
- Professional PDF report generation with embedded charts
- Chart settings update components in real-time
- Undo/redo operations with keyboard shortcuts
- Dark mode with accessible color contrast
- ~50ms processing time for typical files
- Error handling with recovery suggestions
- Client-side processing (no server required)
- CSV and Excel file support
- Settings panel with live configuration updates
- Zustand state management with performance optimizations
- Revenue vs expenses charts with configurable types (Line, Bar, Area)
- Chart type switching with live updates
- Grid lines and legend toggle controls
- Profit margin calculations and trend display
- Basic growth rate and financial ratio calculations
- Revenue consistency and expense pattern analysis
- Dark mode chart rendering with appropriate color schemes
- Multi-format data export (CSV, Excel) with complete dataset preservation
- Professional PDF report generation with two templates (Executive Summary, Detailed Analysis)
- Chart image exports (PNG) with theme-aware rendering
- Export settings configuration and history tracking
- Real-time export progress indicators
- Client-side processing maintaining zero server dependencies
- CSV and Excel (.xlsx) file parsing with validation
- Multi-format export system with data integrity validation
- PDF report generation with embedded chart screenshots
- Input validation with error messages
- Circuit breaker pattern for error handling
- TypeScript for type safety
- Performance optimization (~50ms typical processing)
- Zustand state management with persistence and undo/redo
- Performance monitoring and tracking
- Chart settings integrate with UI components
- Drag & drop file upload with progress indicators
- Processing status and validation feedback with data preview
- Tailwind CSS and Shadcn/UI components
- Dark theme with semantic color system and accessible contrast
- Error messages with recovery suggestions
- Responsive design for mobile and desktop
- Keyboard shortcuts for common operations
- Settings panel with real-time configuration
- Undo/redo controls with operation history
- Undo/redo system with 50-operation memory and keyboard shortcuts
- Chart settings update all components when changed
- Dark mode implementation with semantic color system
- User preferences and settings persistence to localStorage
- Settings panel with real-time UI updates
- CSS variables for consistent light/dark theming
- localStorage quota monitoring and management
- Individual Zustand selectors to prevent unnecessary re-renders
- Redux DevTools integration for debugging
- Store migration system for version updates
The application follows standard React patterns with TypeScript:
- Single Responsibility: Each component has one main job
- Modular Design: Features are separated into logical modules
- Type Safety: TypeScript interfaces define data contracts
- Error Handling: Structured error management throughout
- Testing: Components and services have test coverage
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Presentation Layer โ
โ React Components + TypeScript + Tailwind CSS + Shadcn/UI โ
โ + Undo/Redo Controls โ
โโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โโโโโโโโโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ State Management Layer โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ Zustand Store (7 Slices) โ โ
โ โ โข Financial Data โข UI State โข Error State โ โ
โ โ โข User Preferences โข Processing โข File Compare โ โ
โ โ โข Undo/Redo + Command Pattern + Persistence โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โโโโโโโโโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Service Layer โ
โ โโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ File Processing โ โ Data Processing Service โ โ
โ โ Service โ โ โข Metrics Calculation โ โ
โ โ โข CSV Parser โ โ โข Data Transformation โ โ
โ โ โข Excel Parser โ โ โข Validation Logic โ โ
โ โ โข Factory Patternโ โ โข Business Intelligence โ โ
โ โโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ Export Service โ โ Report Generation Service โ โ
โ โ โข Multi-format โ โ โข PDF Report Creation โ โ
โ โ โข Chart Capture โ โ โข Template Management โ โ
โ โ โข Data Export โ โ โข Chart Embedding โ โ
โ โโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โโโโโโโโโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Infrastructure Layer โ
โ โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ โ
โ โ Circuit Breaker โ โ Error System โ โ Storage & Utils โ โ
โ โ โข Fault Toleranceโ โ โข Structured โ โ โข Type Safety โ โ
โ โ โข Auto Recovery โ โ โข User Messagesโ โ โข Persistence โ โ
โ โ โ โ โ โ โข Performance โ โ
โ โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
- React 18: Modern component-based UI framework with hooks and Suspense
- TypeScript 5+: Static type checking and enhanced developer experience
- Vite: Fast build tool with optimized development server and HMR
- Tailwind CSS: Utility-first styling with responsive design system
- Zustand: Lightweight, performant state management with persistence
- Zustand Store: Modular store architecture with 7 specialized slices
- Command Pattern: Reversible operations with comprehensive undo/redo (50-operation memory)
- Individual Selectors: Performance-optimized subscriptions preventing re-renders
- localStorage Integration: Smart persistence with selective data storage
- Performance Monitoring: Development tools for optimization and debugging
- PapaParse: High-performance CSV parsing with stream support
- ExcelJS: Native Excel file processing with formatting preservation
- Recharts: Powerful charting library with interactive visualizations
- Lodash: Utility functions for efficient data manipulation
- @react-pdf/renderer: Professional PDF report generation
- html2canvas: Chart screenshot capture for embedded images
- file-saver: Cross-browser file download management
- xlsx: Excel format export functionality
- Jest: Comprehensive testing framework (213/213 tests passing)
- Testing Library: React component testing with accessibility focus
- ESLint: Code quality and consistency enforcement
- TypeScript Strict Mode: Enhanced type safety with zero any types
- Shadcn/UI: Modern, accessible component library with complete dark mode support
- Tailwind CSS v3: Class-based dark mode with CSS variables for semantic theming
- Lucide React: Beautiful, customizable icon system with theme-aware colors
- CSS Variables: Semantic color system for consistent light/dark mode theming
- Immer: Immutable state updates with developer-friendly syntax
- Performance Utilities: Custom shallow comparison and optimization tools
src/
โโโ components/ # React components
โ โโโ ui/ # Reusable UI components (Shadcn/UI with dark mode)
โ โโโ error-display.tsx # Error handling components
โ โโโ loading-state.tsx # Loading indicators
โ โโโ financial-app.tsx # Main application component with keyboard shortcuts
โ โโโ undo-redo-controls.tsx # Undo/redo UI controls with dark mode support
โ โโโ store-demo.tsx # Interactive Settings Panel with real-time updates
โ โโโ data-preview.tsx # Data table with dark mode support
โ โโโ revenue-chart.tsx # Revenue chart with live settings integration
โ โโโ profit-chart.tsx # Profit chart with live settings integration
โ โโโ trend-metrics.tsx # Metrics display with dark mode support
โ โโโ file-uploader.tsx # File upload with enhanced UI
โ โโโ export-controls.tsx # Export functionality UI
โ โโโ export-settings-dialog.tsx # Export configuration
โ โโโ export-history-dialog.tsx # Export history tracking
โ โโโ __tests__/ # Component tests (comprehensive coverage)
โโโ store/ # Zustand state management
โ โโโ index.ts # Main store with individual selectors
โ โโโ types.ts # TypeScript interfaces for all slices
โ โโโ commands.ts # Command pattern for undo/redo (fixed live store access)
โ โโโ migrations.ts # Store version migration system
โ โโโ *-slice.ts # Modular store slices (7 total with enhanced features)
โ โโโ __tests__/ # Store functionality tests
โโโ services/ # Business logic layer
โ โโโ interfaces/ # Service contracts
โ โ โโโ IDataProcessingService.ts
โ โ โโโ IFileParser.ts
โ โ โโโ IExportService.ts
โ โ โโโ IReportGenerationService.ts
โ โโโ parsers/ # File format implementations
โ โ โโโ csv-parser.ts
โ โ โโโ excel-parser.ts
โ โ โโโ file-parser-factory.ts
โ โโโ data-processing.service.ts
โ โโโ file-processing.service.ts
โ โโโ export.service.ts
โ โโโ report-generation.service.ts
โโโ utils/ # Infrastructure utilities
โ โโโ circuit-breaker.ts # Fault tolerance
โ โโโ error-handling.ts # Structured error system
โ โโโ validation-utils.ts # Data validation
โ โโโ persistence.ts # localStorage management
โ โโโ performance-monitor.ts # Performance tracking
โ โโโ storage-quota-manager.ts # Storage management
โ โโโ shallow.ts # Performance optimization utilities
โ โโโ store-reset.ts # Development utilities
โโโ hooks/ # Custom React hooks
โ โโโ useKeyboardShortcuts.ts # Global keyboard shortcuts (comprehensive)
โโโ types/ # TypeScript definitions
โโโ assets/ # Static resources
State management with modular store structure:
// Store Structure (7 specialized slices)
interface AppStore {
// Financial data management
fileData: FileData | null;
chartData: ChartData[];
// UI state with persistence
loading: boolean;
theme: 'light' | 'dark';
chartSettings: ChartSettings;
// Error handling integration
error: AppError | null;
errorHistory: AppError[];
// User preferences (persisted)
preferences: UserPreferences;
// Processing metrics and analytics
processingMetrics: ProcessingMetrics;
// File comparison features
comparisonData: ComparisonData;
// Undo/redo system
commandHistory: Command[];
canUndo: boolean;
canRedo: boolean;
}Undo/redo system with 50-operation history:
interface Command {
id: string;
type: string;
execute: () => void;
undo: () => void;
timestamp: number;
description: string;
}
// Supported operations with full undo/redo
- File upload/clear operations (with smart state capture)
- Settings changes (theme, chart type, grid, legend)
- Dashboard configuration updates with real-time feedback
- User preference modifications with instant UI updates
- Theme switching with complete dark/light mode supportIndividual selectors to prevent unnecessary re-renders:
// Individual selectors prevent object recreation
export const useFileData = () => useAppStore(state => state.fileData);
export const useLoading = () => useAppStore(state => state.loading);
export const useSetFileData = () => useAppStore(state => state.setFileData);
// Factory pattern prevents memory leaks
import { shallow } from 'zustand/shallow';
// Factory to create a shallow-equality selector for Zustand
export const createShallowSelector = (selector) => {
return (state) => shallow(selector(state));
};localStorage integration with selective persistence:
Persisted Data:
- User preferences (theme, currency, advanced settings)
- Chart settings (type, grid, legend preferences with real-time sync)
- Dashboard layout (component visibility, order, configuration)
- Processing metrics (performance history and analytics)
- File comparison data and user workflows
Non-Persisted Data:
- Current file data (session-only for privacy)
- Loading states and UI transient state
- Error states (temporary with recovery options)
- Undo/redo stacks (memory-only, 50-operation limit)
Available keyboard shortcuts:
Core Actions:
Ctrl+Z/Cmd+Z- Undo last operationCtrl+Shift+Z/Cmd+Shift+Z- Redo operationCtrl+Y/Cmd+Y- Redo (alternative)Ctrl+Delete- Clear all data (undoable)
Application Controls:
Ctrl+Shift+D/Cmd+Shift+D- Toggle dark/light themeCtrl+S/Cmd+S- Save/Export (when available)Ctrl+O/Cmd+O- Open file dialogEscape- Close modals and dialogs
Chart & Dashboard:
- Live chart type switching through Settings Panel
- Grid and legend toggles with immediate visual feedback
- Theme changes apply instantly to all components
Prevents errors from cascading when file processing fails:
interface CircuitBreakerConfig {
failureThreshold: number; // Max failures before opening
recoveryTimeout: number; // Time before recovery attempt
monitoringPeriod: number; // Monitoring window
}States: CLOSED โ OPEN โ HALF_OPEN โ CLOSED
Structured error management with helpful messages:
class AppError extends Error {
public readonly type: ErrorType;
public readonly severity: ErrorSeverity;
public readonly recoverable: boolean;
public readonly userMessage: string;
}Error Types: Validation, Processing, Network, Circuit Breaker
Severity Levels: Low, Medium, High, Critical
Financial calculations and metrics:
- Revenue Tracking: Monthly revenue totals and trends
- Expense Analysis: Cost tracking and spending patterns
- Profit Calculations: Basic margin and profitability metrics
- Data Validation: Checks for common data quality issues
โ
Test Suites: 12 passed, 12 total
โ
Tests: 213 passed, 213 total
โ
Coverage: Comprehensive coverage, including store and export functionality
- Unit Tests: Service layer, utilities, business logic
- Integration Tests: Component interactions, data flow, store operations
- UI Tests: User interactions, error states, loading states
- Store Tests: Zustand store functionality, persistence, undo/redo
- Export Tests: Export service functionality, PDF generation, data integrity
- Performance Tests: Re-render optimization, memory management
- E2E Tests: Complete file processing and export workflows
# Run all tests
npm test
# Run tests in watch mode
npm test -- --watch
# Run tests with coverage
npm test -- --coverageThe repository includes test data for trying out the application:
sample-data.csv: Basic revenue/expense data (20 entries)sample-data-detailed.csv: More complex data with categories (60 entries)sample-financial-data.xlsx: Excel format examplesample-exports/: Directory with sample export outputs (CSV, Excel, PDF, PNG)
CSV Structure:
Date,Revenue,Expenses
2024-01,120000,85000
2024-02,135000,92000Excel Support:
- Native .xlsx format
- Formatted headers and currency
- Multiple sheets (first sheet processed)
Extended Format (optional columns):
Date,Revenue,Expenses,Department,Region,Product Category
2024-01,120000,85000,Sales,North America,Software- Processing time: ~50ms for typical files (20-60 rows)
- Memory management with bounded operation histories
- Handles small to medium spreadsheets with monitoring
- Fast startup with localStorage state hydration
- Individual selectors prevent unnecessary re-renders
- Automatic storage cleanup when quota exceeds 85%
- Client-side processing (no server required)
- File parsing with PapaParse and ExcelJS libraries
- Recharts for chart rendering
- Code splitting and tree shaking enabled
- localStorage with migration system
- Development performance tracking
- Bounded command history with automatic cleanup
- Small to medium business owners needing financial reporting
- Financial analysts doing rapid data visualization
- Accountants and bookkeepers analyzing financial data
- Business consultants preparing client presentations
- Monthly/quarterly financial reviews
- Profit margin analysis
- Revenue trend identification
- Expense tracking
- Investment presentation preparation
- Basic forecasting with linear regression
- Additional chart types and customization
- Enhanced data filtering and search
- Batch file processing capabilities
# Fork the repository
git clone https://github.com/your-username/financial-dashboard.git
# Create feature branch
git checkout -b feature/your-feature-name
# Install dependencies
npm install
# Start development server
npm run dev
# Run tests
npm test
- TypeScript is required for all new code
- Include tests for new features
- Update documentation for changes
- Code must pass ESLint checks
This project is licensed under the MIT License - see the LICENSE file for details.
- React Team for the library
- TypeScript Team for static type safety
- Vite Team for build tools
- Tailwind CSS for utility-first styling
- Shadcn for accessible components
- Zustand for lightweight state management
- Recharts for powerful data visualization
- @react-pdf/renderer for PDF generation capabilities