diff --git a/.claude/doc/dark_light_mode/theme-architecture-integration.md b/.claude/doc/dark_light_mode/theme-architecture-integration.md new file mode 100644 index 0000000..3aa1a38 --- /dev/null +++ b/.claude/doc/dark_light_mode/theme-architecture-integration.md @@ -0,0 +1,529 @@ +# Theme Architecture Integration Plan + +## Executive Summary + +This document outlines the architectural integration strategy for dark/light mode theme switching in the Next.js application. The solution balances simplicity, architectural consistency, and maintainability while respecting the established hexagonal architecture and feature-based frontend patterns. + +## Architectural Decision: Theme as Infrastructure Concern + +**Decision:** Theme management should **NOT** be a separate feature but rather an **infrastructure-level concern** integrated at the root layout level. + +### Rationale + +1. **Cross-Cutting Concern**: Theme affects the entire application, not a specific business domain +2. **No Business Logic**: Theme switching is purely presentational with no domain rules +3. **No Complex State**: Uses simple localStorage persistence via next-themes +4. **No React Query Integration**: Theme state doesn't require server synchronization +5. **Architectural Simplicity**: Avoids over-engineering a straightforward UI concern + +### What This Means + +- Theme provider lives at root layout (`app/layout.tsx`) +- Theme toggle component lives at infrastructure level (`components/theme-toggle.tsx`) +- No `app/features/theme/` directory needed +- Use `next-themes` directly without custom wrapper hooks (unless specific business logic is needed) + +## Integration Points + +### 1. Root Layout Integration + +**File:** `app/layout.tsx` + +**Changes Required:** +- Wrap children with `ThemeProvider` from next-themes +- Remove hardcoded `dark` class from body +- Provide `suppressHydrationWarning` to html element (required by next-themes) + +**Key Considerations:** +- ThemeProvider must be client component, but layout can remain server component +- Use `"use client"` directive only where necessary (create wrapper if needed) +- Maintain existing structure (Toaster, Navbar, children order) + +**Code Pattern:** +```typescript +import { ThemeProvider } from '@/components/theme-provider' + +export default function RootLayout({ children }: { children: React.ReactNode }) { + return ( + +
+