<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: mustapha Chaibi</title>
    <description>The latest articles on DEV Community by mustapha Chaibi (@musta).</description>
    <link>https://dev.to/musta</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4008695%2F74892a8d-5e39-4061-a107-e06d3651fd9e.png</url>
      <title>DEV Community: mustapha Chaibi</title>
      <link>https://dev.to/musta</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/musta"/>
    <language>en</language>
    <item>
      <title>Building ContractPilot AI: A Serverless Multi-Agent Legal Copilot with Vercel and AWS Databases ⚖️🚀</title>
      <dc:creator>mustapha Chaibi</dc:creator>
      <pubDate>Mon, 29 Jun 2026 19:56:12 +0000</pubDate>
      <link>https://dev.to/musta/building-contractpilot-ai-a-serverless-multi-agent-legal-copilot-with-vercel-and-aws-databases-41lc</link>
      <guid>https://dev.to/musta/building-contractpilot-ai-a-serverless-multi-agent-legal-copilot-with-vercel-and-aws-databases-41lc</guid>
      <description>&lt;p&gt;Legal contracts are the lifeblood of business, yet small business owners, freelancers, and startups sign agreements every week that they don't fully understand. Why? Because hiring a lawyer to review a single contract costs upwards of $300 to $500 per hour. &lt;/p&gt;

&lt;p&gt;To bridge this gap, we built &lt;strong&gt;ContractPilot AI&lt;/strong&gt;—a serverless, multi-agent contract negotiation copilot that analyzes contracts, highlights risks, proposes redlined counter-offers, and allows users to interactively chat with their documents. &lt;/p&gt;

&lt;p&gt;In this article, we'll dive into how we built this application under a weekend for the &lt;strong&gt;H0: Hack the Zero Stack&lt;/strong&gt; hackathon, utilizing &lt;strong&gt;Vercel v0&lt;/strong&gt; for rapid frontend development and &lt;strong&gt;Amazon DynamoDB&lt;/strong&gt; + &lt;strong&gt;Amazon Bedrock&lt;/strong&gt; for a highly scalable, serverless backend.&lt;/p&gt;




&lt;h2&gt;
  
  
  The System Architecture
&lt;/h2&gt;

&lt;p&gt;When designing ContractPilot AI, our primary goal was &lt;strong&gt;operational simplicity and cost-efficiency&lt;/strong&gt;. We wanted a "Zero Stack" implementation—meaning zero fixed server costs when the app is idle, combined with the capability to scale instantly to handle heavy burst traffic.&lt;/p&gt;

&lt;p&gt;Here is how the components connect:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[User Browser]
      │
      ▼ (HTTPS / REST API)
[Vercel / Next.js Frontend]  ←───  Built &amp;amp; Iterated with v0.app
      │
      ▼ (HTTPS Proxy)
[AWS API Gateway HTTP API]
      │
      ▼ (Serverless Invocation)
[AWS Lambda — ASP.NET Core API]
      │
      ├──► [Amazon S3] — Stores uploaded PDF/DOCX files
      │
      ├──► [Multi-Agent Orchestrator] ──► [Amazon Bedrock] (Nova Lite)
      │
      └──► [Amazon DynamoDB] (Single-Table / Serverless Scaling)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  🎨 The Frontend: Vercel v0 + Next.js
&lt;/h2&gt;

&lt;p&gt;Building data-dense dashboards and chat interfaces from scratch can take days of layout and design iterations. To solve this, we used &lt;strong&gt;Vercel v0&lt;/strong&gt;. &lt;/p&gt;

&lt;p&gt;By describing our dashboard requirements in plain English, v0 scaffolded a modern, premium user interface including:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A clean drag-and-drop file upload zone.&lt;/li&gt;
&lt;li&gt;A visual 0-100 risk score gauge.&lt;/li&gt;
&lt;li&gt;An interactive clause risk explorer with accordion panels.&lt;/li&gt;
&lt;li&gt;A clean, responsive chat panel to interact with the contract.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;We exported these components into a Next.js 14 project and deployed them to Vercel with zero configuration.&lt;/p&gt;




&lt;h2&gt;
  
  
  ⚙️ The Backend: ASP.NET Core on AWS Lambda
&lt;/h2&gt;

&lt;p&gt;Our REST API and agent orchestration layer are built using &lt;strong&gt;ASP.NET Core (.NET 9)&lt;/strong&gt;. To keep it serverless, we compiled the API as a self-contained runtime (&lt;code&gt;provided.al2023&lt;/code&gt;) and deployed it directly to &lt;strong&gt;AWS Lambda&lt;/strong&gt; behind &lt;strong&gt;AWS API Gateway&lt;/strong&gt;. &lt;/p&gt;

&lt;p&gt;This serverless execution model means we only pay for compute when a user uploads a contract, keeping idle costs at exactly $0.&lt;/p&gt;




&lt;h2&gt;
  
  
  🗄️ Database: Amazon DynamoDB
&lt;/h2&gt;

&lt;p&gt;We chose &lt;strong&gt;Amazon DynamoDB&lt;/strong&gt; as our primary database because its fully serverless, pay-per-use scaling model aligns perfectly with bursty AI workloads. &lt;/p&gt;

&lt;h3&gt;
  
  
  Data Model &amp;amp; Tables:
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;contractpilot_contracts&lt;/code&gt;&lt;/strong&gt;: Stores document metadata, overall risk score, summary, and lists of highlighted clauses.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;contractpilot_chat_messages&lt;/code&gt;&lt;/strong&gt;: Maintains the history of interactive user messages per contract session.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;contractpilot_agent_logs&lt;/code&gt;&lt;/strong&gt;: Logs performance and token statistics for each analysis run.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Using the official &lt;strong&gt;AWSSDK.DynamoDBv2&lt;/strong&gt; library, the .NET backend fetches and stores data with sub-10ms query latencies.&lt;/p&gt;




&lt;h2&gt;
  
  
  🧠 AI Layer: Multi-Agent Amazon Bedrock (Nova Lite)
&lt;/h2&gt;

&lt;p&gt;ContractPilot AI uses &lt;strong&gt;Amazon Bedrock&lt;/strong&gt; with the &lt;strong&gt;Amazon Nova Lite&lt;/strong&gt; foundation model (&lt;code&gt;amazon.nova-lite-v1:0&lt;/code&gt;) to run five specialized legal agents concurrently:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Legal Analyst&lt;/strong&gt;: Flags problematic clauses and legal terms.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Risk Assessor&lt;/strong&gt;: Computes risk levels and scores.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Compliance Checker&lt;/strong&gt;: Verifies alignment with regulations like GDPR.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Negotiation Strategist&lt;/strong&gt;: Generates redlined counter-proposals with alternative wordings.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Summary Agent&lt;/strong&gt;: Writes a 5-minute executive summary.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  API Optimization:
&lt;/h3&gt;

&lt;p&gt;To minimize cost and latency, our backend consolidates these agent calls into a single structured schema prompt. The model returns typed JSON that matches our backend C# records perfectly, reducing inference time and cost by 4x.&lt;/p&gt;




&lt;h2&gt;
  
  
  💡 What We Learned
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Serverless AI is highly cost-effective&lt;/strong&gt;: Running the Bedrock Nova Lite model costs less than $0.01 per contract analysis. Paired with DynamoDB and Lambda, our fixed monthly infrastructure cost is exactly $0.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;v0.app changes the UI workflow&lt;/strong&gt;: Scaffolding UI in natural language allows developers to spend 90% of their time on backend orchestration and database patterns rather than styling CSS.&lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  🎁 Hackathon Disclaimer
&lt;/h2&gt;

&lt;p&gt;I created this piece of content for the purposes of entering the H0: Hack the Zero Stack hackathon. #H0Hackathon&lt;/p&gt;

</description>
      <category>aws</category>
      <category>vercel</category>
      <category>serverless</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
