Skip to content

Simple Project of Spring Boot Application And Reactjs Builded Full Authentication & Authorization With Clean Architecture

Notifications You must be signed in to change notification settings

shutiyare/react_spring_app

Repository files navigation

πŸš€ Didi - Advanced Employee Management System Frontend

A comprehensive React TypeScript frontend for managing employees, departments, roles, and permissions with advanced role-based access control.

πŸ“‹ Overview

Didi is a feature-rich Employee Management System frontend built with React, TypeScript, and Tailwind CSS. It provides complete role-based access control with three user types (ADMIN, MANAGER, USER) and integrates seamlessly with a Spring Boot backend using comprehensive REST APIs.

✨ Advanced Features

πŸ” Authentication & Authorization

  • JWT-based authentication with secure token management
  • Role-based access control (ADMIN, MANAGER, USER)
  • Secure login and registration with validation
  • Password change functionality
  • Automatic token refresh handling
  • Server-side logout integration

πŸ‘₯ Complete Employee Management

  • ADMIN: Full CRUD operations on employees
  • MANAGER: Read-only access to all employees
  • USER: View and edit own profile only
  • Advanced employee search and filtering
  • Pagination with customizable page sizes
  • Department-based filtering
  • Detailed employee profiles with comprehensive information
  • Employee creation and editing forms with validation
  • Salary management and hire date tracking

🏒 Department Management

  • ADMIN: Full CRUD operations on departments
  • MANAGER: Read-only access to departments
  • Department listing with inline editing
  • Department creation with code validation
  • Real-time validation and error handling

πŸ‘€ Advanced Profile Management

  • Comprehensive user profile editing
  • Employee information integration
  • Password change functionality
  • Role-specific field access
  • Real-time form validation

πŸ”§ Admin Panel (ADMIN Only)

  • Role Management: Create, edit, delete system roles
  • Permission Management: Manage fine-grained permissions
  • Role-Permission Assignment: Flexible permission assignment
  • Advanced admin controls
  • System administration tools

πŸ“Š Enhanced Role-Based Dashboards

  • Admin Dashboard: System statistics, recent hires, employee counts, admin tools
  • Manager Dashboard: Team overview, department statistics, employee metrics
  • User Dashboard: Personal profile, quick actions, employee information

πŸ› οΈ Advanced Technology Stack

  • Frontend: React 19.1.0 with TypeScript
  • Routing: React Router DOM 7.6.3 with protected routes
  • Styling: Tailwind CSS 3.3.5 with custom components
  • Forms: React Hook Form 7.53.0 with advanced validation
  • HTTP Client: Axios 1.10.0 with interceptors
  • Notifications: React Hot Toast 2.4.1
  • Icons: Heroicons React 2.1.1
  • UI Components: Headless UI 2.1.0
  • State Management: React Context with role-based permissions

πŸ—οΈ Advanced Project Structure

src/
β”œβ”€β”€ components/
β”‚   β”œβ”€β”€ auth/              # Authentication components
β”‚   β”‚   β”œβ”€β”€ LoginForm.tsx
β”‚   β”‚   └── SignupForm.tsx
β”‚   β”œβ”€β”€ common/            # Shared components
β”‚   β”‚   β”œβ”€β”€ ProtectedRoute.tsx
β”‚   β”‚   └── ToastProvider.tsx
β”‚   └── layout/            # Layout components
β”‚       β”œβ”€β”€ DashboardLayout.tsx
β”‚       └── Sidebar.tsx
β”œβ”€β”€ context/
β”‚   └── AuthContext.tsx    # Advanced authentication context
β”œβ”€β”€ pages/                 # Complete page components
β”‚   β”œβ”€β”€ AdminPanel.tsx     # Role & permission management
β”‚   β”œβ”€β”€ DashboardPage.tsx  # Role-based dashboards
β”‚   β”œβ”€β”€ DepartmentListPage.tsx
β”‚   β”œβ”€β”€ EmployeeDetailsPage.tsx
β”‚   β”œβ”€β”€ EmployeeFormPage.tsx
β”‚   β”œβ”€β”€ EmployeeListPage.tsx
β”‚   β”œβ”€β”€ LoginPage.tsx
β”‚   β”œβ”€β”€ ProfilePage.tsx
β”‚   └── SignupPage.tsx
β”œβ”€β”€ services/              # Complete API services
β”‚   β”œβ”€β”€ api.ts            # Advanced Axios configuration
β”‚   β”œβ”€β”€ auth.ts           # Authentication services
β”‚   β”œβ”€β”€ departmentService.ts
β”‚   β”œβ”€β”€ employeeService.ts
β”‚   β”œβ”€β”€ permissionService.ts
β”‚   β”œβ”€β”€ roleService.ts
β”‚   └── userProfileService.ts
β”œβ”€β”€ types/                 # Comprehensive TypeScript definitions
β”‚   └── index.ts
└── App.tsx               # Advanced routing with role protection

πŸš€ Getting Started

Prerequisites

  • Node.js 16.x or higher
  • npm or yarn
  • Spring Boot backend running on http://localhost:9090

Installation

  1. Clone the repository
git clone <repository-url>
cd didi
  1. Install dependencies
npm install
  1. Configure environment variables (optional) Create a .env file in the root directory:
REACT_APP_API_BASE_URL=http://localhost:9090
REACT_APP_JWT_TOKEN_KEY=employee_management_token
REACT_APP_REFRESH_TOKEN_KEY=employee_management_refresh_token
  1. Start the development server
npm start

The application will open at http://localhost:3000.

πŸ”‘ Default Test Credentials

Use these credentials to test different user roles:

Role Username Password Access Level
Admin admin admin123 Full system access + Admin Panel
Manager manager manager123 Read-only access to employees/departments
User user user123 Personal profile access only

🎯 Advanced User Roles & Permissions

πŸ‘‘ ADMIN (Full System Access)

  • Employee Management: Create, read, update, delete all employees
  • Department Management: Full CRUD operations on departments
  • Role Management: Create and manage system roles
  • Permission Management: Assign and manage permissions
  • Admin Panel: Access to advanced administration tools
  • System Statistics: View comprehensive system analytics
  • All Navigation: Access to all application areas

πŸ‘¨β€πŸ’Ό MANAGER (Read-Only Management)

  • Employee Viewing: Read-only access to all employee profiles
  • Department Viewing: Read-only access to all departments
  • Team Statistics: Access to team and department analytics
  • Limited Navigation: Employee and department sections only
  • No CRUD Operations: Cannot create, edit, or delete records

πŸ‘€ USER (Personal Access)

  • Personal Profile: View and update own information
  • Limited Editing: Can only edit phone number and basic profile
  • Employee Info: View own employee record (if exists)
  • Minimal Navigation: Dashboard and profile only
  • No System Access: Cannot view other users or system data

πŸ“± Complete Pages & Features

Authentication Pages

  • Login Page: JWT authentication with comprehensive validation
  • Signup Page: User registration with password requirements and validation

Dashboard Pages

  • Admin Dashboard: System overview, employee metrics, recent hires, quick actions
  • Manager Dashboard: Team statistics, department breakdown, employee summary
  • User Dashboard: Personal information, profile summary, quick actions

Employee Management (Full CRUD)

  • Employee List: Advanced pagination, search, department filtering
  • Employee Details: Comprehensive employee information display
  • Employee Form: Create/edit forms with extensive validation
  • Profile Management: Personal profile editing with role-based permissions

Department Management

  • Department List: Inline editing, modal-based CRUD operations
  • Department Forms: Creation and editing with code validation
  • Department Assignment: Employee-department relationship management

Advanced Administration (ADMIN Only)

  • Role Management: Create, edit, delete system roles
  • Permission Assignment: Flexible permission-role mapping
  • System Administration: Advanced admin controls
  • User Role Assignment: Manage user role assignments

πŸ”§ Complete API Integration

The frontend integrates with the Spring Boot backend using these endpoint modules:

Authentication Module (/auth)

POST /auth/login           // User login with JWT
POST /auth/register        // User registration
POST /auth/logout          // Server-side logout
POST /auth/refresh-token   // Token refresh
POST /auth/change-password // Password change

Employee Management (/api/v1/employees)

GET    /api/v1/employees                    // Paginated employee list
GET    /api/v1/employees/search             // Employee search
GET    /api/v1/employees/{id}               // Employee details
GET    /api/v1/employees/profile            // Current user profile
GET    /api/v1/employees/department/{id}    // Employees by department
POST   /api/v1/employees                    // Create employee (ADMIN)
PUT    /api/v1/employees/{id}               // Update employee (ADMIN)
PUT    /api/v1/employees/profile            // Update own profile
DELETE /api/v1/employees/{id}               // Delete employee (ADMIN)

Department Management (/api/v1/departments)

