Repository navigation
refactor: align codebase with architectural standards and thin routing pattern - #283
Merged
Merged
Conversation
- Route directory restructured from src/app/ to src/app/[locale]/ with generateStaticParams() pre-rendering static HTML (SSG) for English and Arabic. - Middleware transparently rewrites unprefixed URLs (/, /leaderboard, etc.) directly to localized pages with zero URL redirect flicker. - Bypasses static assets, metadata files (manifest.webmanifest, robots, sitemap), and API routes from rewrite. - Retains inline blocking script in head for 0ms initial theme FOUC prevention and keeps client-side language switching reactive without router.refresh() to avoid theme flashing. - Adds darkreader-lock to suppress browser extension hydration mismatches and disables unused logo preload. - Adds comprehensive unit test suite in src/lib/i18n/tests/middleware.test.ts.
…te public imports
…ers to thin page controllers
Owner
Author
|
✨ Thank you, @O2sa! Another great contribution merged! 🚀 You've been a fantastic contributor! We truly appreciate your continued support. |
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 addresses architectural anomalies, misplaced files, and boundary leaks across the codebase to strictly align with the design principles defined in
ARCHITECTURE.md. It standardizes module encapsulation, isolates server-only services from client bundles, introduces thin page controllers, and cleans up deep subpath imports.Key Changes
1. 📁 Misplaced Files & Directory Structural Realignment
signal-metrics.ts: Relocated fromsrc/features/developer/tosrc/features/developer/services/signal-metrics.ts.format-comparison-to-markdown.ts: Relocated fromsrc/features/comparison/tosrc/features/comparison/services/format-comparison-to-markdown.ts.DashboardSkeleton: Moved fromsrc/components/layout/skeletons.tsxtosrc/features/comparison/components/dashboard-skeleton.tsx.AvatarPrimitive: Moved fromsrc/components/layout/avatar.tsxtosrc/components/ui/avatar.tsx(with backwards-compatible re-export incomponents/layout/index.ts).src/types/index.tsre-exportingapi.tsandmodels.tsto satisfy@/typesimport paths.2. 🛡️ Server vs. Client Boundary Isolation
user-service.ts,schedule-background.tswithafter()fromnext/server, PostgreSQLpg) leaking into client component bundles.@/features/developerand@/features/comparison) now strictly export client-safe code (UI components, domain types, client helpers), while server-only database and calculation pipelines remain cleanly isolated in@/features/<feature>/services.3. 🧩 Domain Types Encapsulation
CalculateUserScoreResult,TopRepo,TopPullRequest,TopCommunityContribution,TopLanguageRepo,TopLanguagePullRequest, andLanguageScoresfromscore-engine.tsintosrc/features/scoring/types.ts.user-service.ts,user-persistence.ts,db-store.ts) to import directly from public feature barrel@/features/scoring.4. 🪶 Thin Routing Layer (Page Controller Refactoring)
src/app/[locale]/page.tsx): Extracted 50-line inline fallback skeleton intosrc/features/comparison/components/home-page-fallback.tsx.src/app/[locale]/user/[username]/page.tsx): Extracted 80 lines of inline JSON-LD schemas intosrc/features/developer/services/developer-seo.ts(buildUserProfileSchema,buildUserBreadcrumbSchema).src/app/[locale]/leaderboard/[country]/page.tsx): Extracted inlined country formatting and metadata helpers intosrc/features/leaderboard/services/leaderboard-helpers.ts.5. 🧹 Standardized Deep Subpath Imports
src/components/cards/,src/features/comparison/, andsrc/features/developer/.@/components/ui/button,@/components/providers/language-provider,@/utils/cn,@/utils/github,@/features/developer/types) with clean barrel paths (@/components/ui,@/components/providers,@/utils,@/features/developer).