Raj718's picture
docs: Update README with comprehensive project overview and production status
925d439

A newer version of the Gradio SDK is available: 6.13.0

Upgrade

🏠 LeaseGuard - AI-Powered Tenant Rights Assistant

Redis-Powered AI Assistant for NYC Tenant Rights Protection

Tests Security License Deployment

🎯 Overview

LeaseGuard is a comprehensive AI-powered web application that helps NYC tenants understand their rights and identify illegal clauses in their lease agreements. Built with modern security practices and production-ready architecture.

✨ Key Features

  • πŸ“„ Document Processing: Upload and analyze lease documents (PDF, images)
  • πŸ€– AI-Powered Analysis: Google Gemini AI integration for clause analysis
  • βš–οΈ Violation Detection: 20+ NYC housing law violation patterns
  • πŸ’¬ Contextual Q&A: AI chat with lease-specific context
  • πŸ”’ Security First: OWASP Top 10 compliant, production hardened
  • πŸ“Š Analytics: Session tracking and performance monitoring
  • πŸ›‘οΈ Error Resilience: Circuit breakers, retry mechanisms, graceful degradation

πŸ—οΈ Architecture

Technology Stack

  • Frontend: Next.js 14 + TypeScript + Tailwind CSS
  • Backend: Node.js + Express + Google Gemini AI
  • Database: Redis Cloud (Vector, JSON, Streams) + Supabase
  • Security: OWASP Top 10 mitigations + CIS Benchmarks
  • Deployment: Docker + Nginx + SSL/TLS
  • Testing: Jest + React Testing Library (67 tests)

System Components

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Frontend UI   β”‚    β”‚   API Gateway   β”‚    β”‚   AI Services   β”‚
β”‚   (Next.js)     │◄──►│   (Next.js)     │◄──►│   (Gemini AI)   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
         β”‚                       β”‚                       β”‚
         β”‚                       β–Ό                       β”‚
         β”‚              β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”              β”‚
         β”‚              β”‚   Redis Cache   β”‚              β”‚
         β”‚              β”‚   (Vector DB)   β”‚              β”‚
         β”‚              β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜              β”‚
         β”‚                       β”‚                       β”‚
         β–Ό                       β–Ό                       β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Document      β”‚    β”‚   Session       β”‚    β”‚   Analytics     β”‚
β”‚   Processor     β”‚    β”‚   Manager       β”‚    β”‚   (Supabase)    β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸš€ Quick Start

Prerequisites

  • Node.js 18+
  • Redis (local or cloud)
  • Google Gemini API key
  • Supabase account

Development Setup

# Clone repository
git clone https://github.com/yourusername/leaseguard.git
cd leaseguard

# Install dependencies
npm install

# Set up environment variables
cp env.production.template .env.local
# Edit .env.local with your API keys

# Start Redis (if using local)
brew services start redis

# Run development server
npm run dev

# Run tests
npm test

Production Deployment

# Run deployment script
chmod +x scripts/deploy.sh
./scripts/deploy.sh production

See DEPLOYMENT.md for detailed production deployment instructions.

πŸ§ͺ Testing

The project includes comprehensive test coverage:

# Run all tests
npm test

# Run specific test suites
npm test -- --testPathPattern="security"
npm test -- --testPathPattern="error-handling"
npm test -- --testPathPattern="health"

# Test coverage
npm run test:coverage

Test Results: 67 tests passing

  • βœ… 31 Security Configuration tests
  • βœ… 36 Error Handling & Resilience tests
  • βœ… Comprehensive API endpoint testing
  • βœ… UI component testing

πŸ”’ Security Features

OWASP Top 10 2021 Compliance

  • A01:2021 - Broken Access Control: Rate limiting, suspicious activity detection
  • A02:2021 - Cryptographic Failures: SSL/TLS, secure headers, encryption
  • A03:2021 - Injection: Input validation, sanitization, parameterized queries
  • A05:2021 - Security Misconfiguration: Secure defaults, security headers
  • A09:2021 - Security Logging: Comprehensive event logging and monitoring

