Smart Contract Reviewer - Hackathon Submission
Inspiration
Legal compliance in employment contracts is a critical challenge for businesses operating in Morocco. Many HR professionals, legal consultants, and employers struggle to ensure their employment contracts (CDI, CDD) fully comply with the complex Moroccan Labor Code. Manual contract review is time-consuming, error-prone, and requires specialized legal expertise that isn't always accessible to smaller businesses. We were inspired to democratize legal compliance by creating an AI-powered tool that could automatically analyze employment contracts and provide instant, accurate compliance assessments, making legal protection accessible to everyone in the Moroccan business community.
What it does
Smart Contract Reviewer is an intelligent LegalTech platform that automatically analyzes employment contracts for compliance with Moroccan Labor Law. The system allows users to upload contracts in PDF or DOCX format, then uses advanced AI to:
- Extract and analyze contract clauses using natural language processing
- Compare contract terms against Moroccan Labor Code requirements
- Identify potential legal issues and non-compliant clauses
- Generate comprehensive compliance reports with AI-driven insights
- Provide specific references to relevant labor law articles
- Offer actionable suggestions for contract improvements
The tool serves HR professionals, legal consultants, auditors, employers, and employees, ensuring that employment agreements meet legal standards while reducing the risk of labor disputes.
How we built it
We architected Smart Contract Reviewer as a scalable microservices system with three core components:
Frontend (React + Vite): Built a modern, responsive interface using JavaScript and Tailwind CSS for seamless contract upload and report visualization.
Backend (Spring Boot): Developed robust REST APIs with Java 17, implementing role-based security and handling contract processing workflows.
AI Service (FastAPI): Created the intelligence layer using Python 3.10+, integrating Google's Gemini LLM with LangChain for advanced contract analysis and legal reasoning.
Infrastructure: Connected services via RabbitMQ for asynchronous message processing and Redis for caching, ensuring scalable performance. The entire system runs on Docker containers, making deployment and scaling effortless.
The workflow processes contracts by extracting text, splitting and indexing content, retrieving relevant legal clauses, and using Gemini's AI capabilities to perform comprehensive compliance analysis.
Challenges we ran into
- Handling long and unstructured contract documents efficiently with LLMs.
- Building a robust RAG pipeline to match contract clauses with the correct legal references.
- Synchronizing multiple services (AI, backend, frontend) via RabbitMQ in real-time.
- Managing LLM latency and optimizing performance within containerized environments.
Accomplishments that we're proud of
- Successfully integrated Google Gemini LLM with LangChain to create accurate legal analysis capabilities
- Built a fully functional microservices architecture that can scale horizontally
- Achieved seamless contract processing from upload to comprehensive compliance reporting
- Created an intuitive user interface that makes complex legal analysis accessible to non-lawyers
- Implemented robust asynchronous processing that handles real-world contract volumes efficiently
- Developed a system that provides actionable insights, not just identification of issues
- Established a foundation that can be extended to other legal domains and jurisdictions
What we learned
AI Integration: Gained deep insights into prompt engineering and fine-tuning large language models for specialized legal applications.
Legal Technology: Understood the complexity of translating legal frameworks into computational logic while maintaining accuracy and reliability.
Microservices Architecture: Mastered the coordination of distributed systems, message queuing, and asynchronous processing at scale.
- Implementing CI/CD workflows: using GitHub Actions for automation and reliability.
User Experience in LegalTech: Learned how to present complex legal information in an accessible, actionable format for diverse user groups.
Collaborative Development: Enhanced our skills in cross-functional teamwork, combining AI/ML expertise with full-stack development capabilities.
What's next for Smart Contract Reviewer
Enhanced AI Capabilities: Integrate additional LLMs and develop custom legal reasoning models trained specifically on Moroccan labor law precedents.
Expanded Legal Coverage: Extend beyond employment contracts to cover commercial agreements, service contracts, and other business legal documents.
Multi-language Support: Add Arabic and French language support to serve the diverse Moroccan business environment.
Advanced Analytics: Implement trend analysis and risk scoring to help organizations understand their overall legal compliance posture.
Integration Ecosystem: Develop APIs and plugins for popular HR management systems and legal practice management tools.
Mobile Application: Create mobile apps for on-the-go contract review and approval workflows.
Log in or sign up for Devpost to join the conversation.