Skip to content

sidgureja7803/ClauseGuard

Repository files navigation

ClauseGuard - AI Risk Analyzer for Business Contracts

πŸš€ FULLY IMPLEMENTED - Production-ready SaaS application for AI-powered contract analysis that scans contracts for risks in seconds.

βœ… Implementation Status

ClauseGuard is now complete with all requested features implemented:

  • βœ… Landing Page - Beautiful hero section with "Scan Your Contracts for Risk in Seconds"
  • βœ… Authentication - Clerk integration with Google & GitHub OAuth
  • βœ… Dashboard - Sidebar navigation (Home, Upload, History, Settings)
  • βœ… File Upload - Drag-and-drop for PDF/DOCX/TXT files
  • βœ… AI Analysis - IBM Granite models for risk detection and rewrite suggestions
  • βœ… History & Analytics - View past uploads with download capabilities
  • βœ… Settings - User preferences and account management
  • βœ… Cloud Storage - Cloudinary integration for file storage
  • βœ… Production Ready - Docker, deployment configs, error handling

🎯 Key Features

  • πŸ”Ž Clause Summarization - AI-powered contract clause breakdown
  • ⚠️ Risk Detection - Identify risky clauses with severity levels (Safe/Review/Risky)
  • ✍️ Safe Rewrite Suggestions - Get AI-generated safer alternatives
  • πŸ“Š Dashboard - Track upload history and analytics with usage quotas
  • πŸ” Secure Authentication - OAuth with Google & GitHub via Clerk
  • ☁️ Cloud Storage - File storage via Cloudinary
  • πŸ“± Responsive Design - Works on desktop, tablet, and mobile
  • πŸš€ Production Ready - Complete deployment setup

πŸ›  Tech Stack

Frontend:

  • React 18 + TypeScript
  • Tailwind CSS for styling
  • Vite for build tooling
  • Clerk Authentication
  • Axios for API calls
  • React Router for navigation
  • React Dropzone for file uploads
  • Framer Motion for animations

Backend:

  • Express.js + TypeScript
  • MongoDB with Mongoose
  • IBM Granite AI Models
  • Cloudinary Storage
  • PDF/DOCX/TXT parsing
  • Winston logging
  • Helmet security
  • CORS configuration

AI Models (IBM Granite):

  • granite-4b-instruct-v2 - Document analysis & risk detection
  • granite-8b-instruct-v1 - Clause summarization
  • granite-code-v1 - Rewrite suggestions

πŸš€ Quick Start

1. Clone and Install

git clone <repo-url>
cd ClauseGuard
npm install

2. Environment Setup

Frontend (.env):

cp frontend/env.config.example frontend/.env

Edit frontend/.env:

VITE_CLERK_PUBLISHABLE_KEY=pk_test_your_clerk_key
VITE_API_URL=http://localhost:3001/api
VITE_NODE_ENV=development

Backend (.env):

cp backend/env.config.example backend/.env

Edit backend/.env with your actual keys:

PORT=3001
NODE_ENV=development
MONGODB_URI=mongodb://localhost:27017/clauseguard
CLERK_SECRET_KEY=sk_test_your_clerk_secret
IBM_GRANITE_API_KEY=your_ibm_granite_api_key
IBM_GRANITE_BASE_URL=https://us-south.ml.cloud.ibm.com
CLOUDINARY_CLOUD_NAME=your_cloudinary_cloud_name
CLOUDINARY_API_KEY=your_cloudinary_api_key
CLOUDINARY_API_SECRET=your_cloudinary_api_secret

3. Start Development Servers

Option 1: Start both simultaneously

npm run dev

Option 2: Start individually

# Terminal 1 - Backend
cd backend && npm run dev

# Terminal 2 - Frontend  
cd frontend && npm run dev

4. Access the Application

πŸ“‹ Required Services Setup

1. MongoDB

  • Install locally OR use MongoDB Atlas
  • Default local connection: mongodb://localhost:27017/clauseguard

2. Clerk Authentication

  • Sign up at clerk.com
  • Create a new application
  • Configure OAuth providers (Google, GitHub)
  • Get publishable and secret keys

3. IBM Granite AI

  • Apply for IBM Granite API access
  • Get your API key and region endpoint
  • Models used: granite-4b-instruct-v2, granite-8b-instruct-v1, granite-code-v1

4. Cloudinary

  • Sign up at cloudinary.com
  • Get cloud name, API key, and secret
  • Used for contract file storage

πŸ— Project Structure

ClauseGuard/
β”œβ”€β”€ frontend/                 # React + TypeScript frontend
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ components/      # Reusable UI components
β”‚   β”‚   β”œβ”€β”€ pages/          # Main application pages
β”‚   β”‚   β”œβ”€β”€ lib/            # Utilities and configurations
β”‚   β”‚   └── types/          # TypeScript type definitions
β”‚   β”œβ”€β”€ public/             # Static assets
β”‚   └── package.json
β”œβ”€β”€ backend/                 # Express + TypeScript backend
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ routes/         # API route handlers
β”‚   β”‚   β”œβ”€β”€ services/       # Business logic services
β”‚   β”‚   β”œβ”€β”€ models/         # MongoDB models
β”‚   β”‚   β”œβ”€β”€ middleware/     # Express middleware
β”‚   β”‚   └── server.ts       # Main server file
β”‚   └── package.json
β”œβ”€β”€ docker-compose.yml       # Docker development setup
β”œβ”€β”€ vercel.json             # Vercel deployment config
└── deployment-guide.md     # Detailed deployment instructions

🎨 UI Features

Landing Page

  • Hero section with gradient backgrounds
  • Feature cards with animations
  • Statistics section
  • Call-to-action buttons
  • Responsive navigation

Dashboard

  • Sidebar navigation with active states
  • User statistics and usage tracking
  • Recent uploads display
  • Quick upload button
  • Welcome messages

Upload Page

  • Drag-and-drop file upload
  • File type validation (PDF, DOCX, TXT)
  • Upload progress indicators
  • File size limits
  • Real-time status updates

Analysis Results

  • Contract sections in organized cards
  • Risk level badges (Safe/Review/Risky)
  • Clause summaries
  • Rewrite suggestions
  • Confidence scores

History

  • Searchable upload history
  • Filtering by date and risk level
  • Download analysis as PDF
  • Pagination for large datasets

Settings

  • User profile management
  • Usage quota tracking
  • Account preferences
  • API key management

πŸ”§ API Endpoints

Authentication

  • POST /api/auth/webhook - Clerk webhook handler
  • GET /api/auth/me - Get current user

File Upload

  • POST /api/upload - Upload contract file
  • GET /api/upload/:id - Get upload status

Analysis

  • GET /api/analysis/:id - Get analysis results
  • POST /api/analysis/:id/reanalyze - Trigger reanalysis

User Management

  • GET /api/user/profile - Get user profile
  • PUT /api/user/preferences - Update preferences
  • GET /api/user/usage - Get usage statistics

πŸš€ Production Deployment

See deployment-guide.md for comprehensive deployment instructions covering:

  • Frontend: Vercel deployment
  • Backend: Railway, Render, or DigitalOcean
  • Database: MongoDB Atlas
  • Domain: Custom domain setup
  • SSL: Automatic HTTPS
  • Monitoring: Error tracking and analytics

πŸ§ͺ Testing

# Run frontend tests
cd frontend && npm test

# Run backend tests  
cd backend && npm test

# Run linting
npm run lint

πŸ”’ Security Features

  • Helmet.js security headers
  • CORS configuration
  • File upload validation
  • Rate limiting
  • Input sanitization
  • Secure session management
  • Environment variable protection

πŸ“ˆ Performance

  • Code splitting and lazy loading
  • Image optimization
  • CDN integration via Cloudinary
  • Database indexing
  • Caching strategies
  • Background processing

🐳 Docker Support

# Development with Docker
docker-compose up -d

# Production build
docker build -t clauseguard-backend ./backend
docker build -t clauseguard-frontend ./frontend

πŸ“ž Support

For setup assistance or deployment questions:

  1. Check the deployment-guide.md for detailed instructions
  2. Verify all environment variables are properly set
  3. Ensure all required services (MongoDB, Clerk, IBM Granite, Cloudinary) are configured

πŸ“„ License

MIT License - see LICENSE file for details


ClauseGuard - Making contract analysis accessible and secure for everyone. πŸ›‘οΈ

About

ClauseGuard is a Production-ready SaaS application for AI-powered contract analysis that scans contracts for risks in seconds.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages