🏛️ CivicSync — Hackathon Submission

Democratizing access to complex legislation through open-source RAG, multi-agent deliberation, and zero-hallucination verification powered by Google Gemini and Elasticsearch, deployed on Hugging Face Spaces.


🌟 Inspiration

Legislation is complex, opaque, and difficult for the average citizen to navigate.

[!NOTE]
The Problem: The language of law is a barrier to justice and civic participation. Dense legal jargon alienates the public from understanding the very laws that govern their daily lives.

Our motivation was simple: bridge the gap between legalese and public comprehension. We built CivicSync as an open-source civic tech ecosystem designed to democratize access to statutory information and empower individuals with direct, understandable legal transparency.


🛡️ What it does

CivicSync is a transparent legislative analysis dashboard designed to parse, search, and simplify statutory legislation globally.

  • Translating Legalese: It processes dense legal drafts and statutory bills (such as the DPDP Act 2023 or Bharatiya Nyaya Sanhita used in our initial case studies) into plain, citizen-friendly language.
  • Persona-Oriented Impacts: Tailors summaries and impact assessments to specific citizen profiles (e.g., students, small business owners, local laborers) using Gemini 3.1 Flash.
  • Fact-Checking & Verification: Employs Gemini 3.1 Flash as an automated, fast-policing judge to compare generated summaries against the source text to ensure all citations and claims are 100% grounded.
  • Scalable Knowledge Search: Integrates a high-performance Elasticsearch engine to index, query, and search massive legal databases and precedent corpora (such as Indian Kanoon reference data) with sub-millisecond retrieval speeds.

⚙️ How we built it

We designed the codebase from the ground up for transparency, community collaboration, and production reliability:

flowchart TD
    subgraph "GitHub Repository"
        code["Source Code & Configs"]
    end

    subgraph "App Deployment: Hugging Face Spaces"
        fastapi["FastAPI Backend"]
        vite["Vite React SPA Frontend"]
        docker["Dockerized Environment"]
    end

    subgraph "Database & Retrieval"
        es["Elasticsearch Instance"]
        mcp["Elastic MCP Server"]
    end

    subgraph "AI Engine & Models"
        gemini["Google Gemini 3.1 Flash"]
    end

    code --> docker
    docker --> fastapi
    docker --> vite

    vite --> fastapi
    fastapi --> mcp
    mcp --> es
    fastapi --> gemini
  • Open Source: Hosted transparently on GitHub to invite peer review and collaborative enhancement.
  • Hosting Environment: Deployed directly on Hugging Face Spaces as a Docker space containing both the FastAPI backend and built Vite React SPA frontend.
  • Elasticsearch & MCP: Leveraged an Elasticsearch instance connected via the Elastic MCP Server to run optimized lexical DSL queries and hybrid vector search scoring over hundreds of thousands of legal sections and precedents.
  • Gemini-Powered Agents: Orchestrated multi-perspective analysis agents powered by Google Gemini 3.1 Flash for deliberation and courtroom simulation.

📂 Repository Structure

.
├── app/                 # FastAPI Backend (Gemini engine, MCP client, courtroom logic)
├── bills/               # Built-in legislation documents and reference bills (PDF & TXT formats)
├── civicsync-ui/        # Primary React + Vite + TS Frontend Dashboard (with Live Courtroom Simulator)
├── data/                # Regional/state bills datasets & local courtroom session transcripts
├── docs/                # Architecture design, PRD, and hackathon playbooks
├── frontend/            # Optional Streamlit demo user interface
├── public/              # Global static icons and assets
├── scripts/             # Setup and pre-caching helper scripts
├── tests/               # Backend validation test suites
├── CivicSync-v2-main/   # Legacy v2 codebase repository copy
├── CivicSync_v3/        # Git submodule pointer for V3 courtroom engine
├── Dockerfile           # Deployment container config for Hugging Face Spaces
├── render.yaml          # Render Blueprint deployment config
├── requirements.txt      # Python backend package dependencies
└── README.md            # Project documentation and developer instructions

⚠️ Challenges we ran into

[!WARNING]
Building robust legal tech requires navigating complex architectural transitions under tight timelines.

  • Search Migration: Transitioning the RAG pipeline from custom hybrid search algorithms to a production-grade Elasticsearch index while maintaining sub-second query performance and seamless index updates.
  • Deployment & Networking: Configuring the multi-stage Dockerfile inside Hugging Face Spaces to successfully compile the React/Vite client-side assets and serve them alongside the FastAPI backend on port 7860.
  • Marketing & Video Production: Translating a highly serious, technical legal application into an engaging, high-impact walk-through video under strict time constraints.

🏆 Accomplishments that we're proud of

  • True Civic Impact: Successfully launching an open-source tool that makes law understandable for everyday people.
  • Hugging Face Spaces & Elasticsearch Integration: Establishing a resilient, hybrid hosting architecture spanning Hugging Face Spaces, Elasticsearch, and the Google Gemini API.
  • Effective Advocacy: Creating compelling video and promotional content proving that technical civic tech can be marketed dynamically to a mainstream audience.

💡 What we learned

[!TIP]
User Experience (UX) is a core accessibility requirement when dealing with rigid, dense legal text.

  • Cloud Orchestration: Gained deep experience in managing cross-platform cloud deployments, environment syncing, and container pipelines inside Hugging Face Spaces.
  • Search Engine Optimization: Deepened our understanding of configuring index mappings, analyzers, and query parameters in Elasticsearch to retrieve highly context-relevant legal documents.
  • Social & Civic Engagement: Learned how to craft high-engagement social campaigns to drive public awareness and bring critical civic tech directly to the community.

🔮 What's next for CivicSync

  • Database Expansion: Incorporate pending bills, local municipal bylaws, and wider fields of global legal jurisprudence.
  • Elasticsearch Scaling: Implement advanced semantic vectors directly inside our Elasticsearch cluster to enable dense-sparse hybrid search directly at the database layer.
  • Multi-Lingual & Global Localization: Expand the interface support to multiple global and regional languages, adapting the parser schemas to serve the legislative frameworks of different democratic nations seamlessly.

Built With

Share this project:

Updates