docs: add color system architecture and session 48 summary

- Document single source of truth architecture
- Explain CSS variable auto-generation workflow
- Show how colors.mjs eliminates duplication
- Provide maintenance and build integration guide
- Reference commit e715afd8 refactoring

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-04-25 17:32:03 +03:00
parent e715afd814
commit 5e8ff23237
2 changed files with 326 additions and 0 deletions

View File

@@ -264,6 +264,65 @@ Root cause analysis revealed 3 critical failures in DESIGN.md compliance:
---
## SESSION 48 EXECUTION SUMMARY — Architectural Refactoring: Single Source of Truth
### Identified Issue
User question: "Are both tailwind.config.ts and globals.css necessary? If any color needs to be changed, the same information is hardcoded in two different files."
- **Root Problem**: Color definitions duplicated in 2 places (DRY violation)
- **Impact**: Any color change requires editing in 2 files
- **Risk**: Easy to update one file and forget the other, causing sync issues
### Solution: Option 1 - Single Source of Truth
Implemented consolidated color architecture with 3 files:
1. **frontend/colors.mjs** (NEW - SINGLE SOURCE OF TRUTH)
- Exports `colors` object with all 40+ design system colors
- Exports `spacing` object with all semantic spacing tokens
- Machine-readable, importable format
- Comment clearly states: "Changes here automatically propagate to both files"
2. **frontend/scripts/generate-css-vars.mjs** (NEW - BUILD STEP)
- Reads colors.mjs as input
- Auto-generates CSS custom properties (--primary, --secondary, etc.)
- Injects generated variables into globals.css :root section
- Runs on every build (dev and production)
- Prevents manual sync issues
3. **frontend/tailwind.config.ts** (UPDATED)
- Now imports colors from colors.mjs
- Line 17: `import { colors as colorsDefinition } from "./colors.mjs";`
- Line 58: `colors: colorsDefinition,` (single source reference)
- Eliminated 80+ lines of duplicated color definitions
### Build System Integration
**frontend/package.json** (UPDATED)
- Added script: `"generate-css-vars": "node scripts/generate-css-vars.mjs"`
- Updated `"dev"`: now runs `npm run generate-css-vars && next dev`
- Updated `"build"`: now runs `npm run generate-css-vars && next build`
**start_servers.py** (UPDATED)
- Added build step in `setup_frontend()` method
- Runs `node scripts/generate-css-vars.mjs` before `npm run build`
- Ensures CSS variables are synchronized before every build
### Verification
✅ CSS variable generation script tested and working
✅ Build process succeeds with 0 errors (5.7s compile time)
✅ All pages generated (8/8)
✅ No CSS or TypeScript warnings
✅ Commit: e715afd8 - "refactor: consolidate color definitions into single source of truth"
### Benefits Delivered
| Metric | Before | After |
|--------|--------|-------|
| Color definition locations | 2 (duplicated) | 1 (colors.mjs) |
| Lines of duplicate code | 80+ | 0 |
| Build complexity | Manual sync | Automated |
| Update effort | 2 files | 1 file |
| Sync risk | High | None |
---
## NEXT STEPS (Phase 11: Visual Testing & Version Bump)
1. **Visual Verification (RECOMMENDED):**