An intelligent document analysis tool built with Next.js that helps legal professionals analyze contracts and legal documents using AI. Upload PDF, DOCX, or TXT files to get instant summaries, extract key clauses, and analyze legal documents with the power of OpenAI.
-
Document Upload & Text Extraction
- Drag & drop interface for easy file uploads
- Supports PDF, DOCX, TXT, and Markdown files
- Client-side text extraction (no server uploads required)
- Advanced PDF parsing with PDF.js including timeout protection
- DOCX parsing with headers/footers extraction using JSZip + Mammoth
-
AI-Powered Analysis (powered by OpenAI)
- Summarize: Get concise summaries with key parties, terms, obligations, and risks
- Key Clauses: Automated extraction and checklist of critical contract clauses
- Q&A: Ask questions about specific document content (Coming Soon)
- Draft: Generate new clauses or sections based on context (Coming Soon)
-
Privacy-First Design
- All file parsing happens in the browser
- No files uploaded to your server
- Documents only sent to OpenAI API for analysis
- Node.js 20+
- npm, yarn, pnpm, or bun
- OpenAI API key (Get one here)
-
Clone the repository
git clone <repository-url> cd visualcare
-
Install dependencies
npm install
-
Set up environment variables
Create a
.env.localfile in the root directory:OPENAI_API_KEY=your_openai_api_key_here OPENAI_MODEL=gpt-4o-mini # Optional, defaults to gpt-4o-mini -
Run the development server
npm run dev
-
Open the application
Navigate to http://localhost:3000 in your browser.
-
Upload a Document
- Drag and drop a legal document (PDF, DOCX, TXT, or MD)
- Or click "Choose file" to browse and select
- The text will be automatically extracted
-
Select an Analysis Task
- Summarize: Get a comprehensive overview of the document
- Key Clauses: Extract and review critical contract clauses with status indicators
-
Run Analysis
- Click the "Run" button to process the document
- Wait for AI analysis to complete
- Review the formatted output with syntax highlighting
visualcare/
βββ app/
β βββ api/
β β βββ analyze/
β β βββ route.ts # OpenAI API integration
β βββ globals.css # Global styles
β βββ layout.tsx # Root layout
β βββ page.tsx # Main application UI
βββ lib/
β βββ extractText.ts # Document text extraction utilities
βββ public/ # Static assets
βββ next.config.ts # Next.js configuration
βββ package.json # Dependencies and scripts
βββ tailwind.config.ts # Tailwind CSS configuration
βββ tsconfig.json # TypeScript configuration
- Next.js 15.5.6 - React framework with App Router
- React 19.1.0 - UI library
- TypeScript 5 - Type safety
- Tailwind CSS 4 - Utility-first styling
- React Markdown - Markdown rendering with syntax highlighting
- PDF.js (pdfjs-dist) - PDF text extraction
- Mammoth - DOCX to text conversion
- JSZip - DOCX headers/footers extraction
- OpenAI API - Natural language processing and analysis
| Variable | Required | Default | Description |
|---|---|---|---|
OPENAI_API_KEY |
Yes | - | Your OpenAI API key |
OPENAI_MODEL |
No | gpt-4o-mini |
OpenAI model to use |
gpt-4o-mini(default, cost-effective)gpt-4o(more capable)gpt-4-turbo- Any other OpenAI chat completion model
| Command | Description |
|---|---|
npm run dev |
Start development server with Turbopack |
npm run build |
Build production bundle with Turbopack |
npm start |
Start production server |
- Client-side extraction: All document parsing happens in your browser
- No file storage: Documents are not stored on any server
- API only: Text is only sent to OpenAI API for analysis
- Secure transmission: All API calls use HTTPS
- Uses PDF.js with multiple CDN fallbacks (unpkg, cloudflare)
- Robust error handling with page-level timeouts
- Supports system fonts and embedded fonts
- Maximum image size: 1MB per image
- Timeout protection: 30s for loading, 10s per page
- Primary method: ZIP parsing for headers, body, and footers
- Fallback: Mammoth.js for body text
- Preserves formatting markers (bullets, lists)
- Normalizes whitespace for consistent output
- Removes control characters
- Normalizes spaces and line breaks
- Preserves paragraph structure
- Limits to 90,000 characters for API context
Generates comprehensive summaries including:
- Parties and dates
- Purpose and scope
- Key obligations and deliverables
- Payment, terms, and termination conditions
- Liability, indemnity, and warranties
- Confidentiality and IP rights
- Identified risks and red flags
Extracts and analyzes critical clauses:
- Parties & Definitions
- Payment & Fees
- Term & Termination
- Confidentiality
- IP Ownership/Licensing
- Warranties/Disclaimers
- Indemnification
- Limitation of Liability
- Assignment & Subcontracting
- Governing Law & Dispute Resolution
- Compliance (privacy, export, anti-bribery)
- Change Control & Notices
- Non-compete & Non-solicit
Each clause includes:
- Status (Present/Missing/Ambiguous)
- Summary
- Exact quote from document
- Documents are truncated to 90,000 characters to fit model context
- Image-based PDFs (scanned documents) cannot be processed
- Password-protected documents are not supported
- Very large files may experience slower processing times
- API usage is subject to OpenAI rate limits and pricing
Built with:
- Turbopack for fast development and builds
- TypeScript for type safety across the codebase
- ESLint for code quality
- PostCSS for CSS processing
The easiest deployment option:
- Push your code to GitHub
- Import project in Vercel
- Add
OPENAI_API_KEYenvironment variable - Deploy
This is a standard Next.js application and can be deployed to:
- AWS Amplify
- Netlify
- Railway
- Render
- Any Node.js hosting platform
See Next.js deployment documentation for details.
Contributions are welcome! Please feel free to submit a Pull Request.
This project is a POC (Proof of Concept) for demonstration purposes.
Note: This is a proof of concept project. For production use, consider adding authentication, rate limiting, error monitoring, and additional security measures.