A modern contractor time-off tracking application that integrates with Outlook Calendar to automatically detect PTO events and manage balance deduction.
- 🔐 Microsoft OAuth2 Integration - Secure authentication with Microsoft accounts
- 📅 Automatic Calendar Sync - Detects PTO events from Outlook Calendar automatically
- ⚖️ Smart Balance Tracking - Real-time PTO balance calculations with business day precision
- 📊 Interactive Dashboard - Clean, responsive interface showing balance and PTO history
- 🎯 Keyword Detection - Customizable keywords for automatic PTO event recognition
- 📱 Mobile Responsive - Works seamlessly on desktop, tablet, and mobile devices
- ⚡ Performance Optimized - <2s page loads, <5s calendar sync
- 🧪 Well Tested - Comprehensive test coverage with unit, integration, and E2E tests
- Node.js 18.x or later
- PostgreSQL 14.x or later
- Microsoft Azure AD App with Calendar.Read permissions
-
Clone the repository
git clone https://github.com/your-org/pto-manager.git cd pto-manager -
Set up environment variables
# Copy environment template cp .env.example .env # Edit .env with your configuration nano .env
-
Install dependencies
# Backend dependencies cd backend npm install # Frontend dependencies cd ../frontend npm install
-
Set up the database
# Start PostgreSQL (using Docker) docker run --name pto-postgres \ -e POSTGRES_USER=ptomanager \ -e POSTGRES_PASSWORD=dev_password \ -e POSTGRES_DB=pto_manager_dev \ -p 5432:5432 -d postgres:14 # Run migrations cd backend npm run db:migrate
-
Start the development servers
# Terminal 1: Backend server cd backend npm run dev # Terminal 2: Frontend server cd frontend npm run dev
-
Open your browser
- Frontend: http://localhost:3001
- Backend API: http://localhost:3000
├── backend/ # Node.js/Express API server
│ ├── src/
│ │ ├── models/ # Data models (Contractor, PTOEntry, etc.)
│ │ ├── services/ # Business logic services
│ │ ├── api/ # REST API endpoints
│ │ ├── middleware/ # Authentication, error handling
│ │ └── utils/ # Utilities (date, encryption, etc.)
│ ├── tests/ # Backend tests
│ └── migrations/ # Database schema migrations
├── frontend/ # React/TypeScript client
│ ├── src/
│ │ ├── components/ # Reusable UI components
│ │ ├── pages/ # Page components
│ │ ├── services/ # API client, authentication
│ │ ├── hooks/ # Custom React hooks
│ │ └── utils/ # Client-side utilities
│ └── tests/ # Frontend tests
└── specs/ # Project specifications and docs
Create a .env file in the project root:
# Database Configuration
DATABASE_URL="postgresql://username:password@localhost:5432/pto_manager_dev"
# Microsoft Graph API
MICROSOFT_CLIENT_ID="your_azure_app_client_id"
MICROSOFT_CLIENT_SECRET="your_azure_app_client_secret"
MICROSOFT_TENANT_ID="common"
MICROSOFT_REDIRECT_URI="http://localhost:3000/auth/callback"
# Application Configuration
JWT_SECRET="your_jwt_secret_key_here"
NODE_ENV="development"
PORT=3000
FRONTEND_URL="http://localhost:3001"
# Security
ENCRYPTION_KEY="your_32_character_encryption_key"- Register an application in Azure AD
- Configure redirect URI:
http://localhost:3000/auth/callback - Grant API permissions:
Calendars.Read(Delegated)User.Read(Delegated)
- Generate a client secret
- Note the Application (client) ID
- Sign in with Microsoft - Click the login button and authenticate with your Microsoft account
- Set PTO Allocation - Configure your annual PTO days in Settings
- Customize Keywords - Add custom keywords for PTO detection (optional)
- Sync Calendar - Click "Sync Calendar" to import existing PTO events
- Dashboard shows your current balance and recent PTO entries
- Sync Calendar button updates from Outlook Calendar
- PTO History page shows all your time-off entries with filtering
- Settings page allows you to update allocation and preferences
You can manually add PTO entries that won't sync from calendar:
- Go to Dashboard or PTO History
- Click "Add Manual Entry"
- Fill in dates and description
- Entry will be included in balance calculations
The complete API documentation is available in OpenAPI format:
- Local Development: http://localhost:3000/api-docs
- Specification File:
specs/001-pto-manager-contractor/contracts/api-spec.yaml
POST /api/v1/auth/login- Initiate OAuth2 loginPOST /api/v1/auth/callback- Handle OAuth2 callbackGET /api/v1/contractor/profile- Get contractor profilePOST /api/v1/calendar/sync- Sync calendar eventsGET /api/v1/pto/entries- Get PTO entriesGET /api/v1/pto/balance- Get current balancePOST /api/v1/pto/entries- Create manual PTO entry
Backend:
npm run dev # Start development server with hot reload
npm run build # Build for production
npm run start # Start production server
npm test # Run all tests
npm run test:watch # Run tests in watch mode
npm run test:coverage # Run tests with coverage report
npm run lint # Run ESLint
npm run db:migrate # Run database migrations
npm run db:seed # Seed database with test dataFrontend:
npm run dev # Start Vite development server
npm run build # Build production bundle
npm run preview # Preview production build
npm test # Run Jest tests
npm run test:watch # Run tests in watch mode
npm run test:e2e # Run Playwright E2E tests
npm run lint # Run ESLint
npm run format # Format code with PrettierThe project includes comprehensive testing at multiple levels:
- Unit Tests - Business logic, utilities, components
- Integration Tests - API endpoints, database operations
- Contract Tests - Microsoft Graph API compatibility
- E2E Tests - Complete user workflows
- Performance Tests - Load times, memory usage
# Run all tests
npm test
# Run specific test types
npm run test:unit
npm run test:integration
npm run test:e2e
npm run test:performance
# Generate coverage report
npm run test:coverage- TypeScript - Type safety and better developer experience
- ESLint - Code linting with React and TypeScript rules
- Prettier - Code formatting
- Husky - Git hooks for pre-commit checks
- Jest - Unit and integration testing
- Playwright - End-to-end testing
Backend:
- Runtime: Node.js 18+
- Framework: Express.js
- Language: TypeScript
- Database: PostgreSQL with connection pooling
- Authentication: OAuth2 + JWT
- API Integration: Microsoft Graph SDK
- Testing: Jest, Supertest
Frontend:
- Framework: React 18
- Language: TypeScript
- Build Tool: Vite
- State Management: React Query (TanStack Query)
- Styling: Tailwind CSS
- UI Components: Headless UI
- Testing: Jest, React Testing Library, Playwright
- OAuth2 PKCE Flow for secure authentication
- Server-side token storage with encryption at rest
- Business day calculations exclude weekends and holidays
- Real-time balance updates after any PTO changes
- Responsive design with mobile-first approach
- Performance optimized with caching and lazy loading
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Make your changes
- Add tests for new functionality
- Run the test suite (
npm test) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- Write tests for new features
- Follow existing code style (ESLint + Prettier)
- Update documentation for API changes
- Use conventional commit messages
- Ensure all tests pass before submitting PR
- Dashboard Load Time: <2 seconds
- Calendar Sync: <5 seconds for 200+ events
- API Response Time: <500ms for most endpoints
- Memory Usage: <50MB increase during normal usage
- React Query for intelligent caching and background updates
- Database indexing for fast PTO entry queries
- Batch processing for large calendar syncs
- Lazy loading for non-critical components
- Compressed responses with gzip
- OAuth2 + PKCE for secure authentication
- JWT tokens with reasonable expiration times
- Encrypted token storage using AES-256
- Input validation on all API endpoints
- CORS protection for cross-origin requests
- Rate limiting to prevent abuse
- Security headers (helmet.js)
-
Environment Setup
# Set production environment variables export NODE_ENV=production export DATABASE_URL="postgresql://..." export MICROSOFT_CLIENT_ID="..." # ... other production variables
-
Build Applications
# Build backend cd backend npm run build # Build frontend cd ../frontend npm run build
-
Database Migration
cd backend npm run db:migrate -
Start Services
# Start backend server cd backend npm start # Serve frontend (use nginx or similar) # Frontend build files are in frontend/dist/
# Build images
docker build -t pto-manager-backend ./backend
docker build -t pto-manager-frontend ./frontend
# Run with docker-compose
docker-compose up -dCalendar Sync Fails:
- Check Microsoft Graph API permissions
- Verify OAuth2 redirect URI configuration
- Ensure valid refresh token
Database Connection Errors:
- Verify PostgreSQL is running
- Check DATABASE_URL configuration
- Ensure database exists and migrations are applied
Authentication Issues:
- Verify Microsoft Azure AD app configuration
- Check JWT_SECRET is set correctly
- Ensure redirect URI matches exactly
Enable debug logging:
export DEBUG=pto-manager:*
npm run devThis project is licensed under the MIT License - see the LICENSE file for details.
- Documentation: Project Wiki
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Microsoft Graph API for calendar integration
- React and Node.js communities
- Contributors and testers
Made with ❤️ for contractors who want better PTO tracking