Skip to content
shrirampai3000Public

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

HRMS UI

HRMS-UI built with TypeScript, Vite, and Material-UI.

Tech Stack

  • 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

Project Structure

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

Prerequisites

  • Node.js: Version 18 or higher
  • Bun: Package manager (alternatively npm/yarn)

Installation

  1. Clone the repository

    git clone <repository-url>
    cd hrms-ui
  2. Install dependencies

    bun install

Getting Started

Development Server

bun run dev

This starts the development server at http://localhost:5173

Build for Production

bun run build

This creates an optimized production build in the dist folder.

Preview Production Build

bun run preview

This serves the production build locally for testing.

Testing & Code Quality

Running Tests

# 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

Code Quality Checks

ESLint

# Check for linting errors
bun run lint

# Fix auto-fixable linting errors
bun run lint:fix

Type Checking

# Run TypeScript compiler check
bun run type-check

Pre-commit Hooks

This 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.

Development Guidelines

Code Style & Standards

  1. TypeScript: Use strict TypeScript. Define proper types for all components and functions.

  2. Component Structure:

    • Use functional components with hooks
    • Keep components small and focused
    • Extract reusable logic into custom hooks
  3. State Management:

    • Use Zustand for global state
    • Use React Query for server state
    • Use local state (useState) for component-specific state
  4. 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)
  5. 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'

Testing Best Practices

  1. Unit Tests: Test individual components and functions
  2. Integration Tests: Test component interactions
  3. Coverage: Aim for 80%+ test coverage
  4. Test Structure: Use AAA pattern (Arrange, Act, Assert)

Performance Guidelines

  1. Code Splitting: Use React.lazy() for route-based splitting
  2. Memoization: Use React.memo, useMemo, useCallback appropriately
  3. Image Optimization: Use appropriate formats and sizes

Configuration

Environment Variables

Create a .env file in the root directory:

VITE_API_BASE_URL=http://localhost:3000/api
VITE_APP_NAME=HRMS UI

ESLint Configuration

The project uses a modern ESLint configuration with:

  • TypeScript support
  • React Hooks rules
  • React Refresh compatibility

Contributing

  1. Create a feature branch from main
  2. Follow the coding standards outlined above
  3. Write tests for new features
  4. Ensure all tests pass and linting is clean
  5. Create a pull request with a clear description

Additional Resources

Troubleshooting

Common Issues

  1. Port already in use: Change the port in vite.config.ts or kill the process using the port
  2. TypeScript errors: Run bun run type-check to see detailed type errors
  3. Build failures: Clear cache with rm -rf node_modules/.vite and restart dev server

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages