feat: overhaul analytics dashboard and upgrade dev infrastructure - #4
Conversation
…d home components, and expanded domain services and testing.
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
This PR refactors the app into a more modular, feature-oriented architecture (analytics/search/generator) with worker-based heavy computations, while also adding a standardized dev environment (devcontainer + Docker), stricter linting, CI E2E steps, and basic SEO/PWA assets.
Changes:
- Introduces new Zustand store layer (lottery, analytics, data source) and cross-store orchestration via
AppProvider. - Moves analytics/search computations into Web Workers with shared worker client infrastructure.
- Adds/updates developer tooling and ops assets: devcontainer, docker-compose, ESLint+Prettier config, CI Playwright steps, sitemap/robots/manifest.
Reviewed changes
Copilot reviewed 274 out of 298 changed files in this pull request and generated 13 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/fixtures/real-data.ts | Removes Excel-backed real-data fixture. |
| tests/example.test.ts | Removes placeholder Vitest test. |
| tests/e2e/test-results/.last-run.json | Removes committed Playwright run artifact. |
| tests/e2e/dashboard.spec.ts | Removes dashboard E2E spec. |
| src/store/selectors.ts | Adds global selector façade across stores. |
| src/store/lottery.ts | Adds new lottery dataset store (init + file upload). |
| src/store/data.ts | Adds data source switching (official/local) + IDB integration. |
| src/shared/utils/motion.ts | Centralizes motion presets and tooltip style. |
| src/shared/utils/feedback.ts | Adds haptic/audio feedback utility. |
| src/shared/utils/download.ts | Adds browser JSON download helper. |
| src/shared/utils/cn.ts | Adds Tailwind class merge helper in shared layer. |
| src/shared/utils/ballColors.ts | Adds frequency→color gradient utility. |
| src/shared/hooks/useToast.ts | Adds lightweight toast state hook. |
| src/shared/constants/chart-colors.ts | Adds shared chart palette + dimensions. |
| src/shared/components/ui/Toast.tsx | Adds toast UI + container. |
| src/shared/components/ui/Skeleton.tsx | Adds skeleton loading component. |
| src/shared/components/ui/Card.tsx | Adds Card UI primitives in shared layer. |
| src/shared/components/ui/Button.variants.ts | Adds CVA-based button variants. |
| src/shared/components/ui/Button.tsx | Adds enhanced shared Button component. |
| src/shared/components/StatCard.variants.ts | Adds StatCard variants + styles. |
| src/shared/components/StatCard.tsx | Adds shared StatCard molecule. |
| src/shared/components/LoadingBalls.tsx | Updates loading indicator styling/docs. |
| src/shared/components/ErrorBoundary.tsx | Adds global React error boundary UI. |
| src/shared/components/AnimatedCounter.tsx | Adds shared animated counter component. |
| src/pages/NotFound.tsx | Removes old NotFound page (migrated routing). |
| src/pages/Index.tsx | Removes old Index page (migrated to feature page). |
| src/pages/About.tsx | Removes old About page (migrated to feature page). |
| src/main.tsx | Moves entrypoint under src/app/main.tsx. |
| src/lib/zustand.ts | Adds store factory helpers (devtools/subscribe/persist). |
| src/lib/worker-client.ts | Adds generic promise-based worker client. |
| src/lib/utils.ts | Removes old cn helper (relocated). |
| src/lib/lotteryIdb.ts | Adds IndexedDB persistence wrapper for large datasets. |
| src/lib/lottery/constants.ts | Adds consolidated lottery constants. |
| src/lib/formatters.ts | Removes old formatters (migrated elsewhere). |
| src/lib/export.ts | Removes old JSON download helper (relocated). |
| src/lib/ball-color.ts | Removes old ball color util (relocated). |
| src/infrastructure/parser/parser-utils.ts | Removes legacy parser utils. |
| src/infrastructure/parser/parser-factory.ts | Removes legacy parser factory. |
| src/infrastructure/parser/excel-reader.ts | Removes legacy Excel reader (migrated). |
| src/features/search/store.ts | Adds worker-backed search store. |
| src/features/search/search.worker.ts | Adds search worker entrypoint. |
| src/features/search/search.commands.ts | Adds typed search worker protocol. |
| src/features/search/search.client.ts | Adds feature worker client for search. |
| src/features/search/pages/SearchPage.tsx | Adds feature page wrapper for search. |
| src/features/search/lib/search.ts | Adds search algorithm implementation. |
| src/features/search/hooks/use-lookup.ts | Adds lookup hook w/ URL sync + navigation. |
| src/features/search/components/index.ts | Removes barrel export (reorg). |
| src/features/search/components/ShareButton.tsx | Removes old ShareButton component. |
| src/features/search/components/SearchForm.tsx | Removes old SearchForm component. |
| src/features/search/components/ResultBanner.tsx | Removes old ResultBanner component. |
| src/features/search/components/MatchesTable.tsx | Removes old MatchesTable component. |
| src/features/search/components/JackpotDetails.tsx | Removes old JackpotDetails component. |
| src/features/search/components/EducationalNote.tsx | Removes old EducationalNote component. |
| src/features/home/pages/HeroPage.tsx | Adds reorganized home hero page composition. |
| src/features/home/lib/math.ts | Adds small math helpers used by home. |
| src/features/home/components/shared-animations.ts | Removes duplicated animation constants (centralized). |
| src/features/home/components/probability.constants.ts | Removes old probability constants module. |
| src/features/home/components/oddsVisualizer.constants.tsx | Tweaks odds visualizer styling (icon/color). |
| src/features/home/components/odds-visualizer.utils.ts | Fixes import path for odds constants. |
| src/features/home/components/index.ts | Removes home barrel export (reorg). |
| src/features/home/components/RecordsSection.tsx | Adds new records section w/ timeline + CTA. |
| src/features/home/components/ProbabilitySection.tsx | Removes old probability section. |
| src/features/home/components/ProbabilityChart.tsx | Removes old probability chart. |
| src/features/home/components/MoneyFlowList.tsx | Adds distribution list component. |
| src/features/home/components/IndependenceSection.tsx | Removes old independence section. |
| src/features/home/components/FeaturesGrid.tsx | Removes old home features grid. |
| src/features/home/components/FeatureCard.tsx | Removes old feature card component. |
| src/features/home/components/CombinatorialFormula.tsx | Removes old combinatorial formula component. |
| src/features/home/components/CombinatorialChart.tsx | Removes old combinatorial chart. |
| src/features/home/components/ClosingQuote.tsx | Replaces closing quote with CTA-based section. |
| src/features/home/components/AnimatedCounter.tsx | Removes feature-local counter (migrated to shared). |
| src/features/generator/store.ts | Adds persisted generator store + injected services. |
| src/features/generator/pages/GeneratorPage.tsx | Adds generator page wrapper. |
| src/features/generator/hooks/use-simulator.ts | Adds generator simulation hook (shuffle + feedback). |
| src/features/generator/components/index.ts | Removes generator barrel export (reorg). |
| src/features/generator/components/ModeSelector.tsx | Removes old mode selector component. |
| src/features/generator/components/GenerationStats.tsx | Removes old generation stats component. |
| src/features/generator/components/ContextMessage.tsx | Removes old context message component. |
| src/features/generator/components/BallDisplay.tsx | Removes old ball display component. |
| src/features/analytics/store.ts | Adds persisted analytics store + worker-based calc. |
| src/features/analytics/pages/AnalyticsPage.tsx | Adds analytics page wrapper. |
| src/features/analytics/lib/statistical.ts | Adds statistical helpers (Poisson/EV/LLN/parity). |
| src/features/analytics/lib/chartData.ts | Adds generators for demo/bias/LLN chart data. |
| src/features/analytics/hooks/use-analytics.ts | Adds fine-grained selector hooks for stats. |
| src/features/analytics/hooks/use-analytics-metadata.ts | Adds freshness/staleness metadata hook. |
| src/features/analytics/configs/types.ts | Adds typed chapter/section config contracts. |
| src/features/analytics/configs/dashboard-config.tsx | Adds chapter factory configuration builder. |
| src/features/analytics/configs/chapters/geography-chapter.tsx | Adds geography chapter config + insights. |
| src/features/analytics/components/shared/ChartTooltip.tsx | Adds reusable tooltip component. |
| src/features/analytics/components/charts/statistical/frequency-bar.constants.ts | Adds statistical frequency chart constants. |
| src/features/analytics/components/charts/statistical/bubble-chart.utils.ts | Updates bubble chart utils to new constants/style. |
| src/features/analytics/components/charts/statistical/bubble-chart.types.ts | Updates bubble chart types quoting/style. |
| src/features/analytics/components/charts/statistical/StreakTableTab.tsx | Refactors streak table to new utils/styles. |
| src/features/analytics/components/charts/statistical/StreakFrequencyChart.tsx | Adds streak-frequency bar chart. |
| src/features/analytics/components/charts/statistical/StreakEconomicsChart.tsx | Adds streak economics chart/table switcher. |
| src/features/analytics/components/charts/statistical/ParityDistributionChart.tsx | Adds parity distribution visualization. |
| src/features/analytics/components/charts/statistical/Legend.tsx | Minor Legend refactor/style normalization. |
| src/features/analytics/components/charts/statistical/ChartLegend.tsx | Adds legend for streak economics meanings. |
| src/features/analytics/components/charts/list/RecentHotNumbersChart.tsx | Refactors hot numbers list to new hooks/meta. |
| src/features/analytics/components/charts/informational/StatRing.tsx | Refactors ring component formatting/style. |
| src/features/analytics/components/charts/informational/OverlapChart.tsx | Adds overlap bar chart (informational). |
| src/features/analytics/components/charts/informational/NumberProfileChart.tsx | Adds composed number profile dashboard widget. |
| src/features/analytics/components/charts/informational/MathCompositionChart.tsx | Adds pie chart for number-type composition. |
| src/features/analytics/components/charts/informational/LowHighDistribution.tsx | Refactors low/high distribution component style. |
| src/features/analytics/components/charts/informational/LowHighChart.tsx | Adds low-vs-high pie chart. |
| src/features/analytics/components/charts/informational/DecadeDispersion.tsx | Adds decade dispersion KPI widget. |
| src/features/analytics/components/charts/informational/ConsecutiveOverlapChart.tsx | Adds consecutive overlap pie chart. |
| src/features/analytics/components/charts/informational/ClusteringChart.tsx | Adds clustering pie chart. |
| src/features/analytics/components/charts/hierarchical/prize-tier.constants.ts | Adds tier styling config for prize hierarchy. |
| src/features/analytics/components/charts/hierarchical/TierCard.tsx | Refactors tier card visuals + utilities usage. |
| src/features/analytics/components/charts/hierarchical/PrizePyramid.tsx | Adds pyramid visualization for tiers. |
| src/features/analytics/components/charts/geographic/geo.types.ts | Adds geo chart data types. |
| src/features/analytics/components/charts/geographic/brazil-map.data.ts | Adds state path data for Brazil map. |
| src/features/analytics/components/charts/geographic/RegionSummary.tsx | Refactors region summary styling + types. |
| src/features/analytics/components/charts/geographic/GeoWinnersChart.tsx | Adds map/bar toggle geographic winners view. |
| src/features/analytics/components/charts/geographic/BrazilMap.tsx | Adds SVG density map rendering. |
| src/features/analytics/components/charts/chart-styles.ts | Adds shared Recharts style constants. |
| src/features/analytics/components/KpiCard.tsx | Adds KPI card component. |
| src/features/analytics/components/ChapterNav.tsx | Adds chapter navigation component. |
| src/features/analytics/components/AnalyticsStates.tsx | Adds empty/loading states for analytics page. |
| src/features/analytics/analytics.worker.ts | Adds analytics worker entrypoint. |
| src/features/analytics/analytics.client.ts | Adds analytics worker client and command types. |
| src/features/analytics-dashboard/dashboard.components.tsx | Removes legacy analytics-dashboard UI module. |
| src/features/analytics-dashboard/charts/statistical/frequency-bar.constants.ts | Removes legacy constants copy. |
| src/features/analytics-dashboard/charts/statistical/StreakEconomicsChart.tsx | Removes legacy chart implementation. |
| src/features/analytics-dashboard/charts/statistical/ParityDistributionChart.tsx | Removes legacy parity chart implementation. |
| src/features/analytics-dashboard/charts/other/OverlapChart.tsx | Removes legacy overlap chart implementation. |
| src/features/analytics-dashboard/charts/other/DecadeDispersion.tsx | Removes legacy decade dispersion implementation. |
| src/features/analytics-dashboard/charts/other/ChartLegend.tsx | Removes legacy chart legend implementation. |
| src/features/analytics-dashboard/charts/informational/NumberProfileChart.tsx | Removes legacy number profile implementation. |
| src/features/analytics-dashboard/charts/index.ts | Removes legacy charts barrel. |
| src/features/analytics-dashboard/charts/hierarchical/prize-tier.constants.ts | Removes legacy tier constants. |
| src/features/analytics-dashboard/charts/hierarchical/PrizeDistributionChart.tsx | Removes legacy prize distribution chart. |
| src/features/analytics-dashboard/charts/geographic/GeoWinnersChart.tsx | Removes legacy geographic chart. |
| src/features/about/pages/AboutPage.tsx | Adds about page wrapper. |
| src/features/about/components/index.ts | Removes about barrel export. |
| src/features/about/components/WhatIsIt.tsx | Removes legacy about component. |
| src/features/about/components/OpenSource.tsx | Removes legacy about component. |
| src/features/about/components/Methodology.tsx | Removes legacy about component. |
| src/features/about/components/FooterNote.tsx | Removes legacy about component. |
| src/features/about/components/Contribute.tsx | Removes legacy about component. |
| src/domain/math/statistics.ts | Removes legacy domain math utils (migrated). |
| src/domain/math/combinations.utils.ts | Removes legacy combinations table helper. |
| src/domain/math/combinations.ts | Removes legacy combinations implementation. |
| src/domain/lottery/statistics.service.ts | Removes legacy DDD statistics service. |
| src/domain/lottery/search-engine.ts | Removes legacy domain search engine. |
| src/domain/lottery/revenue.service.ts | Removes legacy revenue service. |
| src/domain/lottery/lottery.types.ts | Removes legacy domain types (migrated). |
| src/domain/lottery/lottery.constants.ts | Removes legacy domain constants (migrated). |
| src/domain/lottery/draw.model.ts | Removes legacy draw model (migrated). |
| src/domain/lottery/draw.mapper.ts | Removes legacy draw mapper (migrated). |
| src/domain/lottery/calculators/geography-analyzer.ts | Removes legacy analyzer (migrated). |
| src/domain/lottery/calculators/calculator-utils.ts | Removes legacy calculator utils (migrated). |
| src/components/ui/sonner.tsx | Removes legacy toaster wrapper. |
| src/components/ui/card.tsx | Removes legacy card primitive location. |
| src/components/ui/button.tsx | Removes legacy button primitive location. |
| src/components/ui/button.constants.ts | Removes legacy button constants. |
| src/components/shared/StatCard.tsx | Removes legacy StatCard (migrated). |
| src/components/shared/NumberInput.tsx | Removes legacy number input. |
| src/components/shared/ChartTooltip.tsx | Removes legacy tooltip (migrated). |
| src/components/shared/BallBadge.tsx | Removes legacy ball badge. |
| src/components/lottery/chart.constants.ts | Removes legacy chart constants (migrated). |
| src/components/layout/PageHeader.tsx | Removes legacy page header. |
| src/components/layout/Footer.tsx | Removes legacy footer. |
| src/application/useLotteryStore.ts | Removes legacy monolithic store. |
| src/app/provider.tsx | Adds composition root orchestrating stores + boot. |
| src/app/main.tsx | Adds new React entrypoint. |
| src/app/App.tsx | Adds new top-level app wrapper (provider+router+boundary). |
| src/App.tsx | Removes legacy App/router shell. |
| scripts/latest_sync_data.ts | Updates sync script to new parser/stats pipeline. |
| public/sitemap.xml | Adds sitemap for SEO. |
| public/robots.txt | Simplifies robots rules + adds sitemap link. |
| public/manifest.json | Adds basic PWA manifest. |
| knip.json | Adds knip config for dead-code detection. |
| firebase.json | Re-formats firebase hosting ignore list. |
| eslint.config.js | Adds Prettier integration + stricter rules/ignores. |
| docker-compose.yml | Adds Bun-based dev/CI container setup. |
| TODO.md | Adds/updates project plan checklist. |
| Makefile | Adds local targets (lint/typecheck/test/build + docker). |
| CODE_OF_CONDUCT.md | Markdown list formatting normalization. |
| CHANGELOG.md | Removes outdated changelog. |
| .vscode/extensions.json | Adds recommended VS Code extensions. |
| .prettierrc | Adds Prettier configuration. |
| .husky/pre-push | Adds pre-push typecheck hook. |
| .husky/pre-commit | Adds pre-commit lint-staged hook. |
| .github/workflows/staging.yml | Adds Playwright install + E2E run in CI. |
| .github/workflows/production.yml | Adds Playwright install + E2E run in CI. |
| .github/PULL_REQUEST_TEMPLATE.md | Improves PR template spacing/readability. |
| .github/ISSUE_TEMPLATE/feature_request.yml | Normalizes YAML quoting/style. |
| .github/ISSUE_TEMPLATE/bug_report.yml | Normalizes YAML quoting/style. |
| .devcontainer/devcontainer.json | Adds Bun-based devcontainer + extensions/settings. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
9c0556b to
83761d8
Compare
henriquebonfim
left a comment
There was a problem hiding this comment.
Code Review — PR #4
Overall Risk: MEDIUM RISK
Runtime Validation
- Build: PASS
- Typecheck: PASS
- Lint: FAIL (3 errors, 1 warning)
- Tests: FAIL (No unit tests found in src/)
Summary
This massive PR (298 files) successfully upgrades the project infrastructure (Docker, CI) and delivers significant analytics dashboard enhancements. Build and Typecheck pass successfully.
However, there are critical gaps in testing: the repository has zero unit tests in src/, making this a large-scale change with limited verification beyond static analysis. Additionally, active lint errors exist in geo.calc.ts (explicit any usage) and About.tsx (missing hook dependencies). Fix these to ensure long-term maintainability.
Findings
- TEST: Critically missing test coverage for 244 changed source files.
- ARCH: explicit
anyusage in regional normalization logic; bypassing type safety. - ARCH: Missing dependency in
useEffectinAbout.tsx.
|
Thank you for the reviews! I have addressed the findings:
|
|
Replying to @henriquebonfim's specific findings:
|
There was a problem hiding this comment.
Pull Request Overview
While the PR claims to resolve critical stability issues—specifically memory leaks in the search worker and race conditions during data source switching—there is no evidence of automated testing to prevent regressions in these areas. The scope is unusually broad, mixing infrastructure (Docker/CI) with frontend feature development (Analytics), which complicates the review and increases the risk of side effects.
Codacy analysis shows the PR is technically up to standards regarding static analysis, but the lack of verification for the primary functional requirements and bug fixes remains a significant concern. The absence of linked documentation or Jira tickets further obscures the original requirements.
About this PR
- Critical bug fixes for memory leaks and race conditions are included, but there is no mention of new automated tests to verify these fixes. Relying on manual review for memory-related and concurrency issues is insufficient.
- The PR scope is extremely broad, combining unrelated frontend feature work with foundational infrastructure changes, which complicates the review process and increases the risk of side effects.
- Jira ticket information is missing, leaving the business context and original requirements for the new visualization components unlinked.
Test suggestions
- Render the prize pyramid chart with hierarchical data sets.
- Verify Docker container health check accurately reflects service readiness.
- Validate search worker client resource cleanup after heavy search operations to ensure no memory leaks.
- Simulate rapid data source switching to verify seeding state consistency and absence of race conditions.
Prompt proposal for missing tests
Consider implementing these tests if applicable:
1. Render the prize pyramid chart with hierarchical data sets.
2. Verify Docker container health check accurately reflects service readiness.
3. Validate search worker client resource cleanup after heavy search operations to ensure no memory leaks.
4. Simulate rapid data source switching to verify seeding state consistency and absence of race conditions.
🗒️ Improve review quality by adding custom instructions
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 1557 |
| Duplication | 63 |
AI Reviewer: first review requested successfully. AI can make mistakes. Always validate suggestions.
TIP This summary will be updated as you push new changes. Give us feedback
- Reescrever descrições para maior clareza em README.md e HeroSection.tsx - Padronizar 'Página Inicial' com maiúscula - Corrigir espaço extra em notas de data.json - Trocar 'Stack Tecnológica' para 'Pilha Tecnológica'
fc06df3 to
c842f07
Compare
|
Visit the preview URL for this PR (updated for commit 5b0d649): https://sortudo--pr4-chore-implement-todo-4apjg2cm.web.app (expires Thu, 23 Apr 2026 02:51:06 GMT) 🔥 via Firebase Hosting GitHub Action 🌎 Sign: c294bb71c0bfa9acca4e4c6ba03eed2ea5f917b7 |
Co-authored-by: codacy-production[bot] <61871480+codacy-production[bot]@users.noreply.github.com>
3b5ad63 to
7e5b8e1
Compare
Overview
This PR delivers a significant upgrade to both the product and development infrastructure. It overhauls the analytics dashboard with modern charts and reorganized components while simultaneously standardizing the development environment with updated Docker configurations, CI pipelines, and linting rules.
Major Changes
Bug Fixes & Refinements (from Code Review)
Type of change
How has this been tested?
Changes were verified via static analysis, type checking, and manual review of the analytics components.
Checklist: