Skip to content

refactor(structure): create feature directory structure#31

Merged
peterod99 merged 4 commits intomainfrom
claude/refactor-codebase-structure-MHODq
Jan 5, 2026
Merged

refactor(structure): create feature directory structure#31
peterod99 merged 4 commits intomainfrom
claude/refactor-codebase-structure-MHODq

Conversation

@peterod99
Copy link
Copy Markdown
Owner

@peterod99 peterod99 commented Jan 4, 2026

Add feature-based directory structure with barrel exports:

  • admin: Admin dashboard, settings, analytics
  • auth: Authentication and authorization
  • chat: Chat sessions with agents
  • coach: Coaching functionality
  • dm: Direct messaging
  • forum: Community forum
  • marketing: Funnels and templates
  • subscriptions: Billing and plans
  • tenant: Multi-tenant infrastructure
  • training: Courses and lessons

Also includes REFACTOR_PLAN.md with full refactoring strategy.

Summary by CodeRabbit

Release Notes

  • Refactor
    • Reorganized service architecture by splitting monolithic services into specialized modules
    • Restructured dashboard hooks into separate, focused utilities
    • Established feature-based directory structure across the codebase
    • Created barrel export files for streamlined module access
    • Maintained full backward compatibility with existing implementations

✏️ Tip: You can customize this high-level summary in your review settings.

claude added 4 commits January 4, 2026 22:52
Add feature-based directory structure with barrel exports:
- admin: Admin dashboard, settings, analytics
- auth: Authentication and authorization
- chat: Chat sessions with agents
- coach: Coaching functionality
- dm: Direct messaging
- forum: Community forum
- marketing: Funnels and templates
- subscriptions: Billing and plans
- tenant: Multi-tenant infrastructure
- training: Courses and lessons

Also includes REFACTOR_PLAN.md with full refactoring strategy.
Split 572-line unifiedKnowledgeService.ts into focused modules:
- knowledge/types.ts: Type definitions
- knowledge/knowledgeMetricsService.ts: Counts and metrics
- knowledge/knowledgeGapsService.ts: Gap detection and optimization
- knowledge/knowledgeAnalysisService.ts: Content analysis and cross-agent insights
- knowledge/knowledgeQualityService.ts: Quality assessment
- knowledge/knowledgeSyncService.ts: Search, sync, and real-time updates

Original file now serves as a facade for backward compatibility.
Split 491-line useDashboardData.tsx into focused hooks:
- dashboard/types.ts: Shared type definitions
- dashboard/useDashboardAnalytics.ts: User/subscription analytics
- dashboard/useDashboardAgentUsage.ts: Agent usage and cost data
- dashboard/useDashboardCosts.ts: Cost breakdown by tier
- dashboard/index.ts: Barrel export

Original file now serves as a composition hook for backward compatibility.
Comprehensive log of refactoring work including:
- Baseline results
- File splits with before/after line counts
- Old path -> new path mappings
- Rationale for unchanged files
- Remaining work for future PRs
- Verification results
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jan 4, 2026

📝 Walkthrough

Walkthrough

This pull request reorganizes the codebase into a feature-based directory structure with modular domain services. It introduces feature entry points, splits the monolithic useDashboardData hook into focused dashboard-specific hooks, and replaces the unifiedKnowledgeService with five specialized knowledge domain services, all maintaining backward compatibility through facade and re-export patterns.

Changes

Cohort / File(s) Summary
Documentation & Planning
REFACTOR_LOG.md, REFACTOR_PLAN.md
Comprehensive project documentation detailing the refactoring strategy, baseline metrics, completion tracking, risk assessment, and verification procedures.
Feature Directory Scaffolding
src/features/admin/index.ts, src/features/auth/index.ts, src/features/chat/index.ts, src/features/coach/index.ts, src/features/dm/index.ts, src/features/forum/index.ts, src/features/marketing/index.ts, src/features/subscriptions/index.ts, src/features/tenant/index.ts, src/features/training/index.ts
Placeholder barrel modules establishing new feature-based directory organization. Each contains descriptive headers and commented export scaffolds for future component, hook, and service migrations with no active exports.
Dashboard Hooks Refactoring
src/hooks/dashboard/types.ts, src/hooks/dashboard/useDashboardAnalytics.ts, src/hooks/dashboard/useDashboardAgentUsage.ts, src/hooks/dashboard/useDashboardCosts.ts, src/hooks/dashboard/index.ts
New modular dashboard hooks split from monolithic useDashboardData. Introduces shared types (interfaces, constants, utility functions) and three focused hooks for analytics, agent usage, and cost breakdowns.
Dashboard Composition Update
src/hooks/useDashboardData.tsx
Refactored to compose data from three specialized dashboard hooks rather than managing state and fetching directly. Updated return type to use imported types from ./dashboard/types. Re-exports types for backward compatibility.
Knowledge Services Modularization
src/services/knowledge/types.ts, src/services/knowledge/knowledgeMetricsService.ts, src/services/knowledge/knowledgeGapsService.ts, src/services/knowledge/knowledgeAnalysisService.ts, src/services/knowledge/knowledgeQualityService.ts, src/services/knowledge/knowledgeSyncService.ts, src/services/knowledge/index.ts
Extracts knowledge domain functionality from unifiedKnowledgeService into five specialized services (Metrics, Gaps, Analysis, Quality, Sync), each with focused responsibilities. New shared types module centralizes domain interfaces. Barrel export consolidates public surface.
Knowledge Facade Refactoring
src/services/unifiedKnowledgeService.ts
Converted from monolithic implementation to lightweight facade that delegates to specialized knowledge services. Removes embedded logic; methods now bind to corresponding service methods. Type definitions moved to ./knowledge/types; re-exported for backward compatibility.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 A rabbit's ode to refactor day:

Feature folders bloom in ordered array,
Dashboard hooks now dance, focused and light,
Knowledge services split—each plays its part right,
Facades stay friendly for backward's good way,
Structure reborn, yet nothing goes astray! 🌿✨


📜 Recent review details

Configuration used: defaults

Review profile: CHILL

Plan: Free

📥 Commits

Reviewing files that changed from the base of the PR and between 4ca65d1 and 0b69ffb.

📒 Files selected for processing (26)
  • REFACTOR_LOG.md
  • REFACTOR_PLAN.md
  • src/features/admin/index.ts
  • src/features/auth/index.ts
  • src/features/chat/index.ts
  • src/features/coach/index.ts
  • src/features/dm/index.ts
  • src/features/forum/index.ts
  • src/features/marketing/index.ts
  • src/features/subscriptions/index.ts
  • src/features/tenant/index.ts
  • src/features/training/index.ts
  • src/hooks/dashboard/index.ts
  • src/hooks/dashboard/types.ts
  • src/hooks/dashboard/useDashboardAgentUsage.ts
  • src/hooks/dashboard/useDashboardAnalytics.ts
  • src/hooks/dashboard/useDashboardCosts.ts
  • src/hooks/useDashboardData.tsx
  • src/services/knowledge/index.ts
  • src/services/knowledge/knowledgeAnalysisService.ts
  • src/services/knowledge/knowledgeGapsService.ts
  • src/services/knowledge/knowledgeMetricsService.ts
  • src/services/knowledge/knowledgeQualityService.ts
  • src/services/knowledge/knowledgeSyncService.ts
  • src/services/knowledge/types.ts
  • src/services/unifiedKnowledgeService.ts

Note

🎁 Summarized by CodeRabbit Free

Your organization is on the Free plan. CodeRabbit will generate a high-level summary and a walkthrough for each pull request. For a comprehensive line-by-line review, please upgrade your subscription to CodeRabbit Pro by visiting https://app.coderabbit.ai/login.

Comment @coderabbitai help to get the list of available commands and usage tips.

@peterod99 peterod99 merged commit 5388f9c into main Jan 5, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants