A comprehensive AI-powered contract management platform that automates contract analysis, risk assessment, and lifecycle management using advanced machine learning and natural language processing technologies.
The AIX-CLM system is a full-stack application designed to revolutionize contract management by providing intelligent document analysis, automated risk detection, and comprehensive contract lifecycle tracking. Built with modern web technologies and powered by OpenAI's GPT models, it offers both web-based and API-based contract processing capabilities.
- Automated Document Processing: Extract key information from PDF and DOCX contracts
- Intelligent Risk Detection: Identify potential risks with severity classification (High/Medium/Low)
- Missing Clause Detection: Automatically identify standard clauses that may be missing
- Financial Terms Extraction: Parse payment schedules, amounts, and penalties
- Contract Summarization: Generate concise summaries of contract purpose and scope
- Real-time Analytics: Track contract statistics and analysis metrics
- Visual Risk Assessment: Interactive charts and graphs for risk visualization
- AI Insights Panel: Latest findings and recommendations from contract analysis
- Recent Activity Tracking: Monitor recent uploads and analysis progress
- Semantic Contract Search: Find contracts using natural language queries
- Vector-based Similarity: Leverage OpenAI embeddings for intelligent contract matching
- Multi-language Support: Process contracts in multiple languages with translation capabilities
- DeepL Integration: High-quality translation services for international contracts
- Arabic Contract Support: Specialized handling for Arabic legal documents
- Batch Translation: Process multiple documents simultaneously
- User Authentication: Secure JWT-based authentication system
- Role-based Access Control: User and admin role management
- File Upload Security: Secure document handling with UploadThing integration
- React 19: Modern UI components with TypeScript
- Tailwind CSS: Responsive design system
- Radix UI: Accessible component library
- Recharts: Data visualization and analytics
- Next.js API Routes: RESTful API endpoints
- MongoDB: Document database for contract storage
- Mongoose: ODM for MongoDB integration
- JWT Authentication: Secure token-based authentication
- OpenAI GPT-4o: Contract analysis and information extraction
- OpenAI Embeddings: Semantic search and similarity matching
- Pinecone: Vector database for knowledge base (optional)
- PDF Parsing: pdf-parse library for PDF text extraction
- DOCX Processing: mammoth library for Word document processing
- File Upload: UploadThing for secure file handling
AIX-CLM/
├── app/ # Next.js 16 App Router
│ ├── (auth)/ # Authentication pages
│ │ ├── login/page.tsx
│ │ └── register/page.tsx
│ ├── api/ # API routes
│ │ ├── auth/ # Authentication endpoints
│ │ ├── contracts/ # Contract management APIs
│ │ └── uploadthing/ # File upload handling
│ ├── dashboard/ # Main application dashboard
│ │ ├── contracts/ # Contract management pages
│ │ ├── upload/ # Contract upload interface
│ │ └── layout.tsx # Dashboard layout
│ └── globals.css # Global styles
├── components/ # React components
│ ├── ui/ # Reusable UI components
│ ├── AIInsights.tsx # AI analysis insights
│ ├── ContractsChart.tsx # Contract analytics charts
│ ├── RiskSidebar.tsx # Risk analysis sidebar
│ └── UploadContractDialog.tsx # Contract upload modal
├── lib/ # Utility libraries
│ ├── auth.ts # Authentication utilities
│ ├── contractExtractor.ts # Contract analysis service
│ ├── mongodb.ts # Database connection
│ └── uploadthing.ts # File upload configuration
├── models/ # Database models
│ ├── Contract.ts # Contract schema
│ └── User.ts # User schema
├── middleware/ # Next.js middleware
│ └── auth.ts # Authentication middleware
├── contract-extractor/ # Python contract analysis service
│ ├── app/contract_extractor.py
│ ├── requirements.txt
│ └── tests/
├── contract-searcher/ # Semantic search service
│ ├── app/contract_search.py
│ └── requirements.txt
├── pinecone_knowledgebase/ # Vector database service
│ ├── app/
│ └── scripts/
├── translator/ # Translation service
│ ├── app/
│ └── requirements.txt
└── package.json # Node.js dependencies
- Node.js 18+
- MongoDB database
- OpenAI API key
- DeepL API key (for translation features)
- UploadThing account (for file uploads)
-
Clone the repository
git clone https://github.com/OptiMealCMUQ/AIX-CLM.git cd AIX-CLM -
Install dependencies
npm install
-
Set up environment variables Create a
.env.localfile in the root directory:MONGODB_URI=mongodb://localhost:27017/aix-clm OPENAI_API_KEY=your_openai_api_key DEEPL_API_KEY=your_deepl_api_key UPLOADTHING_SECRET=your_uploadthing_secret UPLOADTHING_APP_ID=your_uploadthing_app_id JWT_SECRET=your_jwt_secret NEXTAUTH_URL=http://localhost:3000
-
Start the development server
npm run dev
-
Access the application Open http://localhost:3000 in your browser
For advanced features, set up the Python services:
-
Contract Extractor Service
cd contract-extractor pip install -r requirements.txt -
Contract Search Service
cd contract-searcher pip install -r requirements.txt -
Translation Service
cd translator pip install -r requirements.txt
The application uses MongoDB for data storage. Ensure your MongoDB instance is running and accessible via the MONGODB_URI environment variable.
- OpenAI API Key: Required for contract analysis and AI features
- DeepL API Key: Required for translation services
- UploadThing: Required for secure file uploads
- Maximum file size: 10MB (configurable)
- Supported formats: PDF, DOCX, DOC
- Secure file handling with automatic virus scanning
- Create an account or log in with existing credentials
- Secure JWT-based authentication with role management
- Navigate to the Upload page
- Drag and drop or select contract files (PDF/DOCX)
- Files are automatically processed and stored securely
- Click "Analyze" on any uploaded contract
- AI automatically extracts:
- Contracting parties
- Key dates (effective, expiration, renewal)
- Financial terms and payment schedules
- Governing law and jurisdiction
- Risk assessment with severity levels
- Missing standard clauses
- Contract summary
- View detailed risk analysis in the Risk Sidebar
- Filter risks by severity (High/Medium/Low)
- Click on risks to highlight relevant contract sections
- Get explanations for each identified risk
- Monitor contract statistics and trends
- View AI insights and recommendations
- Track analysis progress and completion rates
- Use semantic search to find contracts by content
- Search by parties, contract type, or specific terms
- Leverage AI embeddings for intelligent matching
POST /api/auth/login- User loginPOST /api/auth/register- User registration
GET /api/contracts- List user contractsPOST /api/contracts- Upload new contractGET /api/contracts/[id]- Get contract detailsPOST /api/contracts/[id]/analyze- Analyze contractPOST /api/contracts/analyze- Bulk analysis
POST /api/uploadthing- Secure file upload endpoint
npm run test# Contract Extractor
cd contract-extractor
python -m pytest tests/
# Contract Search
cd contract-searcher
python -m pytest tests/
# Translation Service
cd translator
python -m pytest tests/npm run build
npm startA full micro-service stack is provided via docker-compose.yml. It spins up
| Service | Port | Purpose |
|---|---|---|
| libretranslate | 5000 | Lightweight open-source translation engine |
| translator-api | 8000 | FastAPI wrapper that first calls DeepL (if configured) then falls back to LibreTranslate |
| analyzer-api | 9000 | Knowledge-base & legal reviewer (FastAPI) |
| contract-extractor-api | 9100 | GPT-powered structured information extractor |
| contract-searcher-api | 9200 | Hybrid MongoDB + semantic search endpoint |
All containers share a Docker network so services can call each other by name
(e.g. http://translator:8000).
- Docker 20.10+ and the Compose v2 plugin (
docker compose version). - A running MongoDB instance (or use an external Atlas cluster).
- Environment variables in a root-level
.envfile:
OPENAI_API_KEY=sk-...
MONGODB_URI=mongodb://mongo:27017/contract_db # or external Atlas URI
PINECONE_API_KEY=your_pinecone_key # only if you enable analyzer
PINECONE_INDEX_NAME=qatarlaw # optional, default as shown
DEEPL_API_KEY=optional_deepl_key # improves translation quality
UPLOADTHING_SECRET=...
UPLOADTHING_APP_ID=...# build the images (first time or when code changes)
docker compose build
# start stack in the background
docker compose up -d
# follow logs (Ctrl+C to stop tailing)
docker compose logs -fThe Next.js frontend still runs outside the Compose stack (port 3000). Point it to the APIs above via environment variables or reverse-proxy.
docker compose stop # stop containers but keep state
docker compose down # stop & remove containersFor local experimentation you can comment out services you don’t need in
docker-compose.yml(e.g. disable Pinecone-based analyzer).
FROM node:18-alpine
WORKDIR /app
COPY package*.json ./
RUN npm ci --only=production
COPY . .
RUN npm run build
EXPOSE 3000
CMD ["npm", "start"]Ensure all required environment variables are set in your production environment:
- Database connection strings
- API keys and secrets
- File upload configurations
- Authentication settings
- JWT Authentication: Secure token-based authentication
- Password Hashing: bcryptjs for password security
- File Upload Security: UploadThing integration with virus scanning
- Input Validation: Comprehensive input sanitization
- CORS Protection: Configured for secure cross-origin requests
- Next.js 16: Latest performance optimizations
- React 19: Improved rendering performance
- MongoDB Indexing: Optimized database queries
- Caching: Intelligent caching for API responses
- Lazy Loading: Component-based code splitting
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the ISC License - see the LICENSE file for details.
For support and questions:
- Create an issue on GitHub
- Contact the development team
- Check the documentation wiki
- Advanced Analytics: More detailed contract analytics and reporting
- Workflow Automation: Automated contract approval workflows
- Integration APIs: Third-party system integrations
- Mobile App: React Native mobile application
- Advanced AI: Custom trained models for specific contract types
- Compliance Monitoring: Automated compliance checking
- Contract Templates: AI-generated contract templates
- v1.0.0: Initial release with core contract analysis features
- v1.1.0: Added translation services and multi-language support
- v1.2.0: Enhanced risk analysis and missing clause detection
- v1.3.0: Semantic search and vector-based contract discovery