Skip to content

Ihsanullah-Yasar/HR--IMS

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

153 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

HRโ€“IMS: Human Resource Information Management System

A modern, full-stack HR management platform built with Laravel 12 (API) and Next.js 15 (frontend). Provides comprehensive employee lifecycle management including data management, organizational structure, attendance tracking, leave management, salary administration, and document storage with enterprise-grade security and audit capabilities.

๐Ÿ—๏ธ Architecture Overview

Tech Stack

Backend (API)

  • Framework: Laravel 12 with PHP 8.2+
  • Database: SQLite (default), supports MySQL/PostgreSQL
  • ORM: Eloquent with advanced querying via Spatie Query Builder
  • Testing: PHPUnit, Laravel Pint (code style)
  • Development: Laravel Sail (Docker), Pail (log monitoring)

Frontend (Web Application)

  • Framework: Next.js 15 with App Router, React 19, TypeScript
  • Styling: Tailwind CSS v4, shadcn/ui components, Radix UI primitives
  • State Management: TanStack Query for server state, React Hook Form for forms
  • Validation: Zod schema validation
  • Icons: Lucide React, Tabler Icons

Development Tools

  • Package Managers: Composer (PHP), npm/pnpm (Node.js)
  • Build Tools: Vite (Laravel assets), Next.js built-in bundler
  • Code Quality: ESLint, Prettier, PHP CS Fixer

๐Ÿ“ Project Structure

HR--IMS/
โ”œโ”€โ”€ backend-laravel/                 # Laravel API Backend
โ”‚   โ”œโ”€โ”€ app/
โ”‚   โ”‚   โ”œโ”€โ”€ Http/
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ Controllers/Api/     # REST API Controllers
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ Requests/            # Form Request Validation
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ Resources/           # API Response Transformers
โ”‚   โ”‚   โ”œโ”€โ”€ Models/                  # Eloquent Models
โ”‚   โ”‚   โ”œโ”€โ”€ Policies/                # Authorization Policies
โ”‚   โ”‚   โ””โ”€โ”€ Traits/                  # Shared Traits
โ”‚   โ”œโ”€โ”€ database/
โ”‚   โ”‚   โ”œโ”€โ”€ migrations/              # Database Schema
โ”‚   โ”‚   โ”œโ”€โ”€ factories/               # Model Factories
โ”‚   โ”‚   โ””โ”€โ”€ seeders/                 # Database Seeders
โ”‚   โ”œโ”€โ”€ routes/
โ”‚   โ”‚   โ””โ”€โ”€ api.php                  # API Route Definitions
โ”‚   โ””โ”€โ”€ storage/                     # File Storage
โ”œโ”€โ”€ frontend-nextjs/                 # Next.js Frontend
โ”‚   โ”œโ”€โ”€ src/
โ”‚   โ”‚   โ”œโ”€โ”€ app/                     # App Router Pages
โ”‚   โ”‚   โ”œโ”€โ”€ components/              # Reusable Components
โ”‚   โ”‚   โ”œโ”€โ”€ hooks/                   # Custom React Hooks
โ”‚   โ”‚   โ””โ”€โ”€ lib/                     # Utility Libraries
โ”‚   โ””โ”€โ”€ public/                      # Static Assets
โ””โ”€โ”€ README.md                        # This File

๐Ÿ—„๏ธ Domain Entities

Core Business Objects

Entity Description Key Relationships
User Authentication and base user data Department, Audit trail
Department Organizational units with hierarchy Parent/Child departments, Manager
Designation Job titles and roles Department
Employee Personnel records User, Department, Designation
EmployeeDocument File attachments with metadata Employee
AttendanceRecord Time tracking and attendance Employee
Leave Time-off requests Employee, LeaveType
LeaveType Categories of leave -
Salary Compensation data Employee, Currency
Currency Monetary units -
AuditLog System activity tracking User, Various entities
DepartmentManager Management assignments Department, Employee

Database Schema Highlights

  • Soft Deletes: Implemented on User, Employee, Department models
  • JSON Fields: Metadata storage in EmployeeDocument, Salary components
  • Foreign Keys: Proper constraints with cascade delete where appropriate
  • Timestamps: Created/updated tracking across all entities
  • Audit Trail: Comprehensive logging of system changes

๐Ÿš€ Quick Start

Prerequisites

  • PHP: 8.2 or higher
  • Composer: Latest version
  • Node.js: 18.x or 20.x
  • Database: SQLite (included) or MySQL/PostgreSQL
  • Git: For version control

Backend Setup

# Navigate to backend directory
cd backend-laravel

# Install PHP dependencies
composer install

# Environment setup
cp .env.example .env
php artisan key:generate

# Database setup (SQLite)
php -r "file_exists('database/database.sqlite') || touch('database/database.sqlite');"
php artisan migrate --graceful

# Create storage symlink for file uploads
php artisan storage:link

# Start development server
php artisan serve
# Or use the comprehensive dev script
composer run dev

Frontend Setup

# Navigate to frontend directory
cd frontend-nextjs

# Install Node dependencies
npm install
# or
pnpm install

# Start development server
npm run dev

Environment Configuration

Backend (.env)

APP_NAME="HR-IMS"
APP_ENV=local
APP_DEBUG=true
APP_URL=http://127.0.0.1:8000

DB_CONNECTION=sqlite
DB_DATABASE=database/database.sqlite

FILESYSTEM_DISK=public

Frontend (.env.local)

NEXT_PUBLIC_API_BASE_URL=http://127.0.0.1:8000/api

๐Ÿ”Œ API Documentation

Authentication & Security

Currently, the API operates without authentication for development. For production:

  1. Implement Laravel Sanctum or Passport
  2. Add middleware to routes
  3. Configure CORS policies
  4. Implement rate limiting

Response Format

All API responses follow a consistent JSON structure:

Success Response

{
  "status": "success",
  "message": "Resource created successfully",
  "data": { ... }
}

Error Response

{
  "status": "error",
  "message": "Validation failed",
  "errors": { ... }
}

Query Parameters

The API supports advanced querying via Spatie Query Builder:

  • Filtering: ?filter[field]=value
  • Sorting: ?sort=field,-field2
  • Pagination: ?per_page=15&page=1

Available Endpoints

Users Management

GET    /api/users                    # List users with filtering
POST   /api/users                    # Create new user
GET    /api/users/{id}               # Get specific user
PUT    /api/users/{id}               # Update user
DELETE /api/users/{id}               # Delete user

Departments Management

GET    /api/departments              # List departments
POST   /api/departments              # Create department
GET    /api/departments/{id}         # Get department
PUT    /api/departments/{id}         # Update department
DELETE /api/departments/{id}         # Delete department
GET    /api/departments/{id}/form-data  # Get form data for editing

Employees Management

GET    /api/employees                # List employees
POST   /api/employees                # Create employee
GET    /api/employees/{id}           # Get employee
PUT    /api/employees/{id}           # Update employee
DELETE /api/employees/{id}           # Delete employee
GET    /api/employees/{id}/form-data # Get form data for editing

Employee Documents

GET    /api/employee-documents       # List documents
POST   /api/employee-documents       # Upload document (multipart)
GET    /api/employee-documents/{id}  # Get document
PUT    /api/employee-documents/{id}  # Update document
DELETE /api/employee-documents/{id}  # Delete document

Designations

GET    /api/designations             # List designations
POST   /api/designations             # Create designation
GET    /api/designations/{id}        # Get designation
PUT    /api/designations/{id}        # Update designation
DELETE /api/designations/{id}        # Delete designation
GET    /api/designations/{id}/form-data  # Get form data

Attendance Records

GET    /api/attendance-records       # List attendance
POST   /api/attendance-records       # Create attendance record
GET    /api/attendance-records/{id}  # Get attendance record
PUT    /api/attendance-records/{id}  # Update attendance record
DELETE /api/attendance-records/{id}  # Delete attendance record

Leave Management

GET    /api/leaves                   # List leave requests
POST   /api/leaves                   # Create leave request
GET    /api/leaves/{id}              # Get leave request
PUT    /api/leaves/{id}              # Update leave request
DELETE /api/leaves/{id}              # Delete leave request

GET    /api/leave-types              # List leave types
POST   /api/leave-types              # Create leave type
GET    /api/leave-types/{id}         # Get leave type
PUT    /api/leave-types/{id}         # Update leave type
DELETE /api/leave-types/{id}         # Delete leave type

