s

## Inspiration

Indian enterprises and MSMEs face immense regulatory complexity. Every year, statutory bodies like the RBI, GST Council, SEBI, and Income Tax Department issue thousands of circulars and policy updates. Manually scanning thousands of existing vendor contracts, employment agreements, and billing frameworks to identify legal non-compliance is slow, expensive, and error-prone.

Existing solutions rely on reactive keyword searches or disconnected vector databases that lack transactional consistency. We built **Chanakya** as an autonomous, self-healing **Regulatory & Corporate Policy Memory Engine**. Chanakya continuously remembers your enterprise's legal state, instantly maps unstructured regulatory circulars to stored contract clauses, auto-drafts compliance amendments, and maintains a strict ACID audit trail.

---

## What It Does

Chanakya serves as an intelligent compliance command center:

* **Multi-Format Regulatory Ingestion:** Upload PDF circulars, raw text updates, or choose 1-click sample circulars (e.g., *RBI Digital Lending Guidelines*, *GST Rate Revision*).
* **Distributed Vector Clause Matching:** Converts circulars into 768-dimensional embeddings using Gemini `text-embedding-004` and queries CockroachDB to highlight conflicting contract clauses using cosine similarity.
* **AI Legal Amendment Studio:** Uses Gemini 1.5 Pro via Google AI Studio to analyze legal conflicts and generate side-by-side legal diff drafts.
* **Immutable ACID Audit Memory:** One-click approval commits amendments directly to CockroachDB with complete serializable transaction integrity.
* **Interactive Rollback Simulator:** Demonstrates CockroachDB's transactional safety by enabling 1-click rollbacks of approved amendments without data corruption.
* **Contextual Help & AI Agent Terminal:** Features prominent `(i)` help popups explaining system mechanics, alongside an embedded, state-aware Gemini chat assistant.

---

## How We Built It

We designed Chanakya as a production-grade, full-stack application built around persistent agentic memory:

1. **Database & Memory Layer (CockroachDB):**
   * **Distributed Vector Indexing:** Stored 768-dimension embeddings directly in CockroachDB using HNSW indexes for high-speed cosine similarity search ($\text{similarity} = 1 - \text{cosine\_distance}$).
   * **ACID Audit State:** Used CockroachDB's distributed SQL consensus to guarantee strict serializability for all compliance audit logs and rollback operations.
   * **CockroachDB Cloud Managed MCP Server:** Integrated the MCP endpoint (`https://cockroachlabs.cloud/mcp`) for secure, read-only agent database introspection.

2. **AI & Reasoning Layer (Google AI Studio):**
   * Connected Gemini 1.5 Pro for policy reasoning, legal diff generation, and real-time interactive compliance chat.
   * Used `text-embedding-004` to vectorize unstructured legal prose.

3. **Frontend & Deployment (Netlify & AWS Architecture):**
   * Built a React 18 / TypeScript single-page application styled with a custom dark-slate cyber theme using Tailwind CSS.
   * Deployed to **Netlify** with strict HTTP security headers (`Content-Security-Policy`, `X-Frame-Options`) and single-page app redirects (`netlify.toml`).
   * Structured serverless ingestion functions as **AWS Lambda** endpoints with Amazon S3 storage for document management.

---

## Challenges We Faced

* **Vector Consistency vs. Operational Data:** Standard AI architectures force developers to sync separate vector databases (like Pinecone) with relational SQL stores. Using CockroachDB solved this consistency gap by housing operational transactional data and vector search under one ACID umbrella.
* **Tailwind v4 Build Integration:** Resolving PostCSS/Vite compilation pipeline rules required configuring unified CSS import directives for production deployment on Netlify.
* **Zero-Jargon Transparency:** Making advanced distributed database concepts clear to non-technical judges. We solved this by creating a centered, interactive `(i)` modal system explaining the exact CockroachDB and Gemini mechanisms running behind every button.

---

## What We Learned

* How CockroachDB's distributed vector indexing eliminates consistency gaps between unstructured vector embeddings and ACID transactional records.
* Leveraging Model Context Protocol (MCP) servers to allow AI agents to safely read database states without expose risk.
* Structuring full SDLC documentation suites (`/docs/`) simultaneously with zero-warning React codebase generation.

---

## What's Next for Chanakya

* **Automated Regulatory Scraper:** Expanding real-time scrapers for the official Gazette of India and GST portal feeds.
* **Multi-Tenant Enterprise Isolation:** Utilizing CockroachDB multi-region capabilities to guarantee localized data sovereignty for international enterprise branches.
* **Smart Contract Execution:** Triggering automated on-chain legal updates upon audit log commit.

Built With

Share this project:

Updates