mirror of
https://github.com/bitbaum/botsmann.git
synced 2026-12-05 03:59:14 +01:00
Reduced CitizenProfile.tsx from 650 to 115 lines by extracting: - CitizenProfileHeader: avatar and participation score display - CitizenProfileTabs: tab navigation component - CitizenOverviewTab: citizen summary and tax distribution cards - CitizenTaxTab: tax payment history table - CitizenBenefitsTab: benefits list with eligibility check - CitizenAdvisoryTab: advisory distribution sliders Leveraged existing types from types/governance.ts and utilities from lib/governance/utils.ts for DRY compliance. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
4.1 KiB
4.1 KiB
Task Plan & Priority Queue
Comprehensive refactoring for Botsmann - improve maintainability, performance, and code quality.
Status: IN PROGRESS
P0 - Analysis & Planning (COMPLETED)
- Audit all components for size (identify >200 line files)
- Identify repeated code patterns across codebase
- Document current architecture pain points
- Create refactoring priority list
Findings Summary
Large Components (>200 lines):
- CitizenProfile.tsx (650 lines) - Needs split into types + smaller components
- WorkspaceDashboard.tsx (642 lines) - Complex demo, needs extraction
- ExampleSection.tsx (515 lines) - Large example showcase
- DemoSection.tsx (503 lines) - Demo orchestration
- AICaseAnalysis.tsx (441 lines) - Analysis component
- 30+ more files over 200 lines
Bot Page Duplication:
- All 5 bot pages share identical boilerplate (~60 lines each)
- Same pattern: imports, getTryLink(), menuItems, BotNavigation, section structure
- CSS animations duplicated across styles.css files
- Inconsistent main container padding patterns
- Different error message styling
P1 - Bot Page Deduplication (COMPLETED ✓)
- Create
components/shared/BotPageTemplate.tsx- Generic page template - Create
components/shared/BotSection.tsx- Section wrapper - Create
components/shared/BotNotFoundFallback.tsx- Error component - menuItems already centralized in
data/bots.ts - Refactor all 6 bot pages to use new template:
- medical-expert
- research-assistant
- artistic-advisor
- legal-expert
- swiss-german-teacher
- product-manager
- Each page imports CSS locally (page-specific styles preserved)
Actual Impact: ~200+ LOC saved, consistent bot page structure, faster new bot creation
P2 - Large Component Breakdown (IN PROGRESS)
-
Split CitizenProfile.tsx (650→115 lines):
- Types already in
types/governance.ts - Created
citizen/CitizenProfileHeader.tsx - Created
citizen/CitizenProfileTabs.tsx - Created
citizen/CitizenOverviewTab.tsx - Created
citizen/CitizenTaxTab.tsx - Created
citizen/CitizenBenefitsTab.tsx - Created
citizen/CitizenAdvisoryTab.tsx
- Types already in
-
Split WorkspaceDashboard.tsx (642 lines) into smaller components
-
Split ExampleSection.tsx (515 lines) into example cards
-
Review and split other >300 line components
P3 - Code Deduplication (DRY)
- Consolidate repeated utility functions into
lib/ - Create shared hooks for common patterns (
hooks/) - Centralize API call patterns
- Extract constants to
lib/constants.ts
P4 - Architecture Improvements
- Fix blog dynamic server usage errors (no-store fetch issue)
- Separate UI components from container/logic components
- Improve data fetching patterns (server components where appropriate)
- Review and optimize file organization
P5 - Performance Optimization
- Add React.memo to expensive pure components
- Implement useMemo/useCallback where beneficial
- Audit and optimize image loading
- Review bundle size and code splitting opportunities
P6 - Verification
- Run full test suite (
npm run test) - Lint check (
npm run lint) - Build verification (
npm run build) - Manual smoke test of key features
Completed Tasks
- Previous task: Fixed all TypeScript errors and lint warnings (2026-01-11)
- Ralph setup for refactoring task (2026-01-11)
- Deployed to Vercel (2026-01-11) - https://botsmann-orangecat.vercel.app
- Codebase audit completed (2026-01-11)
- P1: Bot page deduplication - Created BotPageTemplate, refactored all 6 bot pages (2026-01-13)
- MDX build error fix - Added sanitization for
<followed by numbers in lib/knowledge.ts (2026-01-13) - Security: Fixed glob CLI command injection vulnerability (CVE-2025-64756) via npm override (2026-01-13)
- P2: Split CitizenProfile.tsx from 650→115 lines with 6 sub-components (2026-01-13)
Notes
- Follow
docs/BEST_PRACTICES.mdfor coding standards - Maintain backward compatibility
- No breaking changes to API routes
- Test after each significant refactor