GET    /api/v1/departments     // All departments
GET    /api/v1/departments/{id} // Department details
POST   /api/v1/departments     // Create department (ADMIN)
PUT    /api/v1/departments/{id} // Update department (ADMIN)
DELETE /api/v1/departments/{id} // Delete department (ADMIN)

User Profile Management (/users)

GET /users/me    // Current user profile
PUT /users/me    // Update user profile

Role Management (/api/roles) - ADMIN Only

GET    /api/roles     // All roles
GET    /api/roles/{id} // Role details
POST   /api/roles     // Create role
PUT    /api/roles/{id} // Update role
DELETE /api/roles/{id} // Delete role

Permission Management (/api/permissions) - ADMIN Only

GET    /api/permissions     // All permissions
GET    /api/permissions/{id} // Permission details
POST   /api/permissions     // Create permission
PUT    /api/permissions/{id} // Update permission
DELETE /api/permissions/{id} // Delete permission

🎨 Advanced UI/UX Features

  • Responsive Design: Mobile-first design with tablet and desktop optimization
  • Role-based Navigation: Dynamic sidebar and menu based on user permissions
  • Advanced Loading States: Skeleton screens and progress indicators
  • Comprehensive Error Handling: Toast notifications and error boundaries
  • Real-time Form Validation: Instant feedback with detailed error messages
  • Consistent Design System: Tailwind CSS with custom component library
  • Accessibility: WCAG 2.1 compliant interface
  • Performance Optimized: Code splitting and lazy loading

πŸ”„ Advanced State Management

  • Authentication State: Global auth context with role checking
  • Permission System: Granular permission checking utilities
  • Token Management: Automatic JWT handling with refresh logic
  • Error Handling: Centralized error management with user feedback
  • Form State: Advanced form management with validation
  • API Caching: Intelligent caching for improved performance

πŸ“Š Performance & Security Features

  • Code Splitting: Optimized bundle sizes with lazy loading
  • JWT Security: Secure token storage and automatic refresh
  • API Interceptors: Request/response interceptors for error handling
  • CSRF Protection: Cross-site request forgery protection
  • Input Validation: Client and server-side validation
  • Error Boundaries: Graceful error handling and recovery

πŸ§ͺ Testing & Development

The project includes comprehensive testing setup:

  • React Testing Library: Component testing
  • Jest: Unit testing framework
  • TypeScript: Type safety and IntelliSense
  • ESLint: Code quality and consistency

Run tests:

npm test

Build for production:

npm run build

πŸ” Advanced Troubleshooting

Common Issues & Solutions

  1. API Connection Issues

    • Ensure backend is running on http://localhost:9090
    • Check CORS configuration on backend
    • Verify API endpoints match documentation
    • Check network tab for failed requests
  2. Authentication Problems

    • Clear localStorage: localStorage.clear()
    • Check JWT token expiration
    • Verify user credentials and roles
    • Check browser console for auth errors
  3. Permission Issues

    • Verify user roles in JWT token
    • Check role-based route protection
    • Ensure proper permission assignment
    • Review admin panel configuration
  4. Build Errors

    • Clear node_modules: rm -rf node_modules && npm install
    • Check TypeScript configuration
    • Verify all imports are correct
    • Update dependencies if needed

πŸ“ˆ Future Enhancements

Planned Advanced Features

  • Real-time notifications with WebSocket
  • Advanced analytics and reporting
  • Bulk operations for employee management
  • CSV/Excel import/export functionality
  • Advanced search with filters
  • Activity logging and audit trails
  • Multi-tenant support
  • Advanced dashboard customization
  • Email notification system
  • Mobile app (React Native)

Technical Improvements

  • PWA capabilities with offline support
  • Advanced caching strategies
  • Performance monitoring
  • E2E testing with Cypress
  • Internationalization (i18n)
  • Dark mode theme
  • Advanced accessibility features
  • SEO optimization

πŸ“„ API Documentation

For complete API documentation, see API_ENDPOINTS_REFERENCE.md which includes:

  • All endpoint specifications
  • Request/response examples
  • Error handling guidelines
  • Authentication requirements
  • Role-based access details

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

πŸ“ž Support

For support and questions:

  • Create an issue in the repository
  • Check the API documentation
  • Review the troubleshooting guide
  • Contact the development team

Built with ❀️ using React, TypeScript, and Tailwind CSS

A complete, production-ready Employee Management System with advanced role-based access control.

About

Simple Project of Spring Boot Application And Reactjs Builded Full Authentication & Authorization With Clean Architecture

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages