Cleanup: Codebase Decoupling and Legacy Code Removal#8
Merged
Conversation
Changed: - Converted model registration function to async/await to ensure all schemas are loaded before database connection returns - Updated connection logic to await registration in both new and cached connection paths Files: - src/server/models/index.js - src/server/db.js Why: In serverless environments (Vercel/Netlify), the previous synchronous implementation could return the database connection before models were registered, leading to 'Schema hasn't been registered' errors when executing queries. Moving to async registration ensures reliable model availability across all execution environments.
Changed: - Added GitHub Actions workflow (ci.yml) for automated linting and testing - Updated .gitignore to exclude local development artifacts and temporary files Files: - .github/workflows/ci.yml - .gitignore Why: Establishes a baseline CI process to enforce code quality on every push. Excluding local environment artifacts ensures the shared repository remains clean and environment-agnostic.
Changed: - Deleted redundant UI components (BettingModal, UWRecord, etc.) replaced by new design system - Removed unused historical data files and legacy HTML/CSS pages - Cleaned up deprecated API endpoints and service methods Files: - src/app/change-password/page.jsx (deleted) - src/app/change-username/page.jsx (deleted) - src/app/contexts/DarkModeContext.jsx (deleted) - src/app/daily-tasks/page.html (deleted) - src/app/daily-tasks/style.css (deleted) - src/app/data/games.js (deleted) - src/app/data/users.js (deleted) - src/components/BettingModal.jsx (deleted) - src/components/BiscuitIcon.jsx (deleted) - src/components/CardStyleC.jsx (deleted) - src/components/DarkModeToggle.jsx (deleted) - src/components/ErrorState.jsx (deleted) - src/components/FireIcon.jsx (deleted) - src/components/GameCalendar.jsx (deleted) - src/components/GameDetailsModal.jsx (deleted) - src/components/UWRecord.jsx (deleted) - src/components/animation/AnimatedCard.jsx (deleted) - src/components/animation/FadeInView.jsx (deleted) - src/components/animation/variants.js (deleted) - src/components/betting/BetConfirmation.jsx (deleted) - src/components/charts/BettingDistributionChart.jsx (deleted) - src/components/charts/BettingTrendChart.jsx (deleted) - src/components/charts/SportActivityChart.jsx (deleted) - src/components/charts/index.js (deleted) - src/components/dashboard/BettingChart.jsx (deleted) - src/components/dashboard/StatsGrid.jsx (deleted) - src/components/game/index.js (deleted) - src/components/leaderboard/Podium.jsx (deleted) - src/components/shared/index.js (deleted) - src/pages/api/bets/settle-all.js (deleted) - src/pages/api/bets/settle-game.js (deleted) - src/hooks/useKeyboardNav.js (deleted) Why: Reduces technical debt and codebase size by removing obsolete features and experimental UI components. This streamlines the project structure and ensures only the current design language and active features remain, making maintenance and onboarding easier.
Changed: - Updated import paths in all active pages to resolve references to deleted legacy components - Refactored remaining components (AppShell, GameCards) to fully adopt the 'MinimalLayout' patterns - Standardized authentication routing in middleware and hooks (removing hash routing) - Centralized icon components into src/components/icons Files: - src/app/betting-history/page.jsx - src/app/dashboard/page.jsx - src/app/games/page.jsx - src/app/layout.jsx - src/app/leaderboard/page.jsx - src/app/tasks/page.jsx - src/app/hooks/useKeyboardNav.js - src/components/experimental/layout/AppShell.jsx - src/components/game/OddsDisplay.jsx - src/components/game/PlaceholderCard.jsx - src/components/game/PlayerStat.jsx - src/components/game/PlayerStatCard.jsx - src/components/icons/BiscuitIcon.jsx - src/components/icons/FireIcon.jsx - src/components/ui/Card.jsx - src/components/ui/LoadingSpinner.jsx - src/middleware.ts - src/pages/api/bets/auto-settle-user.js - src/pages/api/games/sync-from-espn.js - src/server/services/StatisticsService.js Why: To stabilize the application build after the removal of legacy artifacts. This ensures all active code correctly references the new architecture, eliminating dead dependencies and ensuring that the remaining features—like authentication and navigation—function correctly within the unified design system.
✅ Deploy Preview for huskybids ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR performs a comprehensive cleanup of the HuskyBids codebase, removing over 20 legacy files and components that are no longer aligned with the project's minimal design direction. It also strengthens the development workflow with CI improvements and resolves authentication routing issues.
Key changes include:
- Dead Code Removal: Eliminated unused components (Podium, StatsGrid, BettingModal, CardStyleC, GameCalendar, etc.), chart components, animation utilities, and legacy pages
- Database Stability: Converted model registration to use async/await with dynamic imports for better race condition handling
- CI/CD Integration: Removed the
|| trueworkaround from the lint step, enforcing stricter code quality checks
Reviewed changes
Copilot reviewed 49 out of 53 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/server/models/index.js | Converted registerModels to async function using dynamic imports instead of require |
| src/server/db.js | Added await calls for registerModels to ensure proper initialization timing |
| src/server/services/StatisticsService.js | Removed unused Game import and sortField logic |
| src/pages/api/games/sync-from-espn.js | Removed unused wasCompleted variable |
| src/pages/api/bets/settle-game.js | Deleted entire legacy bet settlement endpoint |
| src/pages/api/bets/settle-all.js | Deleted entire legacy batch settlement endpoint |
| src/pages/api/bets/auto-settle-user.js | Removed unused Game import |
| src/middleware.ts | Removed /change-password and /change-username from protected routes |
| src/components/ui/LoadingSpinner.jsx | Added displayName properties to Skeleton and UWSpinner sub-components |
| src/components/ui/Card.jsx | Added displayName properties to CardHeader, CardBody, and CardFooter sub-components |
| src/components/shared/index.js | Deleted empty export file |
| src/components/leaderboard/Podium.jsx | Deleted legacy podium visualization component |
| src/components/icons/FireIcon.jsx | New fire icon component with variants and animations |
| src/components/icons/BiscuitIcon.jsx | New biscuit icon component with balance display and rain effect |
| src/components/game/index.js | Deleted empty export file |
| src/components/game/PlayerStatCard.jsx | Removed unused opponentAbbrev parameter |
| src/components/game/PlayerStat.jsx | Removed unused User import |
| src/components/game/PlaceholderCard.jsx | Removed unused team parameter |
| src/components/game/OddsDisplay.jsx | Updated BiscuitIcon import path |
| src/components/experimental/layout/AppShell.jsx | Updated useKeyboardNav import path |
| src/components/dashboard/StatsGrid.jsx | Deleted legacy stats grid component |
| src/components/dashboard/BettingChart.jsx | Deleted legacy chart component |
| src/components/charts/* | Deleted all legacy chart components and index |
| src/components/betting/BetConfirmation.jsx | Deleted legacy bet confirmation modal |
| src/components/animation/* | Deleted all animation variant utilities and wrapper components |
| src/components/UWRecord.jsx | Deleted UW team record display component |
| src/components/GameDetailsModal.jsx | Deleted legacy game details modal |
| src/components/GameCalendar.jsx | Deleted legacy game calendar component |
| src/components/ErrorState.jsx | Deleted legacy error state component |
| src/components/DarkModeToggle.jsx | Deleted dark mode toggle (dark mode removed) |
| src/components/CardStyleC.jsx | Deleted legacy card style variant |
| src/components/BettingModal.jsx | Deleted legacy betting modal |
| src/app/tasks/page.jsx | Updated import paths and spelling fix |
| src/app/leaderboard/page.jsx | Removed unused ActionBar import and React import |
| src/app/layout.jsx | Removed DarkModeProvider and related inline script |
| src/app/hooks/useKeyboardNav.js | New keyboard navigation hook implementation |
| src/app/games/page.jsx | Updated import path |
| src/app/data/* | Deleted legacy sample data files |
| src/app/dashboard/page.jsx | Updated import paths |
| src/app/daily-tasks/* | Deleted legacy HTML/CSS daily tasks page |
| src/app/contexts/DarkModeContext.jsx | Deleted dark mode context |
| src/app/change-username/page.jsx | Deleted placeholder page |
| src/app/change-password/page.jsx | Deleted legacy page |
| src/app/betting-history/page.jsx | Removed unused useEffect import |
| .gitignore | Added exclusions for Gemini agent files |
| .github/workflows/ci.yml | Removed ` |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Fix auth page redirects and prevent build errors with Suspense Changed: - Wrapped LoginPage and SignUpPage in Suspense to handle useSearchParams correctly - Updated SignUpPage to respect the redirect URL parameter Files: - src/app/login/[[...sign-in]]/page.js - src/app/sign-up/[[...sign-up]]/page.jsx - src/app/sign-up/__tests__/redirect.test.jsx Why: Next.js requires components using useSearchParams to be wrapped in a Suspense boundary to avoid de-opting entire pages to client-side rendering during build. Additionally, the sign-up flow was ignoring the post-auth redirect destination, causing UX issues where users were not sent to their intended protected route.
Improve Mongoose model registration check for serverless and hot-reload environments Changed: - Updated registerModels to check for existing models in mongoose.models alongside the modelsRegistered flag. Files: - src/server/models/index.js Why: In serverless environments or during hot reloads in development, the module-level modelsRegistered flag might persist while the internal Mongoose model cache is cleared. Verifying both ensures that models are always correctly registered before use, preventing 'Schema hasn't been registered' errors.
Fix CI build error caused by invalid Clerk publishable key format Changed: - Updated the dummy NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY in the CI workflow to a syntactically valid mock key (pk_test_Y2xlcmsuY29tJA). Files: - .github/workflows/ci.yml Why: The Clerk SDK performs a Base64 decoding on the publishable key during Next.js's static page generation. Using a non-base64 string like 'pk_test_dummy' caused a DOMException [InvalidCharacterError], breaking the build in CI environments.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR cleans up redundant legacy code and refines the authentication flow by fixing potential redirect issues. It also stabilizes the CI/CD pipeline by providing a correctly formatted mock environment for Clerk.
What problem does it solve?
SignUpPageignored redirect parameters. Wraps auth pages in<Suspense>to prevent de-opting to client-side rendering during build.InvalidCharacterError) in CI caused by an incorrectly formatted dummy Clerk Publishable Key.Context / Background
The project has already transitioned to a minimalist design. This PR represents the final cleanup phase to remove code that is no longer in use and to stabilize the development workflow.
Changes
SignUpPageto respect?redirect=param. WrappedLoginPageandSignUpPagein<Suspense>..github/workflows/ci.ymlwith a syntactically valid mock Clerk key to satisfy the SDK's Base64 decoder during build.registerModelsto checkmongoose.modelsexistence.CardStyleC,GameCalendar, etc.).Tests
SignUpPagerespects redirect param.How to test:
npm test.npm run buildsucceeds with mock environment variables.Impact / Risk
Checklist