Salary Management

GET    /api/salaries                 # List salaries
POST   /api/salaries                 # Create salary record
GET    /api/salaries/{id}            # Get salary record
PUT    /api/salaries/{id}            # Update salary record
DELETE /api/salaries/{id}            # Delete salary record

Currency Management

GET    /api/currencies               # List currencies
POST   /api/currencies               # Create currency
GET    /api/currencies/{id}          # Get currency
PUT    /api/currencies/{id}          # Update currency
DELETE /api/currencies/{id}          # Delete currency

Audit Logs

GET    /api/audit-logs               # List audit logs
GET    /api/audit-logs/{id}          # Get audit log

Request Examples

Create Employee Document

curl -X POST http://127.0.0.1:8000/api/employee-documents \
  -F "employee_id=1" \
  -F "type=contract" \
  -F "document=@/path/to/file.pdf" \
  -F "expiry_date=2025-12-31" \
  -F "metadata[description]=Employment contract"

Filter Employees by Department

curl "http://127.0.0.1:8000/api/employees?filter[department_id]=1&sort=-date_of_joining&per_page=10"

๐ŸŽจ Frontend Architecture

Page Structure

  • Dashboard: Main application interface
  • Admin: Administrative functions
  • Users: User management interface
  • Departments: Organizational structure management
  • Employees: Personnel management
  • Documents: File management interface

Component Library

  • shadcn/ui: Pre-built, accessible components
  • Radix UI: Headless component primitives
  • Custom Components: Domain-specific UI elements

State Management

  • TanStack Query: Server state management
  • React Hook Form: Form state and validation
  • Zod: Schema validation and type safety

๐Ÿงช Testing

Backend Testing

cd backend-laravel
php artisan test

Frontend Testing

cd frontend-nextjs
npm run lint
npm run build

Code Quality

# Backend
cd backend-laravel
./vendor/bin/pint

# Frontend
cd frontend-nextjs
npm run lint

๐Ÿš€ Deployment

Backend Deployment

  1. Set up PHP 8.2+ environment
  2. Configure web server (Apache/Nginx)
  3. Set up persistent storage for uploads
  4. Run migrations: php artisan migrate --force
  5. Optimize: php artisan config:cache && php artisan route:cache

Frontend Deployment

  1. Build application: npm run build
  2. Deploy to platform (Vercel, Netlify, etc.)
  3. Configure environment variables
  4. Set up API base URL

Production Checklist

  • Enable authentication
  • Configure HTTPS
  • Set up monitoring and logging
  • Implement rate limiting
  • Configure backup strategy
  • Set up CI/CD pipeline

๐Ÿ”ง Development Guidelines

Code Standards

  • PHP: PSR-12 coding standards
  • JavaScript/TypeScript: ESLint + Prettier
  • Git: Conventional commits
  • Documentation: Inline comments for complex logic

Best Practices

  • Use Form Requests for validation
  • Implement Resource transformers for API responses
  • Keep controllers thin, move business logic to services
  • Write tests for critical functionality
  • Use database transactions for data integrity

Database Conventions

  • Use migrations for schema changes
  • Implement soft deletes where appropriate
  • Add proper indexes for performance
  • Use foreign key constraints

๐Ÿค Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests if applicable
  5. Ensure code quality standards
  6. Submit a pull request

๐Ÿ“ License

This project is licensed under the MIT License - see the LICENSE file for details.

๐Ÿ†˜ Support

For support and questions:

  • Create an issue in the repository
  • Check existing documentation
  • Review API documentation above

๐Ÿ”ฎ Roadmap

Phase 1: Core Features โœ…

  • User management
  • Department structure
  • Employee records
  • Document management
  • Basic API structure

Phase 2: Advanced Features ๐Ÿšง

  • Authentication & authorization
  • Advanced reporting
  • Email notifications
  • Mobile responsiveness
  • Advanced search and filtering

Phase 3: Enterprise Features ๐Ÿ“‹

  • Multi-tenancy
  • Advanced audit logging
  • API rate limiting
  • Performance optimization
  • Advanced analytics

Built with โค๏ธ using Laravel and Next.js

About

Human resource information management system

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors