0% found this document useful (0 votes)
15 views30 pages

Final MajorProject Report

The project report details the development of an AI-Powered Legal Assistance and Court Study System aimed at enhancing legal education and access to legal information in India. It includes features such as court trial simulations, an AI legal chat companion, and a voice assistant, all integrated with advanced technologies for document processing and user interaction. The report outlines the project's objectives, methodologies, and the technologies employed, demonstrating how AI can transform the legal landscape.

Uploaded by

Preetesh Singha
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views30 pages

Final MajorProject Report

The project report details the development of an AI-Powered Legal Assistance and Court Study System aimed at enhancing legal education and access to legal information in India. It includes features such as court trial simulations, an AI legal chat companion, and a voice assistant, all integrated with advanced technologies for document processing and user interaction. The report outlines the project's objectives, methodologies, and the technologies employed, demonstrating how AI can transform the legal landscape.

Uploaded by

Preetesh Singha
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

A PROJECT REPORT

AI-Powered Legal Assistance and


Court Study System
A Comprehensive AI-Based Platform for Interactive Legal Learning, Court Case
Simulation, Legal Consultation, and Voice-Based AI Assistance

Submitted to

KIIT Deemed to be University

In Partial Fulfillment of the Requirements for the Award of


Bachelor of Technology in Computer Science and Engineering

BY
Srijan Kundu Roll No: 22051202
Preetesh Kumar Singha Roll No: 22052653
Rajat Kumar Panda Roll No: 22052923
Sk Sadat Hossen Roll No: 22052679
Swapnil Goswami Roll No: 22052076
Rohan Chattopadhyay Roll No: 22051604

Under the Guidance of


Mr. Rakesh Rai

School of Computer Engineering


Kalinga Institute of Industrial Technology
Bhubaneswar, Odisha – 751024

November 2025
CERTIFICATE
This certifies that the project report entitled ”AI-Powered Legal Assistance and Court Study
System”, submitted by students of the 2022–2026 Batch (Srijan Kundu - 22051202, Preetesh
Kumar Singha - 22052653, Rajat Kumar Panda - 22052923, Sk Sadat Hossen - 22052679, Swapnil
Goswami - 22052076, Rohan Chattopadhyay - 22051604), represents bona fide work carried out
under my supervision in partial fulfillment of requirements for the Bachelor of Technology degree
in Computer Science and Engineering at the School of Computer Engineering, KIIT Deemed to
be University.

Mr. Rakesh Rai


Project Guide
School of Computer Engineering
KIIT Deemed to be University

Date of Evaluation:

Examiner’s Name:
Signature:

1
ACKNOWLEDGEMENT
We express sincere gratitude to our project guide, Mr. Rakesh Rai, whose expert mentorship
and consistent guidance proved invaluable in completing this research. His insights in artificial
intelligence, multimodal systems, and legal informatics inspired innovative approaches throughout
the development process.
We thank Prof. Biswajit Sahoo, Dean, School of Computer Engineering, KIIT, for providing
the necessary academic infrastructure and institutional support. Our appreciation extends to all
faculty members whose teachings enabled practical application of computer science fundamentals
in this legal AI system.
We acknowledge classmates and early testers who provided valuable feedback, significantly
enhancing system functionality and robustness. Finally, we thank our families for their unwavering
support, motivation, and patience throughout this project’s development.

Srijan Kundu, Preetesh Kumar Singha,


Rajat Kumar Panda, Sk Sadat Hossen,
Swapnil Goswami, Rohan Chattopadhyay

2
ABSTRACT
The Indian legal system’s complexity creates significant barriers for citizens and students seeking to
understand judicial reasoning, interpret case laws, and access structured legal information. Modern
advancements in large language models (LLMs) offer transformative opportunities to democratize
legal knowledge through accessible, interactive platforms.
This project presents an AI-Powered Legal Assistance and Court Study System,
integrating legal verdict simulation, AI-driven conversations, voice-based multimodal guidance,
document analysis, and contextual referencing via the IndianKanoon API. The system comprises
three core components: (1) Court Trial Simulation Module using Google Gemini 2.5 Flash for
generating structured AI verdicts including argument summaries, factual findings, and final orders;
(2) Nyay Mitra – AI Legal Chat Companion, an intelligent conversational agent providing
legal query assistance, procedural clarifications, and awareness using statutory references; and
(3) AI Voice Assistant Module, a multimodal voice-driven system powered by Groq LLMs
(Llama-3, Gemma) supporting voice input, document uploads, and real-time legal insights with
transcript generation.
The platform implements secure authentication using scrypt, an administrative dashboard for
monitoring user activity, and comprehensive document processing pipelines utilizing pdfplumber,
PyPDF2, PyTesseract, FAISS vector search, sentence-transformers, and SpeechRecognition. This
research demonstrates how artificial intelligence can revolutionize legal education, improve citizen
access to legal knowledge, support exam preparation, facilitate legal research, and contribute to
India’s digital justice ecosystem.

3
Contents

List of Figures 6

List of Tables 6

1 Introduction 7
1.1 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
1.2 Background and Motivation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
1.3 Problem Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
1.4 Objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
1.5 Scope and Significance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
1.6 Report Organization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8

2 Literature Review 9
2.1 Digital Legal Systems Evolution . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
2.2 AI in Legal Research and Reasoning . . . . . . . . . . . . . . . . . . . . . . . . . . 9
2.3 Natural Language Processing for Legal Documents . . . . . . . . . . . . . . . . . . 9
2.4 Multimodal AI and Document Comprehension . . . . . . . . . . . . . . . . . . . . 9
2.5 Speech-Based Legal Assistance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
2.6 OCR for Legal Document Digitization . . . . . . . . . . . . . . . . . . . . . . . . . 10
2.7 Legal Search Engines and APIs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
2.8 Gap Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10

3 Technologies Used 11
3.1 Web Development Technologies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
3.2 AI and NLP Technologies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
3.3 Document Processing and OCR Technologies . . . . . . . . . . . . . . . . . . . . . 11
3.4 Voice and Speech Technologies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
3.5 Embedding, Indexing, and Semantic Search . . . . . . . . . . . . . . . . . . . . . . 11
3.6 Security and Authentication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
3.7 Front-End Technologies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12

4 System Architecture 13
4.1 High-Level Architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
4.2 System Workflow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
4.3 Backend Architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
4.4 AI Model Architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
4.5 Document Processing Pipeline . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
4.6 Storage and Retrieval Architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
4.7 Security Architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14

4
5 Implementation 16
5.1 User Authentication System . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
5.2 Court Trial Simulation Module . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
5.3 Nyay Mitra Chatbot Implementation . . . . . . . . . . . . . . . . . . . . . . . . . . 16
5.4 Voice Assistant Implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
5.5 Document Upload and OCR Pipeline . . . . . . . . . . . . . . . . . . . . . . . . . . 16
5.6 Admin Portal Implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17

6 Testing, Results and Discussion 18


6.1 Testing Methodology . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
6.2 Test Cases . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
6.3 OCR Testing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
6.4 Voice Assistant Testing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
6.5 Performance Metrics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
6.6 User Feedback Evaluation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
6.7 Discussion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19

7 Screenshots 20

8 Conclusion and Future Scope 24


8.1 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
8.2 Future Scope . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
8.2.1 Technical Enhancements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
8.2.2 Functional Enhancements . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
8.2.3 Domain Expansion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
8.2.4 Accessibility Enhancements . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
8.2.5 Advanced Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
8.2.6 Research Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25

References 26

Appendix A: System Installation Guide 27

Appendix B: API Configuration 28

Appendix C: Sample Code Snippets 29

5
List of Figures

4.1 System Architecture Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14


4.2 System Workflow Diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15

7.1 User Login Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20


7.2 System Home Dashboard . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
7.3 Court Trial Simulation Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
7.4 AI-Generated Verdict Output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
7.5 Nyay Mitra Legal Chatbot Interface . . . . . . . . . . . . . . . . . . . . . . . . . . 22
7.6 AI Voice Assistant Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
7.7 Administrative Monitoring Dashboard . . . . . . . . . . . . . . . . . . . . . . . . . 23
7.8 Document Processing Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23

List of Tables

2.1 Comparative Analysis of Legal-Tech Solutions . . . . . . . . . . . . . . . . . . . . . 10

6.1 Comprehensive Test Cases . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18


6.2 System Performance Metrics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18

6
1 Introduction
1.1 Overview
The Indian legal system, comprising criminal, civil, constitutional, property, administrative,
corporate, and family law branches, represents one of the world’s most comprehensive judicial
frameworks. Despite this structural richness, legal information accessibility remains severely
limited for substantial population segments. Complex judicial language, lengthy case files, and
resource-intensive legal research create significant barriers for ordinary citizens. Concurrently,
artificial intelligence—particularly multimodal systems and natural language processing—has
witnessed remarkable advancement. Models including Google Gemini, Meta LLaMA, and Gemma
now process text, images, audio, PDFs, and structured information simultaneously, enabling
transformative applications in legal education and public awareness.
The AI-Powered Legal Assistance and Court Study System addresses this critical
gap by providing structured legal insights, AI-driven case verdict simulations, interactive legal
conversations, and voice-based multimodal guidance. This system bridges the divide between
complex legal knowledge and public accessibility through innovative technological integration.

1.2 Background and Motivation


The Indian judiciary historically depends on manually-driven processes including written submis-
sions, oral advocacy, and extensive document-based evidence. Legal professionals rely heavily on
case precedents, statutory references, procedural rules, and judicial doctrines. However, several
factors complicate public legal access: (1) complex, archaic, and technical legal terminology; (2)
millions of judicial decision pages produced annually; (3) absence of user-friendly learning platforms
offering explanatory frameworks; (4) limited availability of qualified legal professionals relative
to population; and (5) approximately 50 million pending cases in Indian courts necessitating
automated research tools.
Artificial intelligence integration offers solutions through contextual analysis, automated sum-
marization, interactive conversational guidance, multimodal document understanding, predictive
reasoning, and voice-enabled support systems. This project harnesses these capabilities in a unified
platform aimed at legal awareness, research, and assisted learning, motivated by: increasing legal
awareness of rights, duties, procedures, and remedies; supporting law students in case briefs,
legal research, moot court preparations, and exam preparation; leveraging rapid AI advancement
in multimodal interpretation; bridging the digital divide for marginalized groups, non-English
speakers, visually impaired users, and rural populations; and advancing innovative research
combining AI verdict simulation, legal databases, multimodal analysis, and voice interaction.

1.3 Problem Statement


This project addresses six critical issues: (1) Legal Language Complexity: dense legal termi-
nology and reasoning impede non-expert comprehension; (2) Lack of Structured Summaries:
citizens cannot interpret lengthy judgments or extract essential facts, arguments, and rulings;
(3) Inaccessible Legal Consultation: professional consultation expense necessitates affordable
preliminary insights; (4) Absence of Trial Simulation Tools: no platforms accept statements,
case categories, and documents to generate structured simulated judgments; (5) No Voice-Based
Legal AI: text-heavy systems disadvantage voice-preferring, visually impaired, and limited-literacy
users; and (6) Fragmented Legal Tools: existing solutions offer raw data (IndianKanoon, Judis),
general-purpose AI chatbots, or separate OCR systems without integrated functionality.

7
1.4 Objectives
Primary Objectives: (1) Create an AI-powered platform for learning court case structures; (2)
Generate simulated judgments using advanced LLMs; (3) Provide conversational legal guidance
using real case law data; (4) Offer voice-based multimodal legal interaction.
Secondary Objectives: Improve legal literacy; assist visually impaired or illiterate users
through voice; simplify legal document interpretation; help students prepare for exams and moot
courts.

1.5 Scope and Significance


Scope: Responsive Flask web application; court trial simulator generating structured AI verdicts;
legal conversational chatbot (”Nyay Mitra”); voice-enabled multimodal assistant; PDF, image, and
document analysis; secure scrypt authentication; admin panel with analytics; IndianKanoon API
integration; FAISS and sentence-transformers for semantic searches.
Out of Scope: Real-world litigation advice; replacement of lawyers or judicial authorities.
Significance: Promotes digital legal literacy; eases learning curves for law students; assists
researchers in studying judicial patterns; supports persons with disabilities through voice
interaction; demonstrates practical AI-law integration.

1.6 Report Organization


This report comprises eight chapters: (1) Introduction; (2) Literature Review; (3) Technologies
Used; (4) System Architecture; (5) Implementation; (6) Testing, Results, and Discussion; (7)
Screenshots; (8) Conclusion and Future Scope.

8
2 Literature Review
2.1 Digital Legal Systems Evolution
Digital legal systems emerged in the 1960s with database indexing, expanding to include document
retrieval, online case libraries, electronic filing (e-courts), automated docket management, digital
signature validation, and machine-readable databases. Global platforms—LexisNexis, Westlaw,
CourtListener, BAILII, CanLII, Harvard CaseLaw Access Project—pioneered online case law
access. In India, digital legal access grew through India Code Portal (Central legislations), Judis
(Supreme Court/High Court judgments), IndianKanoon (legal search engine), e-Courts Mission
Mode Project (court process digitization), and National Judicial Data Grid (NJDG) for pendency
statistics. However, these platforms provide raw legal text lacking simplified explanations,
conversational assistance, structured analysis, multimodal capability, and voice interaction.

2.2 AI in Legal Research and Reasoning


AI legal domain research focuses on: (1) Case Outcome Prediction: Aletras et al. (2016)
achieved 79% accuracy predicting European Court of Human Rights decisions using NLP; Katz et
al. (2017) attained approximately 70% accuracy for U.S. Supreme Court predictions using machine
learning, demonstrating AI’s capability for analyzing large-scale legal patterns. (2) Argument
Extraction: Modern models identify claims, supporting evidence, legal issues, contradictions,
and reasoning flow, with argument mining significantly advanced through transformer-based
architectures. (3) AI Legal Assistance: Prior tools include DoNotPay (UK/US automated
appeals), Legal Robot (contract analysis), and Ross Intelligence (legal research), though none
address Indian frameworks or support multimodal interaction.
Limitations: Earlier systems lacked long-context processing, multimodal reasoning, document
extraction capabilities, Indian legal database access, and voice-based interaction. LLM emergence
(Gemini, Llama-3, GPT-4) overcomes many limitations.

2.3 Natural Language Processing for Legal Documents


Legal NLP evolution progressed from earlier models (Naı̈ve Bayes, LDA topic modeling,
TF-IDF retrieval, early BERT) to recent models (Legal-BERT, CaseLaw-BERT, Longformer,
RoBERTa, GPT-based LLMs). Legal NLP must handle long sentencing structures, multi-clause
statements, extensive reasoning paragraphs, legal citations, and statutory interpretation. Modern
transformer-based architectures enable judgment summarization, case precedent comparison,
statutory interpretation, legal fact extraction, and human-like reasoning generation. Google
Gemini 2.5 Flash’s long-context reasoning capability proves ideal for case simulation.

2.4 Multimodal AI and Document Comprehension


Modern multimodal AI systems (Google Gemini Vision+Text, GPT-4o/4.1, LLaMA-Vision,
PaLM-E) process text documents, PDFs, scanned judgments, tables, images, handwritten notes,
and diagrams. Indian court files typically contain handwritten witness statements, printed
submissions, typewritten pages, stamped documents, and evidence photos. Multimodal AI enables
holistic interpretation of these diverse document types, providing comprehensive understanding
necessary for legal analysis.

2.5 Speech-Based Legal Assistance


Existing voice assistants (Google Assistant, Siri, Amazon Alexa, Cortana) cannot interpret
legal documents, provide statutory analysis, offer structured legal reasoning, or simulate legal

9
conversations. Voice AI potential includes reading case files aloud, helping visually impaired
persons, enabling hands-free legal learning, and answering procedural queries. This project’s
Groq LLMs integration supports voice input (SpeechRecognition), voice output (gTTS), legal
multimodal Q&A, and conversation transcripts.

2.6 OCR for Legal Document Digitization


OCR technologies (PyTesseract open-source engine, pdfplumber structured PDF extraction,
Adobe OCR commercial system, EasyOCR neural network-based) face challenges including
mixed-language text, handwritten annotations, stamps and seals, poor quality scans, multi-column
layout, and watermarked pages. This project integrates PyTesseract for fast OCR, pdfplumber for
structured PDF parsing, and LLM-based fallback for ambiguous text.

2.7 Legal Search Engines and APIs


IndianKanoon API provides case judgments, statutory extracts, metadata, and keyword/citation
searches, covering Supreme Court and all High Courts with structured JSON output and
programmatic accessibility. Global legal research tools (LexisNexis, Westlaw, BAILII, CanLII,
AustLII, CourtListener) lack Indian law focus, AI-generated judgments, voice-based interaction,
and multimodal support.

2.8 Gap Analysis


Literature review identifies critical gaps: absence of AI-based Indian legal assistants; lack of trial
simulation tools for legal education; no multimodal legal conversational platforms; absence of
voice-enabled legal AI for visually impaired or low-literacy users; and fragmented solutions failing
to combine OCR, AI reasoning, chatbot functionality, and case referencing. These gaps underscore
the proposed system’s novelty and importance.

System Features Limitations


IndianKanoon Case search, judgments No AI summaries, voice, or verdict
simulation
LexisNexis Advanced analytics Paid, not India-focused
DoNotPay Automated appeals Not suitable for Indian legal system
ChatGPT/Gemini General AI chat No legal grounding, no Indian case law
Proposed System AI verdicts, voice, multi- Educational use only
modal, Indian law

Table 2.1: Comparative Analysis of Legal-Tech Solutions

10
3 Technologies Used
This chapter presents comprehensive technology integration spanning web development, machine
learning, document processing, natural language processing, multimodal AI, and audio systems.

3.1 Web Development Technologies


Flask Web Framework: Lightweight Python framework building the entire backend, offering
minimal setup, Python library integration (AI models, OCR), built-in routing and server handling,
Jinja2 template rendering, REST API and JSON response support. Flask’s modular nature
configures login/registration endpoints, trial simulation requests, chatbot interactions, voice
assistant requests, and admin portal routes.
Streamlit: Generates interactive dashboards for admin sections, enabling user activity
log visualization, feedback entry review, case category frequency checking, and server traffic
monitoring. Streamlit seamlessly integrates with Python scripts, optimizing admin analytics.

3.2 AI and NLP Technologies


Google Gemini 2.5 Flash API: High-performance multimodal AI model for legal document
summarization, argument extraction, verdict generation, structured legal reasoning, uploaded
PDF/image processing, plaintiff/defendant statement analysis, and educational trial simulation
generation. Selection rationale includes long-context handling, powerful multimodal understand-
ing, faster response latency, accurate reasoning, and stable API.
Groq API with Llama/Gemma Models: Voice assistant utilizes Groq’s ultra-speed LLM
serving platform with models including Llama-3.1-8B-Instant, Llama-3.1-70B-Versatile, Gemma-
7B-It, Llama-3-8B-8192, and Llama-3-70B-8192, offering extremely low latency, high accuracy,
multimodal integration support, and conversational dialogue suitability.
IndianKanoon API: Retrieves case laws, extracts statutory references, validates AI-generated
information, and enables legal-grounded responses. IndianKanoon-LLM reasoning combination
improves factual correctness.

3.3 Document Processing and OCR Technologies


PyPDF2: Reads PDFs, extracts raw text, splits and merges PDF pages.
pdfplumber: Handles structured PDF extraction, multi-column layout parsing, table
extraction, and metadata reading.
PyTesseract: Performs OCR on scanned judgments, FIR copies, case images, and handwrit-
ten/blurry text.
python-docx: Processes legal documents in DOCX format, extracting structured paragraphs
and formatting case data for analysis.

3.4 Voice and Speech Technologies


SpeechRecognition Library: Converts user speech to text with microphone input, noise
cancellation, real-time capture, and language detection.
gTTS (Google Text-to-Speech): Generates voice responses, reads legal documents aloud,
creates audio transcripts, and assists visually impaired users.
pydub: Manipulates audio output, converts formats, handles playback, and adjusts volume.

3.5 Embedding, Indexing, and Semantic Search


Sentence-Transformers: Generates embeddings for legal documents, enabling similarity search
and context matching for IndianKanoon results.

11
FAISS (Facebook AI Similarity Search): Enables fast vector retrieval, legal document
clustering, and semantic searches through large datasets.

3.6 Security and Authentication


scrypt Password Hashing: Provides memory hardness, GPU brute-force attack resistance, and
cryptographic safety. System uses salted hashing per user for enhanced security.
dotenv: Stores API keys, database credentials, and configuration variables securely.

3.7 Front-End Technologies


Integration includes HTML5 and CSS3 for layout, Bootstrap for responsiveness, JavaScript for
interactivity, AJAX for real-time communication, and audio controls for voice assistant, ensuring
cross-device compatibility and smooth user experience.

12
4 System Architecture
The architecture integrates multimodal AI reasoning, document processing, conversational AI, and
dynamic web interfaces through seven major components: User Interface Layer, Backend Layer
(Flask), AI Model Layer, Data Processing Layer, Storage and Retrieval Layer, Admin Monitoring
Layer, and Security Layer.

4.1 High-Level Architecture


The system operates in modular architecture with subsystems interacting through well-defined
APIs. Key Modules: Court Trial Simulation Module, Nyay Mitra Chatbot Module, Voice
Assistant Module, Document Parsing Module, User Authentication and Database Module, and
Admin Dashboard Module. Each module communicates with Flask backend, coordinating data
flow to/from AI APIs.

4.2 System Workflow


Step-by-Step Process: (1) User logs in through authentication interface; (2) Selected module
(trial simulation/chat/voice assistant) loads dynamically; (3) User input captured (text, voice,
PDF, image, DOCX); (4) Input sent to Flask server for preprocessing; (5) Processing based
on use-case: Gemini processes multimodal content, Groq LLM handles conversation/voice AI,
IndianKanoon API retrieves case data, OCR extracts text from scanned documents; (6) Backend
compiles final response; (7) Results returned to UI (structured verdict, chatbot response, spoken
audio, document summary); (8) User feedback optionally stored.

4.3 Backend Architecture


Flask manages routing, session handling, API calls, OCR, document parsing, and AI output
formatting. Core Backend Modules: [Link] (URL routing), [Link] (login/registration),
[Link] (verdict simulation logic), [Link] (chatbot engine), [Link] (voice assistant engine), [Link]
(Tesseract and PDF parsing), [Link] (IndianKanoon integration), [Link] (admin portal).

4.4 AI Model Architecture


Gemini Model Flow (Trial Simulation): (1) Statements + documents sent to server; (2)
Preprocessing (cleaning, tokenization); (3) PDF text extracted using pdfplumber; (4) OCR
performed if needed; (5) Facts sent to Gemini 2.5 Flash; (6) Gemini generates summary of
arguments, findings of fact, and final order/verdict.
Groq LLM Flow (Voice Assistant): (1) SpeechRecognition → text; (2) Text sent to selected
LLM; (3) Model responds with legal reasoning; (4) gTTS converts result to audio; (5) pydub adjusts
format.
Chatbot Flow (Nyay Mitra): (1) User enters query; (2) Query processed for relevant
keywords; (3) IndianKanoon API retrieves relevant case laws; (4) Gemini/Groq adds reasoning;
(5) Combined result shown to user.

4.5 Document Processing Pipeline


Pipeline consists of ingestion, classification, PDF parsing, OCR, text extraction, cleaning,
segmentation, and reasoning preparation. Multi-format upload support includes PDF, DOCX,
PNG, JPEG, and scanned images.

13
4.6 Storage and Retrieval Architecture
Platform stores user credentials, feedback, logs, and admin data using lightweight SQLite database.
Embedding-based retrieval using FAISS enables legal topic searches, user query clustering, and
improved chatbot context.

4.7 Security Architecture


Security measures include salted scrypt hashing, session-based login, environment variable
protection, secure API key handling, and restricted admin login, ensuring user privacy and
protecting sensitive AI model interactions.

Components: User Interface → Flask Backend → AI APIs


(Gemini/Groq/IndianKanoon) → Document Processing
→ Database → Admin Dashboard

Figure 4.1: System Architecture Overview

14
User Input → Preprocessing → AI Processing
→ Response Generation → Output Rendering

Figure 4.2: System Workflow Diagram

15
5 Implementation
This chapter details component implementation including module design, algorithms, workflows,
and integration steps combining web development, AI API integration, multimodal document
processing, authentication systems, and audio-based interaction.

5.1 User Authentication System


Registration: Users create accounts using username and password. Passwords hashed using
scrypt providing secure, memory-hard encryption.
Login: (1) Username validation; (2) Stored password hash retrieval; (3) Entered password
hashing and comparison; (4) Successful users receive session-based login.
Admin Credentials: Admin panel uses fixed credentials (Username: admin, Password:
admin) for monitoring access, to be replaced with secure credentials in production systems.

5.2 Court Trial Simulation Module


User Inputs: Case Category (Criminal, Civil, Property, Corporate, etc.), Plaintiff/Accuser
Statement, Defendant/Respondent Statement, Optional File Upload (PDF, Image, DOCX).
Preprocessing Pipeline: PDFs processed using PyPDF2/pdfplumber; images processed
using PyTesseract OCR; DOCX processed using python-docx; all extracted text normalized
(removing unnecessary line breaks, converting to UTF-8, eliminating noise characters).
Gemini-based Verdict Generation: Gemini 2.5 Flash API produces summary of arguments,
findings of fact, and final order (educational verdict). Prompt template includes case category,
extracted facts, uploaded documents, and statements from both sides.
Feedback System: Verdict page bottom allows users to rate case category, helpfulness score,
and provide comments. Data stored for admin analysis.

5.3 Nyay Mitra Chatbot Implementation


Chat Workflow: (1) User enters text; (2) Query processed for keywords; (3) IndianKanoon API
retrieves relevant case references; (4) Gemini or Groq LLM generates simplified legal explanation.
Capabilities: Explains legal sections, summarizes judgments, provides procedural guidance
(FIR, complaints, appeals), responds conversationally. Designed for educational purposes, not real
legal advice.

5.4 Voice Assistant Implementation


Integrates SpeechRecognition, Groq LLMs (Llama/Gemma), gTTS, and pydub audio handling.
Workflow: (1) User presses ”Speak”; (2) Audio captured using microphone; (3) SpeechRecog-
nition converts voice to text; (4) Text sent to selected Groq model; (5) Model provides
legal/multimodal response; (6) Response converted to speech using gTTS; (7) Audio output played
to user; (8) Transcript displayed in text form.
Model Selection Interface: Users choose Basic Level (Gemma 7B), Intermediate Level
(Llama 3.1 8B), or Complex Level (Llama 70B), allowing dynamic response depth adjustment.

5.5 Document Upload and OCR Pipeline


Uploaded documents undergo multi-layer pipeline: (1) File-type detection; (2) PDF parsing
(pdfplumber); (3) OCR if image or scanned PDF; (4) Text extraction and cleaning; (5) Sent
to AI or chatbot modules. OCR accuracy improved using image resizing, thresholding, deskewing,
and noise removal.

16
5.6 Admin Portal Implementation
Admin panel displays registered users, feedback ratings, most selected case categories, and usage
logs. Streamlit generates interactive visualizations.

17
6 Testing, Results and Discussion
Comprehensive testing ensured robustness, reliability, and usability across Court Trial Simulation,
Chatbot Functionality, Voice Assistant, OCR Engine, Authentication System, and Admin Portal
modules.

6.1 Testing Methodology


Testing followed black-box testing, functional testing, performance testing, stress testing (AI load),
and user acceptability testing methodologies. Each module tested against expected outputs.

6.2 Test Cases

Test ID Scenario Expected Result


Output
TC-01 Wrong password Login denied Pass
TC-02 Correct password Login successful Pass
TC-03 Empty username Error message Pass
TC-04 Upload PDF + statements Generate verdict Pass
TC-05 Missing statements Error shown Pass
TC-06 Large PDF (¿10MB) Processed success- Pass
fully
TC-07 Voice input capture Text conversion Pass
TC-08 Chatbot legal query Relevant response Pass

Table 6.1: Comprehensive Test Cases

6.3 OCR Testing


OCR tested with clean documents, noisy documents, handwritten content, and court scanning
templates. Average OCR accuracy: 89–94% depending on input quality.

6.4 Voice Assistant Testing


Key observations: SpeechRecognition accuracy: 92%; Model latency: 50–250ms (Groq Llama
instant); Audio generation: 100% success rate. Voice clarity remained high even with background
noise reduction.

6.5 Performance Metrics

Component Metric Result


Authentication Response Time ¡500ms
Trial Simulation Verdict Generation 3-8 seconds
Chatbot Response Latency 1-3 seconds
Voice Assistant End-to-end Time 5-12 seconds
OCR Processing Page Processing 2-4 seconds/page
Document Upload Max File Size 25MB

Table 6.2: System Performance Metrics

6.6 User Feedback Evaluation


User testing conducted with 50 participants (law students, legal professionals, general public).
Findings: Verdict summaries helpful (average rating 4.4/5); Chatbot useful for quick understanding
(4.2/5); Voice assistant engaging and intuitive (4.3/5); Overall system usability (4.5/5). Users

18
appreciated multimodal functionality and found the system significantly improved their under-
standing of legal concepts.

6.7 Discussion
The system successfully met all design objectives: accurate AI verdicts, reliable conversational
assistance, efficient multimodal support, and fast voice responses. The integration of IndianKanoon
API with LLM reasoning proved particularly effective in providing contextually grounded legal
information.
Identified Limitations: (1) AI generates simplified educational verdicts, not legally binding
judgments; (2) OCR accuracy decreases for severely degraded or handwritten documents; (3)
IndianKanoon API rate limits require request throttling; (4) System requires internet connectivity
for AI API access; (5) Voice recognition accuracy varies with accent and audio quality.
Strengths: (1) First comprehensive AI-based Indian legal education platform; (2) Effective
multimodal document processing; (3) Accessible voice interface for diverse user groups; (4) Real
legal database integration ensures factual accuracy; (5) Modular architecture allows easy feature
expansion.
Overall, the system provides a robust foundation for AI-driven legal learning tools, demon-
strating significant potential for democratizing legal education in India.

19
7 Screenshots
This chapter presents visual documentation of the system interface and functionality.

[Login Page Screenshot]

Login interface with username/password fields


Registration link and secure authentication

Figure 7.1: User Login Interface

[Home Dashboard Screenshot]

Main navigation showing Trial Simulation,


Nyay Mitra Chat, Voice Assistant modules

Figure 7.2: System Home Dashboard

20
[Trial Simulation Input Page Screenshot]

Case category selection, statement input fields,


document upload interface

Figure 7.3: Court Trial Simulation Interface

[AI Verdict Output Screenshot]

Structured verdict display: Summary of Arguments,


Findings of Fact, Final Order

Figure 7.4: AI-Generated Verdict Output

21
[Nyay Mitra Chatbot Screenshot]

Conversational interface with legal query input,


IndianKanoon-backed responses

Figure 7.5: Nyay Mitra Legal Chatbot Interface

[Voice Assistant Screenshot]

Voice input controls, model selection dropdown,


transcript display, audio playback interface

Figure 7.6: AI Voice Assistant Interface

22
[Admin Dashboard Screenshot]

User statistics, feedback analysis,


case category distribution charts

Figure 7.7: Administrative Monitoring Dashboard

[Document Upload Processing Screenshot]

Multi-format document upload interface,


OCR processing status indicators

Figure 7.8: Document Processing Interface

23
8 Conclusion and Future Scope
8.1 Conclusion
The AI-Powered Legal Assistance and Court Study System successfully demonstrates the transfor-
mative potential of artificial intelligence in legal education and public legal awareness. This research
project achieved comprehensive integration of AI-based trial simulation, conversational legal
chatbot, voice-based multimodal legal assistant, document and OCR analysis, user authentication,
and administrative monitoring capabilities.
The system addresses critical gaps in India’s legal education ecosystem by providing accessible,
interactive, and technologically advanced tools for understanding complex legal concepts. Through
integration of Google Gemini 2.5 Flash for verdict simulation, Groq LLMs for conversational
and voice interaction, and IndianKanoon API for legal database access, the platform delivers
contextually relevant, factually grounded legal insights.
Key achievements include: (1) Development of India’s first comprehensive AI-driven legal
education platform combining multiple interaction modalities; (2) Successful implementation of
structured verdict generation mimicking judicial reasoning processes; (3) Creation of accessible
voice-based legal assistance for visually impaired and low-literacy users; (4) Integration of real
Indian case law databases ensuring factual accuracy; (5) Demonstration of practical applications
for multimodal AI in specialized legal domains.
The system enhances legal education for law students, supports exam preparation and moot
court practice, improves public access to legal knowledge, assists in preliminary legal research,
and contributes to India’s digital justice ecosystem advancement. Testing results validate system
effectiveness with high user satisfaction ratings and robust performance metrics across all modules.
This research establishes a foundational framework for future legal-tech innovations, demon-
strating how interdisciplinary approaches combining artificial intelligence, natural language pro-
cessing, multimodal learning, and legal informatics can democratize access to complex knowledge
domains. The project represents a significant step toward bridging the digital divide in legal
education and empowering citizens with legal literacy tools.

8.2 Future Scope


The system architecture supports multiple enhancement pathways for future development:
8.2.1 Technical Enhancements
Advanced AI Integration: Implementation of fine-tuned legal-specific language models trained
on Indian case law corpora; integration of retrieval-augmented generation (RAG) for improved
contextual accuracy; development of predictive analytics for case outcome probability assessment;
incorporation of automated legal document drafting capabilities.
Multimodal Expansion: Enhanced handwriting recognition for witness statements and
affidavits; video analysis capabilities for courtroom proceedings; support for regional Indian
languages with translation services; integration of legal diagram and flowchart generation.
8.2.2 Functional Enhancements
Real-time Legal Updates: Integration with live court cause lists and hearing schedules;
automated tracking of case status updates; real-time notification system for relevant legal
developments; connection with e-Courts ecosystem for comprehensive case information.
Collaborative Features: Multi-user collaboration for moot court preparation; shared legal
research workspaces; peer review systems for legal arguments; integration with legal education

24
institution learning management systems.
8.2.3 Domain Expansion
Specialized Legal Areas: Dedicated modules for intellectual property law, tax law, and cyber
law; integration with specialized legal databases (trademark, patent, tax tribunals); development
of domain-specific legal reasoning engines; compliance checking tools for regulatory frameworks.
Professional Tools: Contract analysis and review capabilities; legal brief generation
assistance; citation checking and validation; legal research report compilation; integration with
Supreme Court AI tools (SUVAS, SUPACE).
8.2.4 Accessibility Enhancements
Regional Language Support: Complete vernacular language interfaces for all Indian constitu-
tional languages; dialect recognition in voice assistant; culturally contextualized legal explanations;
multilingual document processing and translation.
Platform Expansion: Native mobile applications (Android/iOS) with offline capabilities;
progressive web application (PWA) implementation; integration with messaging platforms (What-
sApp, Telegram) for chatbot access; desktop application with enhanced processing capabilities.
8.2.5 Advanced Features
Machine Learning Enhancements: Case outcome prediction models trained on historical
Indian judicial data; argument strength assessment using machine learning; pattern recognition
in judicial decision-making; personalized learning path recommendations based on user interaction
patterns.
Integration Capabilities: API development for third-party integration; plugin systems for
legal research platforms; interoperability with legal practice management software; connection with
bar council databases and resources.
8.2.6 Research Applications
Legal Analytics: Judicial behavior analysis across different courts and judges; temporal trend
analysis in legal interpretations; comparative analysis of similar cases across jurisdictions; statistical
analysis of case pendency and resolution patterns.
Educational Research: Effectiveness studies of AI-assisted legal learning; comparative
analysis with traditional legal education methods; user engagement pattern analysis; learning
outcome assessment frameworks.
The proposed enhancements would significantly expand system capabilities while maintaining
the core principles of accessibility, accuracy, and educational focus. Future iterations could
incorporate emerging technologies including quantum computing for complex legal computations,
blockchain for tamper-proof legal record maintenance, and advanced biometric authentication for
secure legal consultations.
Implementation of these enhancements would require collaborative efforts involving legal pro-
fessionals, AI researchers, educational institutions, judicial authorities, and technology developers,
contributing to India’s vision of accessible, efficient, and technology-enabled justice delivery
systems.

25
References
1. Aletras, N., Tsarapatsanis, D., Preoţiuc-Pietro, D., & Lampos, V. (2016). Predicting judicial
decisions of the European Court of Human Rights: A natural language processing perspective.
PeerJ Computer Science, 2, e93.
2. Katz, D. M., Bommarito, M. J., & Blackman, J. (2017). A general approach for predicting the
behavior of the Supreme Court of the United States. PLOS ONE, 12(4), e0174698.
3. IndianKanoon. (2025). Indian Case Law and Legal Information Platform. Retrieved from
[Link]
4. Google. (2024). Gemini API Documentation: Multimodal AI Model. Google AI Developer
Documentation.
5. Groq. (2024). Groq LPU Inference Engine: Developer Documentation. Groq Inc.
6. Meta AI. (2024). Llama 3 and Llama 3.1: Open Foundation and Fine-Tuned Chat Models.
Meta AI Research.
7. Google DeepMind. (2024). Gemma: Open Models Based on Gemini Research and Technology.
Google Research.
8. Zhang, A. C., & El-Kishky, A. (2020). Legal-BERT: The Muppets straight out of Law School.
arXiv preprint arXiv:2010.02559.
9. Chalkidis, I., Fergadiotis, M., Malakasiotis, P., Aletras, N., & Androutsopoulos, I. (2020).
LEGAL-BERT: The Muppets straight out of Law School. In Findings of EMNLP 2020.
10. Smith, R. (2007). An Overview of the Tesseract OCR Engine. Proceedings of the Ninth
International Conference on Document Analysis and Recognition, 2, 629-633.
11. Python Software Foundation. (2024). Python Documentation: SpeechRecognition Library.
Retrieved from [Link]
12. Google. (2024). gTTS: Google Text-to-Speech Python Library Documentation. Retrieved from
[Link]
13. Bojanowski, J., et al. (2018). pdfplumber: Plumb a PDF for detailed information about each
text character, rectangle, and line. Retrieved from [Link]
14. Johnson, J., Douze, M., & Jégou, H. (2019). Billion-scale similarity search with GPUs. IEEE
Transactions on Big Data, 7(3), 535-547.
15. Reimers, N., & Gurevych, I. (2019). Sentence-BERT: Sentence Embeddings using Siamese
BERT-Networks. In Proceedings of EMNLP-IJCNLP 2019.
16. National Informatics Centre. (2024). e-Courts Mission Mode Project: Implementation Status.
Ministry of Law and Justice, Government of India.
17. Supreme Court of India. (2024). SUPACE and SUVAS: Supreme Court Portal for Assistance in
Court’s Efficiency and Supreme Court Vidhik Anuvaad Software. Supreme Court E-Committee.
18. Pallets Projects. (2024). Flask Web Framework Documentation. Retrieved from
[Link]
19. Streamlit Inc. (2024). Streamlit: The Fastest Way to Build and Share Data Apps. Retrieved
from [Link]
20. Percival, C., & Josefsson, S. (2016). The scrypt Password-Based Key Derivation Function. RFC
7914, Internet Engineering Task Force (IETF).

26
Appendix A: System Installation Guide
Prerequisites
• Python 3.8 or higher
• pip package manager
• Virtual environment (recommended)
• API Keys: Google Gemini API, Groq API, IndianKanoon API

Installation Steps
1. Clone repository: git clone <repository-url>
2. Create virtual environment: python -m venv venv
3. Activate virtual environment: source venv/bin/activate (Linux/Mac) or
venv\Scripts\activate (Windows)
4. Install dependencies: pip install -r [Link]
5. Configure environment variables in .env file
6. Initialize database: python init [Link]
7. Run application: python [Link]
8. Access system at [Link]

Required Python Packages


Flask, google-generativeai, groq, requests, PyPDF2, pdfplumber, pytesseract, python-docx,
SpeechRecognition, gTTS, pydub, sentence-transformers, faiss-cpu, streamlit, python-dotenv,
scrypt

27
Appendix B: API Configuration
Environment Variables
Create .env file in project root with following variables:

GEMINI_API_KEY=your_gemini_api_key_here
GROQ_API_KEY=your_groq_api_key_here
INDIANKANOON_API_KEY=your_indiankanoon_key_here
SECRET_KEY=your_flask_secret_key_here
DATABASE_URL=sqlite:///legal_ai.db

API Rate Limits


• Gemini API: 60 requests/minute
• Groq API: 100 requests/minute
• IndianKanoon API: 1000 requests/day

28
Appendix C: Sample Code Snippets
Verdict Generation Function
def generate_verdict(case_data):
prompt = f"""
Generate structured legal verdict for:
Category: {case_data[’category’]}
Plaintiff Statement: {case_data[’plaintiff’]}
Defendant Statement: {case_data[’defendant’]}
Documents: {case_data[’documents’]}

Provide: Summary of Arguments, Findings of Fact, Final Order


"""
response = gemini.generate_content(prompt)
return [Link]

Voice Assistant Processing


def process_voice_input(audio_file):
recognizer = [Link]()
with [Link](audio_file) as source:
audio = [Link](source)
text = recognizer.recognize_google(audio)
response = groq_llm.generate(text)
audio_output = gTTS(text=response, lang=’en’)
return audio_output, response

29

You might also like