HRMS-UI built with TypeScript, Vite, and Material-UI.
- Frontend Framework: React 19 with TypeScript
- Build Tool: Vite 7
- UI Library: Material-UI (MUI) v7 with Emotion
- Icons Library: Material-UI (MUI) Icons
- State Management: Zustand
- Data Fetching: TanStack React Query (React Query)
- HTTP Client: Axios
- Routing: React Router DOM v7
- Internationalization: React i18next
- Date Handling: date-fns
- Utilities: Lodash, Immer
- Testing: Vitest, React Testing Library
- Code Quality: ESLint, Husky, lint-staged
src/
├── assets/ # Static assets (images, icons)
├── common/
│ ├── components/ # Reusable UI components
│ ├── types/ # TypeScript type definitions
│ └── utils/ # Utility functions
├── config/ # Application configuration
├── hooks/ # Custom React hooks
├── pages/ # Page components
└── store/
└── slices/ # Zustand store slices
- Node.js: Version 18 or higher
- Bun: Package manager (alternatively npm/yarn)
-
Clone the repository
git clone <repository-url> cd hrms-ui
-
Install dependencies
bun install
bun run devThis starts the development server at http://localhost:5173
bun run buildThis creates an optimized production build in the dist folder.
bun run previewThis serves the production build locally for testing.
# Run all tests
bun run test
# Run tests in watch mode
bun run test:watch
# Run tests with coverage
bun run test:coverage
# Open Vitest UI
bun run test:ui# Check for linting errors
bun run lint
# Fix auto-fixable linting errors
bun run lint:fix# Run TypeScript compiler check
bun run type-checkThis project uses Husky and lint-staged to ensure code quality:
- Automatic linting and formatting on commit
- Type checking before push
- Test validation on staged files
The hooks are automatically installed when you run bun install.
-
TypeScript: Use strict TypeScript. Define proper types for all components and functions.
-
Component Structure:
- Use functional components with hooks
- Keep components small and focused
- Extract reusable logic into custom hooks
-
State Management:
- Use Zustand for global state
- Use React Query for server state
- Use local state (useState) for component-specific state
-
File Naming:
- Components: PascalCase (e.g.,
UserProfile.tsx) - Hooks: camelCase starting with 'use' (e.g.,
useUserData.ts) - Utilities: camelCase (e.g.,
formatDate.ts) - Constants: UPPER_SNAKE_CASE (e.g.,
API_ENDPOINTS.ts)
- Components: PascalCase (e.g.,
-
Import Organization:
// 1. External libraries import React from 'react' import { Button } from '@mui/material' // 2. Internal imports (absolute paths preferred) import { UserType } from '@/common/types' import { useUserStore } from '@/store/slices/userSlice' // 3. Relative imports import './ComponentName.css'
- Unit Tests: Test individual components and functions
- Integration Tests: Test component interactions
- Coverage: Aim for 80%+ test coverage
- Test Structure: Use AAA pattern (Arrange, Act, Assert)
- Code Splitting: Use React.lazy() for route-based splitting
- Memoization: Use React.memo, useMemo, useCallback appropriately
- Image Optimization: Use appropriate formats and sizes
Create a .env file in the root directory:
VITE_API_BASE_URL=http://localhost:3000/api
VITE_APP_NAME=HRMS UIThe project uses a modern ESLint configuration with:
- TypeScript support
- React Hooks rules
- React Refresh compatibility
- Create a feature branch from
main - Follow the coding standards outlined above
- Write tests for new features
- Ensure all tests pass and linting is clean
- Create a pull request with a clear description
- React Documentation
- TypeScript Handbook
- Vite Guide
- Material-UI Documentation
- Zustand Documentation
- React Query Documentation
- Port already in use: Change the port in
vite.config.tsor kill the process using the port - TypeScript errors: Run
bun run type-checkto see detailed type errors - Build failures: Clear cache with
rm -rf node_modules/.viteand restart dev server