Overview
Dashboard applications require careful organization of data-heavy features, real-time updates, and complex UI components. This example demonstrates how to structure an admin dashboard following the Scope Rule.Project Structure
- Next.js
- Angular
- React
Key Architectural Decisions
Sidebar Navigation
Usage: Dashboard, Analytics, Users, Settings, Reports (5+ pages) Decision: Shared within dashboard feature group Reasoning: Used by all dashboard pages. In Next.js, it goes in(dashboard)/_components/. In Angular/React, it goes in shared/components/.
Chart Components
Usage: Analytics feature, Reports feature (2 features) Decision: Shared components Reasoning: Crosses feature boundaries. Both analytics and reports need visualization components.User Avatar
Usage: Users feature only Decision: Local to users feature Reasoning: Specific to user management. Even if it appears in multiple places within user management, it stays local.Data Table
Usage: Users feature, Reports feature (2 features) Decision: Shared component Reasoning: Generic table component used across multiple features. Perfect candidate for shared.Stats Card
Usage: Dashboard page only Decision: Local to dashboard feature Reasoning: Specific to the main dashboard view. Doesn’t need to be shared.Real-time Updates Pattern
Dashboards often need real-time data. Here’s how to structure WebSocket integration:State Management Patterns
Server State
Use Server Components (Next.js) or signals (Angular) for data fetching and server state management.
Client State
Keep UI state local to components. Use context or stores only for truly global state.
Real-time State
WebSocket connections managed at the feature level with shared infrastructure.
Form State
Form state stays local to the form component. Use controlled components or form libraries.
Data Visualization Structure
Chart components are used by multiple features (analytics and reports), so they’re shared:Layout Composition
Dashboard applications typically have nested layouts:Permission-Based UI
Role-based access control stays in core/infrastructure:Performance Considerations
Data Table Virtualization
For large datasets, implement virtualization in the shared data table:Chart Performance
Memo-ize expensive chart calculations in feature-specific hooks:Testing Strategy
- Shared components - Unit test thoroughly since they’re used everywhere
- Feature components - Test in isolation with mocked dependencies
- Integration tests - Test feature flows end-to-end
- E2E tests - Test critical user journeys across features
