Skip to content

Sanhith30/Multi-agent_chatbot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

9 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

SunnyAI - Agentic AI Personal Loan Assistant

SunnyAI Logo

An Enterprise-Grade Agentic AI System for Automated Personal Loan Processing

Python React FastAPI WebSocket AI

Live Demo โ€ข Architecture โ€ข ๐Ÿค– AI Agents โ€ข Quick Start โ€ข ๐Ÿ“Š Features


๐Ÿ“‹ Table of Contents


๐ŸŽฏ Project Overview

SunnyAI is a cutting-edge Agentic AI system that revolutionizes personal loan processing through intelligent automation. Built for Tata Capital, this system demonstrates enterprise-level AI orchestration with multiple specialized agents working in harmony to deliver instant loan decisions.

๐ŸŽช What Makes This Special?

  • ๐Ÿง  True Agentic AI: Not just a chatbot - a complete multi-agent system
  • โšก Instant Decisions: Loan approval in under 60 seconds
  • ๐ŸŽจ Premium UI: Professional black & gold design with smooth animations
  • ๐Ÿ“ฑ Mobile-First: Responsive design for all devices
  • ๐Ÿ”„ Real-time: WebSocket-powered live communication
  • ๐Ÿฆ Enterprise-Ready: Production-grade architecture and security

โœจ Key Features

๐Ÿค– Intelligent AI System

  • Multi-Agent Architecture with specialized roles
  • Natural Language Processing for human-like conversations
  • Context-Aware Responses with memory management
  • Intelligent Routing between different agents

๐Ÿ’ผ Complete Loan Processing

  • Instant Eligibility Check based on credit profiles
  • Automated KYC Verification with OTP validation
  • Smart Underwriting with configurable business rules
  • PDF Generation for official sanction letters

๐ŸŽจ Premium User Experience

  • Professional Black & Gold Theme with luxury aesthetics
  • Smooth Animations and micro-interactions
  • Interactive Suggestion Buttons for faster user input
  • Floating Chat Widget with elegant transitions

๐Ÿ”ง Technical Excellence

  • FastAPI Backend with async/await patterns
  • React Frontend with modern hooks and state management
  • WebSocket Communication for real-time updates
  • Modular Architecture for easy maintenance and scaling

๐Ÿ—๏ธ System Architecture

graph TB
    subgraph "Frontend Layer"
        A[React App] --> B[Floating Widget]
        A --> C[Chat Interface]
        A --> D[Suggestion System]
    end
    
    subgraph "Communication Layer"
        E[WebSocket Manager] --> F[Session Management]
    end
    
    subgraph "AI Orchestration Layer"
        G[Master Agent] --> H[Intent Analysis]
        G --> I[Context Management]
        G --> J[Agent Routing]
    end
    
    subgraph "Specialized Agents"
        K[Sales Agent] --> L[Lead Qualification]
        M[Verification Agent] --> N[KYC & OTP]
        O[Underwriting Agent] --> P[Credit Decision]
        Q[Sanction Agent] --> R[PDF Generation]
    end
    
    subgraph "Data Layer"
        S[CRM Service] --> T[Customer Data]
        U[Credit Bureau] --> V[Credit Scores]
        W[Session Store] --> X[Conversation State]
    end
    
    A --> E
    E --> G
    G --> K
    G --> M
    G --> O
    G --> Q
    K --> S
    M --> S
    O --> U
    Q --> W
Loading

๐Ÿ”„ Data Flow Architecture

  1. User Interaction โ†’ React Frontend captures user input
  2. WebSocket Communication โ†’ Real-time message transmission
  3. Master Agent Processing โ†’ Intent analysis and routing decisions
  4. Specialized Agent Execution โ†’ Domain-specific processing
  5. Data Integration โ†’ CRM and Credit Bureau API calls
  6. Response Generation โ†’ Contextual AI responses with suggestions
  7. State Management โ†’ Session persistence and context updates

๐Ÿค– Multi-Agent Orchestration

๐ŸŽฏ Master Agent (Orchestrator)

The Master Agent serves as the brain of the system, managing the entire conversation flow and coordinating between specialized agents.

class MasterAgent:
    """
    Central orchestrator managing conversation flow and agent coordination
    """
    
    async def process_message(self, user_message: str) -> Dict[str, Any]:
        # 1. Analyze user intent
        intent = await self._analyze_intent(user_message)
        
        # 2. Route to appropriate agent
        if self.conversation_state == "sales":
            return await self.sales_agent.process_message(user_message, self.user_context)
        elif self.conversation_state == "verification":
            return await self.verification_agent.process_message(user_message, self.user_context)
        # ... more routing logic

Key Responsibilities:

  • ๐Ÿง  Intent Recognition - Understanding user needs and context
  • ๐Ÿ”„ State Management - Tracking conversation progress
  • ๐ŸŽฏ Agent Routing - Directing requests to appropriate specialists
  • ๐Ÿ’พ Context Preservation - Maintaining user information across agents
  • ๐ŸŽช Error Handling - Graceful fallbacks and recovery

๐Ÿช Sales Agent (Lead Qualification)

Specialized in converting prospects into qualified loan applicants.

class SalesAgent:
    """
    Handles lead qualification and loan requirement gathering
    """
    
    async def start_sales_process(self) -> Dict[str, Any]:
        # Collect: Amount, Tenure, Purpose, Contact Info
        # Provide: EMI calculations, Rate information
        # Generate: Qualified lead with complete requirements

Core Functions:

  • ๐Ÿ’ฐ Requirement Gathering - Loan amount, tenure, purpose
  • ๐Ÿ“Š EMI Calculations - Real-time payment calculations
  • ๐ŸŽฏ Lead Qualification - Ensuring completeness before handoff
  • ๐Ÿ’ฌ Persuasive Dialogue - Converting hesitant prospects

๐Ÿ” Verification Agent (KYC & Security)

Handles identity verification and compliance requirements.

class VerificationAgent:
    """
    Manages KYC verification and identity confirmation
    """
    
    async def start_verification(self, context: Dict[str, Any]) -> Dict[str, Any]:
        # Generate OTP, Verify phone number
        # Fetch customer data from CRM
        # Validate identity and eligibility

Security Features:

  • ๐Ÿ“ฑ OTP Verification - Multi-factor authentication
  • ๐Ÿฆ CRM Integration - Customer data validation
  • ๐Ÿ” Identity Confirmation - KYC compliance
  • โšก Fast Processing - Streamlined verification flow

๐ŸŽฏ Underwriting Agent (Credit Decision)

Implements sophisticated credit decision logic with configurable rules.

class UnderwritingAgent:
    """
    Automated credit decision engine with business rules
    """
    
    def _apply_underwriting_rules(self, credit_score: int, loan_amount: int, preapproved_limit: int):
        # Rule 1: Credit score threshold (700+)
        # Rule 2: Pre-approved limit check
        # Rule 3: Income verification requirements
        # Rule 4: Debt-to-income ratio validation

Decision Matrix:

  • ๐ŸŸข Instant Approval - Credit score 750+, within pre-approved limit
  • ๐ŸŸก Conditional Approval - Requires salary verification
  • ๐Ÿ”ด Rejection - Below credit threshold or high risk

๐Ÿ“„ Sanction Letter Agent (Document Generation)

Generates professional, legally compliant loan sanction documents.

class SanctionLetterAgent:
    """
    Professional PDF generation with Tata Capital branding
    """
    
    def _create_sanction_letter_pdf(self, context: Dict[str, Any]):
        # Professional layout with company branding
        # Complete loan terms and conditions
        # Legal compliance and regulatory requirements
        # Digital signature and approval workflow

Document Features:

  • ๐Ÿข Professional Branding - Tata Capital visual identity
  • ๐Ÿ“‹ Complete Terms - All loan conditions and schedules
  • โš–๏ธ Legal Compliance - Regulatory requirement adherence
  • ๐Ÿ”’ Secure Generation - Tamper-proof document creation

๐ŸŽจ UI/UX Design

๐ŸŒŸ Design Philosophy

Our design embodies luxury financial services with a sophisticated black and gold theme that builds trust and conveys premium quality.

๐ŸŽช Visual Elements

