UI Architecture Standards
Mandatory standards for UI folder organization, component development patterns, and quality requirements across all frontend projects.
UI Architecture Standards
Overview
This document outlines our recommended standards for UI folder organization, component development patterns, and quality requirements across frontend projects. Following these standards helps ensure consistency, maintainability, and scalability of our UI architecture.
Why UI Standards Matter
Through our development experience, we've found that consistent UI architecture significantly improves team collaboration, speeds up development, and creates a better foundation for AI collaboration. These standards have evolved through practical application and solving real-world challenges in our applications.
Purpose & Scope
This guide is designed to help all developers working on UI components:
- UI folder structure best practices and organization
- Component development patterns and their benefits
- Integration approaches with our existing architecture
- Testing and performance standards for quality
- Quality assurance techniques for consistent UI
1. UI Folder Structure
Our three-tiered UI architecture (foundation, patterns, business) is designed to create clear separation between different types of components. This approach makes components more reusable, easier to test, and creates a natural progression from simple to complex UI elements.
Recommended UI Organization
We recommend following this folder structure for optimal organization and discoverability:
This structure provides several benefits:
- Clear responsibility boundaries between different component types
- Predictable imports that make component discovery easier
- Logical progression from simple (foundation) to complex (business) components
- Easier ownership with different teams potentially owning different layers
Component Placement Guidelines
Deciding where to place a component in our architecture is important for maintainability and reusability. The following guidelines can help you make these decisions:
Foundation Components
(Do ✅) Place basic UI building blocks in the foundation layer
Foundation components are the atomic building blocks of our UI system:
Foundation components should be:
- Single-purpose, atomic UI elements
- Free from business logic or domain knowledge
- Highly reusable across many contexts
- Used by 3+ other components OR fundamental to the design system
- Examples: Button, Input, Text, Card, Icon
(Consider 🤔) Creating a foundation component when you see the same UI pattern repeated
If you find yourself creating similar UI elements in multiple places, consider extracting them into foundation components.
(Don't ❌) Include business logic or domain-specific behavior in foundation components
Pattern Components
(Do ✅) Use pattern components for complex UI compositions
Pattern components combine multiple foundation components to create more complex, reusable UI patterns:
Pattern components should be:
- Composed of multiple foundation components
- Handling complex UI behavior but no domain-specific logic
- Reusable across different features and contexts
- Examples: Modal, Form, DataTable, Carousel, Tabs
(Consider 🤔) Extracting common UI interaction patterns into pattern components
When you notice the same combination of foundation components appearing together with similar behavior, consider creating a pattern component.
(Don't ❌) Mix domain-specific logic with pattern components
Instead, create a generic DataTable pattern component and let business components or features handle the domain-specific aspects.
Business Components
(Do ✅) Create business components for domain-specific UI needs
Business components integrate with specific domains and display domain-specific data:
Business components should:
- Integrate with specific domain logic and APIs
- Use hooks from the domains layer
- Display domain-specific data in a consistent way
- Examples: ProductCard, UserAvatar, OrderSummary, PaymentForm
(Consider 🤔) Creating business components when the same domain entity UI appears in multiple features
When multiple features need to display the same type of domain entity in a consistent way, a business component helps maintain consistency and reduces duplication.
(Don't ❌) Make business components too specific to a single feature context
Business components should be reusable across different features that work with the same domain entity:
- Mixing component types within same folder
2. Component Development Standards
Well-structured components make code more maintainable, testable, and easier to understand. These standards represent patterns we've found effective across many projects.
2.1 Component File Organization
(Do ✅) Organize each component in a dedicated folder with consistent structure
A well-organized component structure makes it easier to find files and understand their purpose:
This structure provides several benefits:
- Separation of concerns: Each file has a clear, single responsibility
- Testing clarity: Tests are co-located with the component they test
- Import simplicity: Barrel exports create clean import statements
- Discoverability: Consistent structure makes finding things predictable
(Do ✅) Type Definitions:
(Do ✅) Barrel Export:
2.3 Design Token Integration
Design tokens are the foundation of a consistent visual language. They help maintain a cohesive look and feel across the application and make theme changes much simpler to implement.
(Do ✅) Always use design tokens for visual properties
Design tokens provide a single source of truth for visual styles and enable easier theming and maintenance:
This approach provides several benefits:
- Consistency: All components use the same visual values
- Themability: Changing theme is centralized in token files
- Maintainability: Visual changes can be made in one place
- Design alignment: Tokens match design system specifications
(Consider 🤔) Creating component-specific token extensions when needed
For specialized components, consider extending the token system in a structured way:
(Don't ❌) Use arbitrary hardcoded values for visual properties
Hardcoded values create inconsistency and make maintenance difficult:
This creates several problems:
- Inconsistency: Different components use different values
- Maintenance challenges: Changes require updating many files
- Theme limitations: Dark mode and other themes become difficult to implement
- Design drift: No guarantee that values match design specifications
Domain Integration Rules
(Do ✅) Business components can import from domains:
(Don't ❌) Foundation/Pattern components cannot import domains:
Feature Integration Rules
(Do ✅) Features can import any UI components:
(Don't ❌) UI components cannot import from features:
3. Integration with Existing Architecture
Domain Integration Rules
(Do ✅) Business components can import from domains:
(Don't ❌) Foundation/Pattern components cannot import domains:
Feature Integration Rules
(Do ✅) Features can import any UI components:
(Don't ❌) UI components cannot import from features:
4. Naming Conventions (Enforced)
Component Naming
- Files: PascalCase (e.g.,
Button.tsx,ProductCard.tsx) - Folders: PascalCase (e.g.,
Button/,DataTable/) - Props Interfaces: ComponentName + Props (e.g.,
ButtonProps,ModalProps)
Consistent Export Patterns
5. Accessibility Requirements
Required Accessibility Features
Every component must implement these accessibility features:
1. Semantic Roles
2. State Communication
3. Dynamic Content
6. Testing Requirements
Required Test Patterns
(Do ✅) Every component must have:
- Render test
- Props validation test
- User interaction test (if applicable)
- Accessibility test
Testing Coverage Requirements
- Unit Tests: 80%+ coverage required
- Accessibility Tests: All accessibility features must be tested
- Visual Regression Tests: Required for all visual states
- Integration Tests: Required for complex business components
7. Performance Requirements
(Do ✅) Performance Standards:
- Use React.memo for components with complex props
- Implement proper prop comparison for expensive re-renders
- Avoid inline styles in render methods
- Use StyleSheet.create for static styles
(Don't ❌) Performance Anti-Patterns:
- Creating style objects in render
- Missing memoization for expensive computations
- Unnecessary re-renders from prop drilling
8. Documentation Requirements
(Do ✅) Every component must have:
- JSDoc comments for component and props
- Usage examples in comments
- Accessibility notes
9. Quality Control and Enforcement
Required Checks Before Merge
- Component in correct folder (foundation/patterns/business)
- Uses design tokens (no hardcoded values)
- Proper TypeScript interfaces
- Barrel exports implemented
- Unit tests included
- Accessibility features complete
- Documentation complete
- Performance optimizations applied
ESLint Rules Integration
Code Review Checklist
Architecture Compliance
- Component placed in correct folder
- Follows naming conventions
- Proper import/export patterns
- No architecture rule violations
Design Token Usage
- All colors use theme tokens
- Typography follows token system
- Spacing uses consistent tokens
- No hardcoded values
Accessibility
- Proper semantic roles
- Screen reader support
- Keyboard navigation
- Focus management
Performance
- Appropriate memoization
- Efficient re-rendering
- Bundle size impact
- Runtime performance
10. Migration and Adoption
Project Migration Steps
- Create ui/ folder with foundation/patterns/business structure
- Move existing components to appropriate folders
- Update all imports across the project
- Add missing TypeScript interfaces
- Integrate design tokens
- Add required tests
Legacy Component Handling
- Deprecation Period: 3 months for existing components
- Migration Support: Provide migration guides
- Backward Compatibility: Maintain during transition
- Documentation: Clear migration paths
11. Enforcement and Compliance
Automated Checks
- ESLint rules for import restrictions
- TypeScript strict mode compliance
- Test coverage requirements (80%+)
- Design token usage validation
Manual Review Process
- Architecture compliance review
- Accessibility audit
- Performance assessment
- Documentation review
Non-Compliance Consequences
- Warning Phase: First violation gets warning and guidance
- Blocking Phase: Second violation blocks merge until fixed
- Training Phase: Repeated violations require team training
Related Documents
- UI Architecture Overview - Complete architecture guide
- Foundation Components Guide - Component development patterns
- Component Development Workflow - Step-by-step development process
- AI Collaboration Guide for UI Development - AI consistency patterns
- Core Architecture - System architecture
- Domain Architecture Guide - Domain integration patterns
- Project Structure - File organization
- File Naming Conventions - Naming standards
- Communication Patterns - Cross-feature integration
These standards ensure consistent, maintainable, and high-quality UI components across all frontend projects.
UI Architecture Overview
Comprehensive guide to UI folder organization, component hierarchy, and integration with the core architecture for consistent frontend development.
AI Collaboration Guide for UI Development
Standardized AI prompts, patterns, and quality validation for consistent UI component development across all projects.