An intelligent, full-stack leave processing system powered by AI that automates leave application analysis, approval workflows, and decision-making for corporate environments, schools, government offices, and any organization that handles employee leave requests.

š Features
š§ AI-Powered Intelligence
- Smart Leave Classification: Automatically categorizes applications as MEDICAL or CASUAL using Google Gemini 2.0 Flash
- Natural Language Processing: Understands leave requests written in natural language
- Intelligent Date Extraction: Automatically parses start dates, end dates, and calculates leave duration
- Context-Aware Responses: Generates personalized replies for applicants
ā” Automated Workflow
- Multi-Step Decision Process: Uses LangGraph for sophisticated workflow orchestration
- Leave Balance Validation: Checks available leave balance before processing
- Smart Auto-Approval: Single-day medical leaves are automatically approved
- Human-in-the-Loop: Complex cases are routed to human reviewers
- Instant Rejection: Applications exceeding balance are automatically rejected with explanations
š§ Technical Excellence
- RESTful API: FastAPI-based backend with comprehensive CORS support
- Scalable Architecture: Modular design suitable for enterprise deployment
- Type Safety: Structured outputs using Pydantic models
- State Management: LangGraph handles complex workflow states
- Production Ready: Built with modern Python practices and UV package management
šļø Architecture
š Quick Start
Prerequisites
- Python 3.11 or higher
- UV package manager
- Google API key for Gemini
Installation
-
Clone the repository
git clone <repository-url> cd leave-application-agent
-
Set up the backend
cd backend cp .env.example .env # Add your Google API key to .env file uv sync
-
Run the server
uv run python main.py
The server will start onhttp://localhost:7007
-
Test the API
curl -X POST "http://localhost:7007/leaves/apply" \ -H "Content-Type: application/json" \ -d '"I need medical leave for 2 days starting from June 1st due to fever"'
š ļø Project Structure
leave-application-agent/
āāā backend/
ā āāā main.py # FastAPI application entry point
ā āāā agents/
ā ā āāā agentWorkflow.py # AI agent workflow implementation
ā āāā pyproject.toml # Project dependencies and metadata
ā āāā uv.lock # Lockfile for reproducible builds
ā āāā .env.example # Environment variables template
āāā frontend/ # Next.js UI (Coming Soon)
āāā docs/
ā āāā leave-agent.png # Workflow diagram
āāā README.md # This file
š§ Configuration
Environment Variables
Create a
.env
file in the backend directory:GOOGLE_API_KEY=your_google_api_key_here
Built with ā¤ļø using FastAPI, LangChain, LangGraph, and Google Gemini AI
Interested in this project?
Check out the full source code and documentation on GitHub.