๐ŸŽจ Color Palette

  • Primary: Deep blacks (#000000, #0f0f0f, #1a1a1a)
  • Accent: Luxury gold (#ffd700, #ffed4e)
  • Effects: Gradients, glows, and transparency

โœจ Animations

  • Micro-interactions for button hovers and clicks
  • Smooth transitions between conversation states
  • Loading animations with golden shimmer effects
  • Floating elements with gentle motion

๐Ÿ“ฑ Responsive Design

  • Mobile-first approach with touch-optimized interactions
  • Adaptive layouts for all screen sizes
  • Progressive enhancement for different device capabilities

๐ŸŽฏ User Experience Flow

journey
    title User Journey Through SunnyAI
    section Landing
      Visit Website: 5: User
      See Floating Widget: 4: User
      Click SunnyAI Button: 5: User
    section Conversation
      Meet Sanhith: 5: User
      Share Requirements: 4: User
      Get Instant Feedback: 5: User
    section Verification
      Receive OTP: 4: User
      Verify Identity: 5: User
      Confirm Details: 5: User
    section Decision
      Wait for Processing: 3: User
      Get Instant Decision: 5: User
      Download Letter: 5: User
Loading

๐Ÿš€ Quick Start

๐Ÿ“‹ Prerequisites

  • Python 3.8+ with pip
  • Node.js 16+ with npm
  • Git for version control
  • Docker (optional, for production deployment)

โšก Development Setup

  1. Clone the Repository

    git clone https://github.com/Sanhith30/Multi-agent_chatbot.git
    cd Multi-agent_chatbot
  2. Backend Setup

    # Install Python dependencies
    pip install -r requirements.txt
    
    # Start the FastAPI server
    python run_backend.py

    ๐ŸŒ Backend runs on: http://localhost:8000

  3. Frontend Setup

    # Navigate to frontend directory
    cd frontend
    
    # Install Node.js dependencies
    npm install
    
    # Start the React development server
    npm start

    ๐ŸŒ Frontend runs on: http://localhost:3001

๐ŸŽฏ First Run

  1. Open your browser to http://localhost:3001
  2. Wait for the SunnyAI floating widget to appear (3 seconds)
  3. Click the widget to start your loan application
  4. Meet Sanhith, your AI loan advisor!

๐Ÿš€ Production Deployment

Option 1: Quick Local Production

# Windows users
deploy_windows.bat

# Linux/Mac users
python deploy_production.py

Option 2: Docker Production

# Build and start production services
docker-compose -f docker-compose.prod.yml up -d

# Access your application
# Frontend: http://localhost:3001
# Backend: http://localhost:8000
# Monitoring: http://localhost:3000

Option 3: Cloud Deployment

  • AWS: Use ECS or EKS for container orchestration
  • Azure: Deploy to Container Instances or AKS
  • Google Cloud: Use Cloud Run or GKE
  • Heroku: Simple git-based deployment

๐Ÿ”‘ Real AI Integration

For production with real AI capabilities:

  1. Get OpenAI API Key: Visit OpenAI Platform
  2. Update Environment: Add to .env file:
    OPENAI_API_KEY=sk-your-actual-api-key-here
  3. Deploy: System automatically uses real AI when key is provided

๐Ÿ“Š API Documentation

๐Ÿ”Œ WebSocket Endpoints

Main Chat Connection

WS /ws/{session_id}
  • Purpose: Real-time bidirectional communication
  • Authentication: Session-based
  • Message Format: JSON with content, sender, timestamp

File Upload

POST /upload-salary-slip/{session_id}
  • Purpose: Salary slip upload for income verification
  • Format: Multipart form data
  • Response: Processing status and next steps

Document Download

GET /download/{filename}
  • Purpose: Sanction letter PDF download
  • Security: Session-validated access
  • Format: PDF with proper headers

๐Ÿ“‹ Message Schema

{
  "content": "User message or agent response",
  "sender": "user|bot",
  "timestamp": "2024-01-07T12:00:00Z",
  "metadata": {
    "step": "current_conversation_step",
    "suggestions": ["Quick reply options"],
    "download_url": "/download/filename.pdf"
  }
}

๐Ÿงช Testing Scenarios

๐ŸŽฏ Demo Phone Numbers

Phone Number Scenario Expected Outcome
9876543210 Instant Approval Rahul Sharma, 780 credit score, โ‚น5L limit
9876543211 Salary Verification Priya Patel, 720 credit score, needs income proof
9876543212 Rejection Amit Kumar, 650 credit score, below threshold

๐Ÿ”„ Test Flow Examples

โœ… Successful Approval Flow

  1. Start with "Hi" โ†’ Meet Sanhith
  2. Share name โ†’ Personalized greeting
  3. Click "Yes, I need a personal loan"
  4. Select "โ‚น5 lakhs" โ†’ Amount confirmed
  5. Choose "2 years" โ†’ Tenure set
  6. Pick "Home renovation" โ†’ Purpose recorded
  7. Use 9876543210 โ†’ Customer found
  8. Enter OTP โ†’ Verification complete
  9. Get instant approval โ†’ Download PDF

๐Ÿ“„ Salary Verification Flow

  1. Follow steps 1-7 above
  2. Use 9876543211 โ†’ Higher amount requested
  3. Upload salary slip โ†’ Income verified
  4. Get conditional approval โ†’ Download PDF

โŒ Rejection Handling

  1. Follow steps 1-7 above
  2. Use 9876543212 โ†’ Low credit score
  3. Receive polite rejection โ†’ Alternative options provided

๐Ÿ”ง Configuration

โš™๏ธ Environment Variables

Create a .env file in the root directory:

# Server Configuration
HOST=localhost
PORT=8000
DEBUG=True

# Database Configuration (if using real DB)
DATABASE_URL=sqlite:///./loan_app.db

# External API Keys (for production)
CREDIT_BUREAU_API_KEY=your_api_key_here
SMS_GATEWAY_API_KEY=your_sms_api_key

# Security
SECRET_KEY=your_secret_key_here
JWT_ALGORITHM=HS256

๐ŸŽ›๏ธ Business Rules Configuration

Modify agents/underwriting_agent.py to adjust credit policies:

# Credit Score Thresholds
MIN_CREDIT_SCORE = 700
EXCELLENT_CREDIT_SCORE = 750

# Loan Amount Limits
MAX_LOAN_AMOUNT = 4000000  # โ‚น40 lakhs
MIN_LOAN_AMOUNT = 50000    # โ‚น50 thousand

# Income Verification Rules
SALARY_VERIFICATION_MULTIPLIER = 2.0  # 2x pre-approved limit
MAX_EMI_TO_INCOME_RATIO = 0.5  # 50% of monthly income

๐Ÿ“ˆ Performance

โšก System Metrics

  • Response Time: < 500ms average
  • Concurrent Users: 100+ supported (1000+ with production setup)
  • Memory Usage: ~200MB baseline
  • CPU Usage: < 10% under normal load
  • Uptime: 99.9% availability target

๐Ÿ”ง Optimization Features

  • Async/Await: Non-blocking I/O operations
  • Connection Pooling: Efficient database connections
  • Caching: Session and customer data caching
  • Lazy Loading: On-demand resource loading
  • WebSocket Optimization: Persistent connections for real-time communication

๐Ÿ“Š Production Scalability

graph LR
    A[Load Balancer] --> B[App Instance 1]
    A --> C[App Instance 2]
    A --> D[App Instance N]
    
    B --> E[PostgreSQL DB]
    C --> E
    D --> E
    
    B --> F[Redis Cache]
    C --> F
    D --> F
    
    G[Prometheus] --> H[Grafana Dashboard]
    I[Nginx] --> A
Loading

๐ŸŽฏ Expected Production Performance

  • Throughput: 1000+ requests/minute
  • Conversion Rate: 25-35% (vs 15-20% traditional)
  • Processing Time: < 60 seconds end-to-end
  • Cost Reduction: 70% vs manual processing

๐Ÿ› ๏ธ Technology Stack

๐Ÿ–ฅ๏ธ Backend Technologies

  • FastAPI - Modern, fast web framework for building APIs
  • WebSockets - Real-time bidirectional communication
  • Pydantic - Data validation using Python type annotations
  • ReportLab - Professional PDF generation
  • Uvicorn - Lightning-fast ASGI server

๐ŸŽจ Frontend Technologies

  • React 18 - Modern UI library with hooks
  • CSS3 - Advanced styling with animations
  • WebSocket API - Real-time communication
  • Responsive Design - Mobile-first approach

๐Ÿ”ง Development Tools

  • Git - Version control
  • ESLint - Code quality for JavaScript
  • Black - Python code formatting
  • Pytest - Python testing framework

๐ŸŽฏ Business Impact

๐Ÿ’ผ For Financial Institutions

  • ๐Ÿš€ Faster Processing: Reduce loan approval time from days to minutes
  • ๐Ÿ’ฐ Cost Reduction: Automate manual underwriting processes
  • ๐Ÿ“ˆ Higher Conversion: Improve lead-to-loan conversion rates
  • ๐ŸŽฏ Better Experience: Provide 24/7 instant service

๐Ÿ‘ฅ For Customers

  • โšก Instant Decisions: Know your loan status immediately
  • ๐Ÿ“ฑ Convenient Process: Apply from anywhere, anytime
  • ๐ŸŽช Engaging Experience: Interactive and user-friendly interface
  • ๐Ÿ”’ Secure Processing: Bank-grade security and privacy

๐Ÿš€ Future Enhancements

๐Ÿ”ฎ Planned Features

  • ๐Ÿค– Advanced AI: Integration with GPT-4 for more natural conversations โœ… READY
  • ๐ŸŒ Multi-language: Support for regional Indian languages
  • ๐Ÿ“Š Analytics Dashboard: Real-time business intelligence โœ… INCLUDED
  • ๐Ÿ”— API Integration: Connect with real banking systems โœ… READY
  • ๐Ÿ“ฑ Mobile App: Native iOS and Android applications

๐ŸŽฏ Production Ready Features

  • โ˜๏ธ Cloud Deployment: AWS/Azure/GCP deployment scripts โœ… INCLUDED
  • ๐Ÿ”„ Microservices: Containerized architecture โœ… READY
  • ๐Ÿ“ˆ Load Balancing: Handle thousands of concurrent users โœ… CONFIGURED
  • ๐Ÿ›ก๏ธ Security Hardening: Enterprise-grade security โœ… IMPLEMENTED
  • ๐Ÿ“Š Monitoring: Prometheus + Grafana dashboards โœ… INCLUDED

๐Ÿฆ Real Banking Integration Ready

  • Credit Bureau APIs: CIBIL, Experian, Equifax integration
  • SMS Gateways: Twilio, AWS SNS, MSG91 support
  • Core Banking: Temenos T24, Finacle integration
  • Payment Gateways: Razorpay, PayU, CCAvenue ready

๐Ÿ‘จโ€๐Ÿ’ป About the Developer

๐ŸŽฏ Technical Expertise Demonstrated

This project showcases proficiency in:

  • ๐Ÿค– AI/ML Engineering - Multi-agent systems and orchestration
  • ๐Ÿ–ฅ๏ธ Full-Stack Development - React frontend + Python backend
  • ๐Ÿ—๏ธ System Architecture - Scalable, maintainable design patterns
  • ๐ŸŽจ UI/UX Design - Professional, user-centric interfaces
  • โšก Performance Optimization - Async programming and real-time systems
  • ๐Ÿ”ง DevOps Practices - Git workflow, environment management

๐Ÿ’ผ Business Acumen

  • ๐Ÿฆ Financial Services Domain - Understanding of loan processing workflows
  • ๐Ÿ“Š Requirements Analysis - Translating business needs into technical solutions
  • ๐ŸŽฏ User Experience Focus - Designing for conversion and engagement
  • ๐Ÿ“ˆ Scalability Planning - Building for growth and enterprise adoption

๐Ÿค Contributing

We welcome contributions! Here's how you can help:

๐Ÿ”ง Development Setup

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/amazing-feature
  3. Make your changes and test thoroughly
  4. Commit with descriptive messages: git commit -m 'Add amazing feature'
  5. Push to your branch: git push origin feature/amazing-feature
  6. Open a Pull Request

๐Ÿ“‹ Contribution Guidelines

  • Code Quality: Follow existing code style and patterns
  • Testing: Add tests for new features
  • Documentation: Update README and code comments
  • Performance: Ensure changes don't degrade performance

๐Ÿ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.


๐ŸŒŸ Show Your Support

If you found this project helpful or interesting:

  • โญ Star this repository to show your appreciation
  • ๐Ÿด Fork it to build upon this work
  • ๐Ÿ“ข Share it with your network
  • ๐Ÿ› Report issues to help improve the project
  • ๐Ÿ’ก Suggest features for future enhancements

๐Ÿ“ž Contact & Connect


๐ŸŽฏ Production Deployment Files

This repository includes comprehensive production deployment resources:

  • deploy_production.py - Automated production deployment script
  • deploy_windows.bat - Windows deployment batch file
  • docker-compose.prod.yml - Production Docker configuration
  • Dockerfile.prod - Production-optimized Docker image
  • REAL_TIME_INTEGRATION.md - Complete real-time deployment guide
  • production_setup.md - Step-by-step production setup
  • GO_LIVE_GUIDE.md - Comprehensive go-live checklist

๐Ÿš€ Ready for Enterprise Deployment

This system is production-ready and can be deployed to handle real loan applications with:

  • Real OpenAI GPT-4 integration
  • Banking system APIs
  • Enterprise security
  • Monitoring and analytics
  • Horizontal scaling
  • 99.9% uptime target

Built with โค๏ธ for the future of financial services

Transforming loan processing through intelligent automation

Made with Python Made with React Powered by AI

About

An Enterprise-Grade Agentic AI System for Automated Personal Loan Processing

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors