Frontend Architecture Map of Content
๐ฏ Overview
Central hub for all frontend architecture documentation, UI/UX patterns, component libraries, and implementation guides across Nimbly Compass platforms. This MOC covers web applications, mobile apps, and admin interfaces.
Quick Start
- New to frontend? Start with Frontend Overview
- Component Development? Check Component Library
- State Management? Visit State Management
- Mobile Development? See Mobile Architecture
๐๏ธ Architecture Overview
Technology Stack
Web Applications
- Framework: React 18+
- State Management: Redux Toolkit
- Styling: Material-UI + Styled Components
- Build Tool: Webpack/Vite
- Testing: Jest + React Testing Library
- Type Checking: TypeScript
Mobile Applications (2.0 App)
- Framework: React Native
- Navigation: React Navigation
- State: Redux + Redux Persist
- UI: React Native Elements
- Storage: AsyncStorage
- Testing: Detox + Jest
Application Architecture
graph TB A[User Interface] --> B[Component Layer] B --> C[Container Layer] C --> D[State Management] D --> E[API Layer] E --> F[Backend Services] C --> G[Routing] C --> H[Hooks] D --> I[Redux Store] style B fill:#f9f,stroke:#333,stroke-width:2px style D fill:#bbf,stroke:#333,stroke-width:2px
๐งฉ Component Library
Core Components
Reusable UI components across applications:
Layout Components
- AppLayout - Main application wrapper
- NavigationBar - Top navigation
- Sidebar - Side navigation
- Footer - Application footer
- PageContainer - Page wrapper
Data Display
- DataTable - Advanced tables
- Card - Content cards
- List - List displays
- Timeline - Timeline view
- Charts - Data visualization
Form Components
- FormBuilder - Dynamic forms
- TextField - Input fields
- SelectField - Dropdowns
- DatePicker - Date selection
- FileUpload - File handling
Component Patterns
// Component Structure Example
const FeatureComponent = ({ data, onAction }) => {
const [state, setState] = useState(initialState);
const dispatch = useDispatch();
useEffect(() => {
// Side effects
}, [dependencies]);
const handleAction = useCallback(() => {
// Handle user actions
}, [dependencies]);
return (
<Container>
{/* Component JSX */}
</Container>
);
};๐ฑ Platform-Specific Implementations
Web Frontend
Core web application features:
Mobile Frontend (2.0 App)
Mobile-specific implementations:
Admin Frontend
Administrative interfaces:
๐ State Management
Redux Architecture
graph LR A[UI Component] --> B[Action] B --> C[Reducer] C --> D[Store] D --> E[State] E --> A B --> F[Middleware] F --> G[API Call] G --> H[Response] H --> B style D fill:#bbf,stroke:#333,stroke-width:2px
Store Structure
{
auth: {
user: {...},
token: string,
isAuthenticated: boolean
},
features: {
dashboard: {...},
issues: {...},
reports: {...},
sites: {...},
users: {...}
},
ui: {
loading: boolean,
notifications: [],
modal: {...},
theme: 'light|dark'
}
}State Management Patterns
- Redux Toolkit Usage
- Async Actions with Thunks
- Normalized State Shape
- Reselect for Memoization
- Redux Persist Configuration
๐จ UI/UX Design System
Design Principles
- Consistency: Unified experience across platforms
- Accessibility: WCAG 2.1 AA compliance
- Responsiveness: Mobile-first approach
- Performance: Optimized rendering
- Intuitiveness: Clear user flows
Theme Configuration
const theme = createTheme({
palette: {
primary: {
main: '#1976d2',
light: '#42a5f5',
dark: '#1565c0'
},
secondary: {
main: '#dc004e',
light: '#e33371',
dark: '#9a0036'
}
},
typography: {
fontFamily: '"Roboto", "Helvetica", "Arial", sans-serif',
h1: { fontSize: '2.5rem' },
body1: { fontSize: '1rem' }
},
spacing: 8
});Component Styling
- Material-UI theming
- Styled Components
- CSS Modules
- Responsive utilities
- Animation library
๐ Performance Optimization
Code Splitting
// Route-based splitting
const Dashboard = lazy(() => import('./pages/Dashboard'));
const Reports = lazy(() => import('./pages/Reports'));
// Component-based splitting
const HeavyComponent = lazy(() =>
import(/* webpackChunkName: "heavy" */ './components/Heavy')
);Optimization Techniques
- React.memo for component memoization
- useMemo and useCallback hooks
- Virtual scrolling for large lists
- Image lazy loading
- Bundle size optimization
- Service Worker caching
Performance Monitoring
// Web Vitals tracking
import { getCLS, getFID, getFCP, getLCP, getTTFB } from 'web-vitals';
getCLS(console.log);
getFID(console.log);
getFCP(console.log);
getLCP(console.log);
getTTFB(console.log);๐ฑ Mobile Architecture
React Native Structure
src/
โโโ components/ # Shared components
โโโ screens/ # Screen components
โโโ navigation/ # Navigation config
โโโ store/ # Redux store
โโโ services/ # API services
โโโ utils/ # Utilities
โโโ assets/ # Images, fonts
Mobile-Specific Features
- Offline functionality
- Push notifications
- Camera integration
- GPS location services
- Biometric authentication
- Local storage sync
Platform Differences
// Platform-specific code
import { Platform } from 'react-native';
const styles = StyleSheet.create({
container: {
marginTop: Platform.OS === 'ios' ? 20 : 0,
...Platform.select({
ios: { shadowColor: '#000' },
android: { elevation: 4 }
})
}
});๐งช Testing Strategy
Testing Pyramid
-
Unit Tests (70%)
- Component logic
- Utility functions
- Reducers
- Selectors
-
Integration Tests (20%)
- Component integration
- API integration
- State management
-
E2E Tests (10%)
- Critical user flows
- Cross-browser testing
- Mobile app flows
Testing Examples
// Component Test
describe('IssueCard', () => {
it('renders issue details correctly', () => {
render(<IssueCard issue={mockIssue} />);
expect(screen.getByText(mockIssue.title)).toBeInTheDocument();
});
it('calls onEdit when edit clicked', () => {
const onEdit = jest.fn();
render(<IssueCard issue={mockIssue} onEdit={onEdit} />);
fireEvent.click(screen.getByText('Edit'));
expect(onEdit).toHaveBeenCalledWith(mockIssue.id);
});
});๐ง Development Tools
Development Setup
- VS Code with extensions
- React Developer Tools
- Redux DevTools
- ESLint + Prettier
- Husky + lint-staged
- Storybook
Build Pipeline
graph LR A[Source Code] --> B[Lint] B --> C[Test] C --> D[Build] D --> E[Optimize] E --> F[Deploy] style C fill:#f9f,stroke:#333,stroke-width:2px style F fill:#bbf,stroke:#333,stroke-width:2px
๐ Frontend Resources
Documentation
- Component Documentation
- State Management Guide
- Testing Best Practices
- Performance Guide
- Accessibility Guidelines
Development Guides
- Setting Up Development Environment
- Creating New Components
- Adding New Features
- Debugging Guide
- Deployment Process
Code Standards
- React Best Practices
- TypeScript Guidelines
- CSS/Styling Standards
- Component Naming Conventions
- File Structure Guidelines
๐ท๏ธ Related MOCs
- Backend Architecture
- Mobile Architecture
- Design System
- DevOps & Deployment
๐ Frontend Documentation Coverage
| Area | Documentation | Status | Priority |
|---|---|---|---|
| Component Library | โ Complete | Active | High |
| State Management | โ Complete | Active | High |
| Testing Guide | โณ In Progress | Draft | Medium |
| Performance Guide | โณ In Progress | Draft | High |
| Mobile Guide | โ Complete | Active | High |
| Accessibility | ๐ Planned | - | Medium |
This MOC is maintained by the Frontend Team. Last review: 2024-01-25 For questions or improvements, contact: Frontend Team Lead