A comprehensive leave management system built with Django REST Framework (Backend) and React (Frontend) for educational institutions to manage faculty leave requests, substitutions, and approvals.
- Leave Management: Multiple leave types (Earned, Casual, Medical, Compensatory, etc.)
- Substitution System: Staff can request substitutions for their classes
- Multi-level Approval: HOD and Principal approval workflow
- Real-time Notifications: Live updates on request status
- Calendar Integration: Visual leave calendar
- PDF Reports: Automated leave reports and certificates
- Staff: Request leaves, arrange substitutions
- HOD: Approve/reject department staff leaves, view department statistics
- Principal: Final approval authority, view institution-wide data
- Admin: System administration and user management
- Django 5.2.5 - Python web framework
- Django REST Framework - API development
- SQLite (development) / PostgreSQL (production)
- JWT Authentication - Secure token-based auth
- ReportLab - PDF generation
- React 19 - User interface
- Vite - Build tool and dev server
- Tailwind CSS - Styling
- Axios - HTTP client
- React Router - Navigation
- FullCalendar - Calendar components
- Python 3.8+
- Node.js 16+
- npm or yarn
- Git
git clone <repository-url>
cd faculty-leave-appcd backend
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activatepip install -r requirements.txtcp .env.example .env
# Edit .env file with your settingspython manage.py migrate
python manage.py createsuperuserpython manage.py collectstatic --noinputcd frontend
npm installcd backend
python manage.py runserverBackend will be available at: http://localhost:8000
cd frontend
npm run devFrontend will be available at: http://localhost:5173
SECRET_KEY=your-secret-key-here
DEBUG=True
ALLOWED_HOSTS=localhost,127.0.0.1
DATABASE_URL=sqlite:///db.sqlite3
CORS_ALLOWED_ORIGINS=http://localhost:5173The backend is configured to accept requests from the React development server. For production, update CORS_ALLOWED_ORIGINS in settings.py.
- User: Custom user model with roles (Staff, HOD, Principal)
- LeaveRequest: Leave applications with status tracking
- LeaveBalance: Track leave balances for each user
- Substitution: Substitution arrangements for leave periods
- HODAction: Track HOD approvals/rejections
- NightWorkRecord: Track compensatory work
- CompensatoryWork: Compensatory leave records
The system uses JWT (JSON Web Tokens) for authentication:
- Access Token: Short-lived (60 minutes)
- Refresh Token: Long-lived (1 day)
- Token Refresh: Automatic token renewal
POST /api/auth/login/- User loginPOST /api/auth/refresh/- Refresh access tokenPOST /api/auth/logout/- User logout
GET /api/staff/leaves/- View own leave requestsPOST /api/staff/leaves/- Create new leave requestGET /api/staff/balance/- View leave balance
GET /api/hod/leaves/- View department leave requestsPOST /api/hod/leaves/{id}/approve/- Approve leavePOST /api/hod/leaves/{id}/reject/- Reject leaveGET /api/hod/leaves/department_stats/- Department statistics
GET /api/substitution/sent_requests/- View sent requestsGET /api/substitution/received_requests/- View received requestsPOST /api/substitution/- Create substitution requestPOST /api/substitution/{id}/accept/- Accept substitutionPOST /api/substitution/{id}/reject/- Reject substitution
frontend/src/
├── components/
│ ├── Auth/ # Authentication components
│ ├── Staff/ # Staff dashboard components
│ ├── HOD/ # HOD dashboard components
│ ├── Principal/ # Principal dashboard components
│ └── Common/ # Shared components
├── pages/ # Page components
├── hooks/ # Custom React hooks
├── utils/ # Utility functions
└── services/ # API service functions
-
Backend Changes:
cd backend python manage.py makemigrations python manage.py migrate -
Frontend Changes:
cd frontend npm run dev # Development server with hot reload
-
Code Quality:
# Backend cd backend black . # Format code flake8 . # Lint code # Frontend cd frontend npm run lint # Lint code
cd backend
pip install -r requirements.txt
python manage.py collectstatic --noinput
python manage.py migrate
gunicorn backend.wsgi:applicationcd frontend
npm run build
# Serve the dist/ folder with your web server- Login with your credentials
- Check Leave Balance on dashboard
- Request Leave by filling the form
- Arrange Substitution by searching for colleagues
- Wait for Approval from HOD and Principal
- Track Status in leave history
- Review Pending Leaves in approval dashboard
- Check Substitution Details before approval
- Approve/Reject with optional comments
- View Department Statistics and calendar
- Review Approved Leaves from HODs
- Final Approval/Rejection authority
- View Institution-wide statistics and reports
-
CORS Errors:
- Ensure
CORS_ALLOWED_ORIGINSincludes your frontend URL - Check if Django server is running
- Ensure
-
Authentication Issues:
- Verify JWT token is included in requests
- Check token expiration
-
Database Issues:
- Run migrations:
python manage.py migrate - Check database permissions
- Run migrations:
-
Frontend Issues:
- Clear node_modules:
rm -rf node_modules && npm install - Check browser console for errors
- Clear node_modules:
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
This project is licensed under the MIT License - see the LICENSE file for details.
For support and questions:
- Create an issue in the repository
- Contact the development team
Note: This is a faculty leave management system designed for educational institutions. Ensure proper security measures are in place before deploying to production.