Inspiration

The inspiration behind CogniDraft stemmed from the inherent complexity and often intimidating nature of legal documents. Many individuals and businesses struggle to fully comprehend the intricate language, hidden clauses, and potential risks embedded within contracts. This often leads to reliance on expensive legal counsel for every review, or worse, signing agreements without full understanding. We envisioned a tool that could democratize access to legal insights, empowering users to quickly grasp the essence of their contracts, identify critical terms, and understand potential implications without needing a law degree. The goal was to bridge the gap between legal expertise and everyday understanding, making contract review efficient, accessible, and less daunting.

What it does

CogniDraft is an AI-powered platform designed to simplify contract analysis and drafting. It allows users to upload legal documents (PDF, DOC, DOCX) for instant AI-driven analysis. The core functionalities include:

  • AI-Powered Analysis: Automatically extracts and summarizes key clauses, providing an overall risk assessment and a detailed breakdown of each section.
  • Risk Detection: Identifies high-risk clauses, unfavorable terms, and potential legal pitfalls, categorizing them by importance and suggesting concerns.
  • Plain English Explanations: Translates complex legal jargon into clear, understandable language that anyone can comprehend.
  • Strategic Questions: Generates actionable questions tailored to specific clauses, helping users prepare for negotiations or clarify terms with counterparties.
  • Contract Comparison: Enables users to compare different versions of contracts or standardize existing ones against improved terms, highlighting changes and their implications.
  • AI Drafting Assistant: Allows users to generate new contract drafts or specific clauses from scratch, tailored to their industry, jurisdiction, and risk tolerance based on their workspace settings.
  • Real-time Updates: Provides immediate feedback on contract analysis status and streams AI-generated content for drafting and chat.
  • Workspace Management: Users can create and manage multiple workspaces, each configured with specific industry, country, company size, and risk tolerance settings, ensuring AI responses are highly contextualized.

How we built it

CogniDraft was built as a modern web application using a robust and scalable technology stack.

  • Frontend: Developed with React, leveraging its component-based architecture for a modular and maintainable user interface. We utilized Tailwind CSS for rapid and consistent styling, ensuring a clean, modern, and responsive design. Lucide React provided a comprehensive set of icons for a visually appealing and intuitive user experience.
  • Backend & Database: Supabase serves as the primary backend, providing:
    • PostgreSQL Database: For storing user profiles, workspaces, contracts, and analysis results.
    • Authentication: Handles user sign-up and sign-in processes securely.
    • Storage: Manages the upload and retrieval of contract files.
    • Edge Functions: Used for server-side logic, such as handling Lemon Squeezy webhooks for subscription management and orchestrating the AI analysis process by forwarding requests to a Cloudflare Worker.
  • AI Integration: We integrated with both OpenAI (GPT-4o-mini) and Google Gemini (gemini-2.5-pro) for the core AI capabilities, including contract analysis, clause explanation, and contract drafting. The system leverages streaming responses for a more interactive user experience during AI generation.
  • Document Processing: Files uploaded by users are processed to extract text, which is then fed to the AI models.
  • Development Environment: Vite was used as the build tool for a fast and efficient development workflow.
  • Payment Processing: Integrated with Lemon Squeezy for handling subscriptions and payments, with webhooks managed via Supabase Edge Functions to update user profiles.

The application follows a component-based design philosophy, breaking down complex features into reusable and manageable React components, which contributes to the project's scalability and ease of maintenance.

Challenges we ran into

Developing CogniDraft presented several interesting challenges:

  • Accurate AI Parsing and Contextualization: Ensuring the AI accurately extracts and understands legal nuances from diverse contract types and then contextualizes its responses based on user-defined workspace settings (industry, jurisdiction, risk tolerance) was complex. Achieving consistent and reliable output required extensive prompt engineering and iterative refinement.
  • Handling Large Documents: Processing and displaying potentially very large contract texts efficiently, especially when highlighting specific clauses, required careful optimization to maintain performance and responsiveness.
  • Real-time Data Synchronization: Implementing real-time updates for contract analysis status (e.g., from "processing" to "analyzed") across the application using Supabase's real-time capabilities required robust error handling and state management.
  • Complex UI States: Managing the various UI states, such as loading indicators, error messages, modal visibility, and interactive elements (like the AI chat and contract editor), demanded a well-structured state management approach.
  • Security and Row-Level Security (RLS): Properly configuring Supabase RLS to ensure users could only access and modify their own data (contracts, profiles, workspaces) while allowing necessary inter-table relationships was crucial and required careful policy definition.
  • Integration of Multiple AI Models: Seamlessly switching between or combining different AI models (OpenAI and Gemini) for various tasks while maintaining a consistent user experience and managing API keys securely.
  • Position Mapping for Highlighting: Accurately mapping AI-identified clauses back to their exact positions in the original text for highlighting, especially after text extraction and potential formatting changes, proved challenging.

Accomplishments that we're proud of

We are particularly proud of several key accomplishments in CogniDraft:

  • Intuitive User Experience: Despite the complexity of the underlying AI and legal concepts, we successfully created a clean, intuitive, and user-friendly interface that makes advanced contract analysis accessible to non-legal professionals.
  • Effective AI Integration: The seamless integration of powerful AI models to provide meaningful and actionable insights into legal documents is a significant achievement. The ability to explain complex clauses in plain English and generate strategic questions is a standout feature.
  • Real-time Responsiveness: The implementation of real-time updates for contract analysis and streaming AI responses for drafting and chat significantly enhances the user experience, making the application feel dynamic and responsive.
  • Robust Workspace Customization: The workspace feature, allowing users to tailor AI analysis and drafting to their specific industry, jurisdiction, and risk preferences, provides a highly personalized and valuable experience.
  • Scalable Architecture: The choice of React, Supabase, and external AI services provides a highly scalable architecture that can handle a growing number of users and contracts without significant re-engineering.
  • Comprehensive Feature Set: From analysis and comparison to drafting and strategic questioning, CogniDraft offers a comprehensive suite of tools for contract management, all within a single platform.

What we learned

Throughout the development of CogniDraft, we gained valuable insights:

  • The Power of Prompt Engineering: We learned that the quality and specificity of AI prompts are paramount for generating accurate, relevant, and contextualized legal insights. Iterative refinement of system prompts was key to achieving desired outcomes.
  • Importance of User Context: Integrating user-defined workspace context (industry, jurisdiction, risk tolerance) into AI prompts is critical for delivering truly personalized and valuable AI assistance, especially in specialized domains like legal.
  • Supabase Capabilities: We deepened our understanding of Supabase's full-stack capabilities, particularly its powerful RLS, real-time subscriptions, and Edge Functions, which proved invaluable for building a secure and dynamic application.
  • Handling Streaming Responses: Implementing UI updates for streaming AI responses requires careful state management to ensure a smooth and non-flickering display of generated content.
  • UI/UX for Complex Data: Designing an interface that effectively presents complex legal analysis and AI-generated content in an easily digestible format is crucial for user adoption and satisfaction.
  • Error Handling and Retries: Robust error handling and retry mechanisms are essential when dealing with external APIs (AI, storage) and background processes to ensure application stability and a good user experience even when external services face transient issues.

What's next for CogniDraft

For CogniDraft, the future holds exciting possibilities:

Advanced AI Features

  • Automated Redlining: AI-powered suggestions for contract modifications directly within the editor, allowing users to accept or reject changes.
  • Contract Negotiation Simulation: An AI that can role-play as a counterparty, helping users practice negotiation strategies.
  • Multi-document Analysis: The ability to analyze relationships and inconsistencies across multiple related contracts.

Deeper Integrations

  • Integration with CRM and document management systems for seamless contract import/export.
  • API access for developers to integrate CogniDraft's capabilities into their own applications.

Enhanced Customization

  • Allowing users to define and train the AI on their own custom contract templates and clauses for even more tailored analysis and drafting.
  • More granular control over risk tolerance and compliance settings within workspaces.

Mobile Application

  • Developing native mobile applications for iOS and Android to enable on-the-go contract review and drafting.

Advanced Analytics & Reporting

  • Providing more in-depth dashboards and reports on contract trends, common risks, and negotiation outcomes across a user's contract portfolio.

Community Features

  • Enabling users to share anonymized insights or best practices within their industry or legal domain.

Built With

Share this project:

Updates