AI-Powered Bill Sentiment Analysis

AI-powered dashboard for analyzing public sentiment on draft legislations using NLP, RAG, and Milvus.

Next.js FastAPI NLP License
Stars Repo Size Forks

BillsSentiments is an advanced AI-driven analytical dashboard built to tackle the challenge of manually analyzing thousands of public stakeholder comments on draft legislations.

GitHub: 0xarchit/BillsSentiments

Overview

By leveraging Natural Language Processing (NLP), Large Language Models (LLMs), and Retrieval-Augmented Generation (RAG), this platform automates:

  • Sentiment Analysis: Classifying feedback as Positive, Neutral, or Negative.
  • Contextual Summarization: Generating concise summaries of lengthy legal texts.
  • Semantic Search: Enabling "Chat to Document" functionality via Vector search.
  • Visual Analytics: Providing word clouds and statistical breakdowns for policy makers.

Input Data Example

The system analyzes complex legislative texts and diverse public comments.

Sample Act
Sample Act

System Architecture

The system is built on a Microservices-inspired architecture, containerized with Docker for easy deployment. It features a FastAPI backend for heavy ML lifting and a sleek Next.js frontend for an immersive user experience.

System Diagram
System Diagram

Core Workflow

  1. Ingestion: Comments are uploaded (CSV) or fetched via API.
  2. Processing:
    • Sentiment Engine: BERT-based model predicts sentiment scores.
    • Vectorization: Embeddings are generated and stored in Milvus (Zilliz) for RAG.
    • Vector Storage: The Milvus vector database efficiently indexes these embeddings for rapid similarity search. Milvus DB
  3. Analysis: Gemini 2.5 Flash (via LangChain) generates summaries and answers RAG queries.
  4. Presentation: Results are displayed on a real-time Interactive Dashboard.
RAG Workflow
RAG Workflow

Key Features

1. Interactive Dashboard

A modern, responsive UI showing real-time statistics, sentiment distribution, and recent activities.

Landing Page
Landing Page

2. RAG-Powered Chatbot

Ask questions about specific legislative acts. The bot retrieves context from the official document PDFs and stakeholder comments to provide evidence-backed answers.

Chatbot
Chatbot

3. Automated Insight Generation

View overall sentiment trends and word clouds highlighting key topics of discussion for each act.

Acts Overview
Acts Overview

4. Detailed Comment Analysis

Drill down into individual comments with granular sentiment scoring and metadata.

Comment Drilldown
Comment Drilldown

5. Secure Authentication

Robust user management and authentication system powered by Supabase.

Account Verification
Account Verification

6. Admin & System Health

Role-based access control (RBAC). Admins can manage acts, trigger model updates, and monitor the health of all system components.

Admin Panel
Admin Panel

System Health Monitoring:

Health Tab
Health Tab

Tech Stack

Tech Stack
Tech Stack
Layer Technologies
Frontend Next.js 15 (React), TailwindCSS, ShadCN UI, Recharts, Framer Motion
Backend Python FastAPI, LangChain, PyTorch (Sentiment Model)
Database PostgreSQL (Structured), Milvus/Zilliz (Vector), Supabase (Auth & DB)
AI/ML OpenAI/Gemini APIs, Sentence-Transformers (Embeddings)
DevOps Docker, Docker Compose, GitHub Actions

API & Database

The backend exposes a comprehensive REST API documented via Swagger UI.

FastAPI Swagger
FastAPI Swagger

Database Schema

A robust relational schema handles Users, Acts, Comments, and Authentication states.

DB Schema
DB Schema

Getting Started

Deploy the entire stack (Frontend + Backend) with a single command. The backend is isolated internally, exposing only the frontend.

Access the app at http://localhost:3000.

Option B: Manual Setup

Backend

# Setup Python Environment
python -m venv venv
.\venv\Scripts\activate
pip install -r requirements.txt

# Run Server
uvicorn app:app --reload --port 8000

Frontend

cd Frontend
npm install
npm run dev
# App runs at http://localhost:3000

Testing & Performance

We maintain rigorous testing standards including unit tests for API endpoints and consistency checks for the ML models.

Metric Status
Sentiment Accuracy 92% (F1 Score)
API Latency < 200ms (Average)
RAG Retrieval Top-5 Context Precision

Model Evaluation

Model Evaluation
Model Evaluation

Test Coverage

Test Coverage
Test Coverage