Security Implementations

  • πŸ” Rate Limiting: 100 requests per 15 minutes
  • πŸ›‘οΈ CORS Protection: Origin validation and restrictions
  • 🧹 Input Sanitization: XSS protection and validation
  • πŸ“ File Upload Security: Type and size validation
  • πŸ‘€ Suspicious Activity Detection: Bot and crawler detection
  • πŸ“Š Security Event Logging: Real-time monitoring and alerts

πŸ“Š Performance & Monitoring

Key Metrics

  • Response Time: <2.5s for AI Q&A
  • Document Processing: <5s for typical leases
  • Violation Detection: <100ms with Redis caching
  • Uptime: 99.9% target with health monitoring

Monitoring Features

  • Real-time health checks
  • Performance metrics tracking
  • Error rate monitoring
  • Security event logging
  • Automated alerting

πŸ›οΈ NYC Housing Law Database

The system includes 20+ violation patterns covering:

Critical Violations (5 patterns)

  • Illegal rent increases
  • Unauthorized fees
  • Retaliatory eviction clauses
  • Waiver of rights
  • Unconscionable terms

High Priority Violations (4 patterns)

  • Security deposit violations
  • Maintenance responsibility shifts
  • Unlawful entry clauses
  • Rent control violations

Medium/Low Priority Violations (11 patterns)

  • Late fee caps
  • Subletting restrictions
  • Pet policy violations
  • Utility charge restrictions

πŸ”§ API Endpoints

Core Endpoints

GET  /api/health              # System health check
POST /api/upload              # Document upload and processing
POST /api/chat                # AI Q&A with lease context
GET  /api/session             # Session management
POST /api/analytics           # Analytics tracking

Security Endpoints

GET  /api/health              # Health monitoring
GET  /api/analytics/error     # Error tracking
GET  /api/analytics/performance # Performance metrics
GET  /api/analytics/resilience # Resilience metrics

🐳 Docker Deployment

Production Docker Compose

services:
  app:
    build: .
    environment:
      - NODE_ENV=production
      - REDIS_URL=redis://:password@redis:6379
    depends_on:
      - redis
  
  redis:
    image: redis:7-alpine
    command: redis-server --requirepass password
    
  nginx:
    image: nginx:alpine
    ports:
      - "80:80"
      - "443:443"

Security Features

  • Non-root user execution
  • SSL/TLS termination
  • Rate limiting
  • Security headers
  • Health checks

πŸ“ˆ Project Status

Completed Tasks βœ…

  1. Environment Setup & Security Hardening - Core infrastructure
  2. Core API Infrastructure - Health checks and error handling
  3. Document Processing Pipeline - PDF/image processing with AI
  4. Housing Law Database - 20+ violation patterns with >90% accuracy
  5. AI Q&A System - Contextual memory with Redis
  6. User Interface & Experience - Mobile-first responsive design
  7. Session Management & Analytics - Privacy-compliant tracking
  8. Error Handling & System Resilience - Circuit breakers and fallbacks
  9. Security Hardening & Production Deployment - Production-ready security

Test Coverage

  • Total Tests: 67 passing
  • Security Tests: 31 tests
  • Error Handling Tests: 36 tests
  • API Tests: 9 tests
  • UI Tests: 18 tests

🀝 Contributing

We welcome contributions! Please see our Contributing Guidelines for details.

Development Workflow

  1. Fork the repository
  2. Create a feature branch
  3. Write tests for new functionality
  4. Ensure all tests pass
  5. Submit a pull request

Code Standards

  • Follow S.A.F.E. D.R.Y. principles
  • Write comprehensive tests
  • Follow security best practices
  • Use TypeScript for type safety
  • Document all public APIs

πŸ“„ License

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

πŸ™ Acknowledgments

  • NYC Housing Laws: Based on NYC Rent Guidelines Board regulations
  • OWASP: Security best practices and guidelines
  • Google Gemini AI: Advanced AI capabilities
  • Redis: High-performance caching and vector search
  • Next.js: Modern React framework

πŸ“ž Support


⚠️ Legal Disclaimer: This application provides general information about tenant rights and should not be considered legal advice. Always consult with a qualified attorney for legal matters.

πŸ† Hackathon Ready: LeaseGuard is production-ready and perfect for hackathon demonstrations with its comprehensive feature set and security compliance.