Workforce Tracker HR Dashboard - Employee Time Tracking & Scheduling System
📋 Overview
A modern, full-stack HR dashboard application designed for comprehensive employee time tracking and scheduling management. Built with React and TypeScript on the frontend, Express.js backend, and PostgreSQL database integration via Drizzle ORM.
✨ Features
Core Functionality
- Employee Management: Complete CRUD operations for employee data
- Time Tracking: Clock in/out functionality with break duration tracking
- Schedule Management: Visual schedule creation with recurring pattern support
- Attendance Tracking: Daily attendance monitoring with status management
- Analytics Dashboard: Real-time productivity charts and attendance metrics
- Google Sheets Integration: Export schedules and employee data to Google Sheets
- Responsive Design: Mobile-friendly interface with adaptive layouts
Technical Features
- Type Safety: Full TypeScript implementation with Zod validation
- Real-time Updates: Live data synchronization via TanStack Query
- Error Handling: Comprehensive error boundaries and validation
- Modern UI: Radix UI components with Tailwind CSS styling
- Database ORM: Drizzle ORM for type-safe database operations
🛠️ Technology Stack
Frontend
- React 18 with TypeScript
- Wouter for client-side routing
- TanStack Query for server state management
- Tailwind CSS with custom HR-themed styling
- Radix UI components with shadcn/ui library
- Chart.js for data visualization
- Vite for development and build tooling
Backend
- Node.js with Express.js framework
- TypeScript with ES modules
- PostgreSQL with Drizzle ORM
- Neon Database (serverless PostgreSQL)
- Zod for schema validation
- Google Sheets API integration
🚀 Quick Start
Prerequisites
- Node.js (v18 or higher)
- PostgreSQL database (or Neon Database account)
- Google Cloud Console account (for Sheets integration)
Installation
- Clone the repository
git clone <repository-url>
cd hr-dashboard
- Install dependencies
- Set up environment variables
Create a
.env file in the root directory:
DATABASE_URL=your_postgresql_connection_string
GOOGLE_SHEETS_CREDENTIALS=your_google_service_account_json
- Initialize the database
- Start the development server
The application will be available at http://localhost:5000
📊 Google Sheets Integration Setup
Step 1: Create Google Cloud Project
- Go to Google Cloud Console
- Create a new project or select an existing one
- Enable the Google Sheets API:
- Navigate to “APIs & Services” → “Library”
- Search for “Google Sheets API”
- Click “Enable”
Step 2: Create Service Account
- Go to “APIs & Services” → “Credentials”
- Click “Create Credentials” → “Service Account”
- Enter a name for your service account
- Click “Create and Continue”
- Skip optional steps and click “Done”
Step 3: Generate Service Account Key
- Click on your newly created service account
- Go to the “Keys” tab
- Click “Add Key” → “Create New Key”
- Select “JSON” format
- Download the key file
Step 4: Update Google Sheets Service
Replace the mock implementation in server/google-sheets.ts with the real implementation:
import { google } from 'googleapis';
export async function createGoogleSheet(data: any[], startDate: Date | null, endDate: Date | null, customTitle?: string): Promise<string> {
try {
const credentials = JSON.parse(process.env.GOOGLE_SHEETS_CREDENTIALS || '{}');
const auth = new google.auth.GoogleAuth({
credentials,
scopes: ['https://www.googleapis.com/auth/spreadsheets'],
});
const sheets = google.sheets({ version: 'v4', auth });
const title = customTitle ||
(startDate && endDate ? `Work Schedule - ${startDate.toLocaleDateString()} to ${endDate.toLocaleDateString()}` :
'HR Data Export');
const resource = {
properties: { title },
};
const spreadsheet = await sheets.spreadsheets.create({ resource });
const spreadsheetId = spreadsheet.data.spreadsheetId!;
// Prepare headers based on data type
const headers = data.length > 0 ? Object.keys(data[0]) : [];
const values = [
headers,
...data.map(row => headers.map(header => row[header] || ''))
];
await sheets.spreadsheets.values.update({
spreadsheetId,
range: 'A1',
valueInputOption: 'RAW',
resource: { values },
});
// Format header row
await sheets.spreadsheets.batchUpdate({
spreadsheetId,
resource: {
requests: [{
repeatCell: {
range: {
sheetId: 0,
startRowIndex: 0,
endRowIndex: 1,
},
cell: {
userEnteredFormat: {
backgroundColor: { red: 0.9, green: 0.9, blue: 0.9 },
textFormat: { bold: true },
},
},
fields: 'userEnteredFormat(backgroundColor,textFormat)',
},
}],
},
});
return `https://docs.google.com/spreadsheets/d/${spreadsheetId}/edit`;
} catch (error) {
console.error('Error creating Google Sheet:', error);
throw new Error('Failed to create Google Sheet');
}
}
Step 6: Test Integration
- Create test schedules in your application
- Use the “Export to Sheets” button in Schedule Management
- Verify that a new Google Sheets document is created
- Test employee data export from Employee Management
📈 Application Improvements
Critical Issues to Address
1. Navigation Structure Fix
Issue: Console warning about nested anchor tags in sidebar navigation
Priority: High
Solution: Remove nested <a> tags and use proper Wouter Link components
2. Error Boundaries Enhancement
Issue: Missing error boundaries for React component errors
Priority: High
Solution: Implement comprehensive error boundaries with fallback UI
Issue: Time entry form validation errors (400 responses)
Priority: Critical
Solution: Add client-side validation and improve error messaging
Recommended Enhancements
Frontend Improvements
- Real-time Updates: WebSocket integration for live time tracking
- Advanced Filtering: Enhanced search and filter capabilities
- Data Visualization: More interactive charts and analytics
- Mobile Optimization: Improved responsive design for mobile devices
- Accessibility: ARIA labels and keyboard navigation support
Backend Improvements
- API Security: Rate limiting and request sanitization
- Database Optimization: Indexes for frequently queried fields
- Caching: Redis integration for improved performance
- Input Validation: Comprehensive middleware validation
- Logging: Structured logging with different log levels
Feature Additions
- User Authentication: Role-based access control system
- Advanced Reporting: PDF export and scheduled reports
- Notifications: Email and in-app notification system
- Data Import: CSV bulk import functionality
- Backup System: Automated data backup and restore
Code Quality Improvements
- Testing Suite: Unit, integration, and E2E tests
- TypeScript Strict Mode: Enhanced type safety
- Code Documentation: JSDoc comments and API documentation
- Performance Monitoring: Application performance tracking
- Security Audits: Regular security vulnerability assessments
Implementation Priority
- Fix navigation nested link issue
- Resolve schedule creation form validation
- Add basic error boundaries
- Implement proper Google Sheets integration
Phase 2 (High Priority - Next Sprint)
- Enhance form validation across all forms
- Add loading states and better UX feedback
- Implement security improvements
- Add comprehensive error handling
Phase 3 (Medium Priority - Future)
- Real-time features with WebSocket
- Advanced reporting capabilities
- Performance optimizations
- Mobile app considerations
Phase 4 (Nice to Have)
- Advanced user management system
- Comprehensive testing suite
- Advanced analytics and insights
- Third-party integrations (Slack, Teams, etc.)
🔧 Development Commands
# Start development server
npm run dev
# Build for production
npm run build
# Start production server
npm start
# Type checking
npm run check
# Database schema push
npm run db:push
🌐 Deployment
Manual Deployment
- Build the application:
npm run build
- Set environment variables on your hosting platform
- Deploy the
dist folder and server files
- Ensure PostgreSQL database is accessible
📄 API Documentation
Employee Endpoints
GET /api/employees - Get all employees
GET /api/employees/:id - Get employee by ID
POST /api/employees - Create new employee
PUT /api/employees/:id - Update employee
DELETE /api/employees/:id - Delete employee
Time Entry Endpoints
GET /api/time-entries - Get all time entries
GET /api/time-entries/active/:employeeId - Get active time entry
POST /api/time-entries - Create time entry (clock in)
PUT /api/time-entries/:id/clock-out - Clock out
Schedule Endpoints
GET /api/schedules - Get all schedules
POST /api/schedules - Create new schedule
PUT /api/schedules/:id - Update schedule
DELETE /api/schedules/:id - Delete schedule
Export Endpoints
POST /api/schedules/export-google-sheets - Export schedules to Google Sheets
POST /api/employees/export-google-sheets - Export employee data to Google Sheets
🤝 Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- 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
- Review the improvement suggestions above
Built with ❤️ using React, TypeScript, and modern web technologies