šŸ¤– Leave Application AI Agent

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.

Leave Agent Workflow

🌟 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

  1. Clone the repository

    git clone <repository-url>
    cd leave-application-agent
    
  2. Set up the backend

    cd backend
    cp .env.example .env
    # Add your Google API key to .env file
    uv sync
    
  3. Run the server

    uv run python main.py
    
    The server will start on http://localhost:7007
  4. 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.