How zzwtsy/wakatime-dashboard works
Main Components
• Entry Point & Bootstrapping:
• index.html serves as the basic HTML shell.
• src/main.tsx is the starting point where React is bootstrapped, and the root of the component tree is rendered.
• Application Component:
• src/App.tsx is the central container wrapping overall functionality, which may include routing or state management.
• UI Components:
• Dashboard (src/components/Dashboard.tsx) which likely serves as the main view for displaying visualized data.
• ThemeProvider and ThemeToggle (src/components/ThemeProvider.tsx & src/components/ThemeToggle.tsx) managing and enabling theme switching.
• Chart components (Chart.tsx, DoughnutChart.tsx, StackedHorizontalBar.tsx under src/components/charts) that encapsulate different visualization types.
• Data and API Layer:
• src/api directory (with index.ts) manages API calls or data fetching logic related to Wakatime statistics.
• Domain Models and Types:
• src/entity contains “models” like GistRawUrl, StackedHorizontalBarData, and Wakatime representing the core data structures.
• src/enum and src/types provide typed constants and interfaces that support data consistency across the app.
• Assets:
• src/assets contains theming details for charts (JSON files for ECharts themes) and other static assets.
• Utilities:
• src/utils.ts and src/localStorage.ts support miscellaneous functions (including persisting theme preference or other state).
Out the Relationships and Data Flow
• The web page (index.html) loads the bundled JavaScript which is produced using Vite (notable from vite.config.ts, tsconfig related files).
• main.tsx initializes the React app by rendering App.tsx.
• App.tsx composes the page by including the Dashboard component as well as wrapping the content with ThemeProvider so that components down the tree can access theme state.
• Data is fetched from external sources using the API module (src/api/index.ts), which processes and transforms the data into model objects defined in src/entity.
• The visual representations in the charts use the style themes provided in src/assets/echarts (for light and dark modes).
• LocalStorage utilities help maintain state between sessions (like a chosen theme) and possibly cache data.
Architectural Patterns and Design Principles
• Component-Based Architecture: The project leverages React’s composable component system.
• Separation of Concerns: There’s a clear split between UI (in components), data access (in api), and domain data representation (in entity and types).
• Theming/Configuration Management: Dedicated components (ThemeProvider and ThemeToggle) encapsulate global UI state (theme) and configuration.
• Declarative Data Flow: Data flows from the API layer through model transformation into UI components for rendering interactive charts.
Detail Specific Technologies and Tools
• That the application uses:
• React for component-based UI,
• TypeScript for type safety,
• Vite as the build tool,
• ECharts (through assets JSON themes) for data visualization.
• External integration such as “wakatime-action-sync” for data feeding.