Skip to content

Ahmed-KHI/pakistan-court-case-predictor

Repository files navigation

🌟 Overview

🎯 What is this?

An intelligent legal assistant built with cutting-edge AI technology to help Pakistani citizens understand their court cases better. Powered by Google Gemini 2.0, this system analyzes case details and provides:

  • πŸ“Š Outcome Predictions based on Pakistani law
  • πŸ’° Cost Estimations in PKR
  • ⏱️ Timeline Forecasts for case resolution
  • βš–οΈ Risk Assessment with confidence scores
  • πŸŽ™οΈ Voice Input in native Urdu language
Governor House

Mission: Democratize legal intelligence for Pakistani citizens using AI technology.

Impact: Making justice system more accessible and transparent for everyone.


✨ Features

πŸŽ™οΈ Voice Assistant

Native Urdu Speech

  • Authentic Pakistani accent (Kore voice)
  • Real-time speech recognition
  • 10-question guided interview
  • Auto case detail extraction

πŸ€– AI Analysis

Gemini 2.0 Powered

  • Advanced language model
  • Pakistani law precedents
  • Risk & confidence scoring
  • Multi-factor evaluation

🌐 Bilingual

English + Urdu

  • Real-time translation
  • Proper Urdu script (اردو)
  • Seamless language switching
  • Native font rendering

βš–οΈ Predictions

Smart Outcomes

  • Win/Lose probability
  • Settlement likelihood
  • Case urgency level
  • Evidence strength analysis

πŸ’° Cost Estimates

Realistic PKR Forecasts

  • Court fees breakdown
  • Lawyer charges estimate
  • Total cost projection
  • Timeline-based calculation

πŸ” Privacy

Secure & Private

  • No data storage
  • Client-side processing
  • Secure API calls
  • Your data, your control

πŸ› οΈ Tech Stack

Frontend Excellence


Next.js 16
App Router + Turbopack

TypeScript 5
Type Safety

Tailwind CSS 4
Modern Styling

React 19
UI Library

AI & Voice Technology


Gemini 2.0 Flash
AI Analysis Engine

Gemini Live API
Kore Voice (Urdu)

WebSocket + Web Audio
Real-time Communication

Deployment & Tools


Vercel
Serverless Deploy

Git
Version Control

ESLint
Code Quality

npm
Package Manager

πŸš€ Getting Started

πŸ“‹ Prerequisites
βœ… Node.js 18+ (Download from nodejs.org)
βœ… npm or yarn package manager
βœ… Google Gemini API Key (Free at aistudio.google.com/app/apikey)
βœ… Git installed
⚑ Quick Installation

1️⃣ Clone Repository

git clone https://github.com/Ahmed-KHI/pakistan-court-case-predictor.git
cd pakistan-court-case-predictor

2️⃣ Install Dependencies

npm install

3️⃣ Setup Environment

# Copy .env.example to .env.local
cp .env.example .env.local

# Edit .env.local and add your Gemini API key
NEXT_PUBLIC_GEMINI_API_KEY=your_api_key_here

4️⃣ Run Development Server

npm run dev

5️⃣ Open Browser

🌐 http://localhost:3000
πŸ—οΈ Build for Production
# Create optimized production build
npm run build

# Start production server
npm start

Install dependencies

npm install

Setup environment

cp .env.example .env.local

Add your Gemini API key to .env.local

Run development server

npm run dev


Open [http://localhost:3000](http://localhost:3000) in your browser.



---

## 🎯 Usage Guide

<table>
<tr>
<td width="50%">

### πŸŽ™οΈ Voice Mode (Urdu)

1. **Click** "Start Voice Conversation" πŸŽ™οΈ
2. **Grant** microphone permission
3. **Hear** greeting in Urdu: "Ψ§Ω„Ψ³Ω„Ψ§Ω… ΨΉΩ„ΫŒΪ©Ω…"
4. **Answer** 10 questions naturally:
   - Ψ’ΩΎ Ϊ©Ψ§ Ω†Ψ§Ω…ΨŸ (Your name?)
   - ΨΉΩ…Ψ±ΨŸ (Age?)
   - کیس کی Ω‚Ψ³Ω…ΨŸ (Case type?)
   - ΨͺΩΨ΅ΫŒΩ„ΨŸ (Description?)
   - And more...
5. **Receive** instant AI prediction

**Benefits:**
- βœ… Natural conversation flow
- βœ… Authentic Pakistani accent
- βœ… No typing required
- βœ… Perfect for illiterate users

</td>
<td width="50%">

### ⌨️ Manual Mode (Text)

1. **Fill** case details form:
   - Name, Age, Location
   - Case Type (Criminal/Civil/Property)
   - Description, Evidence
   - Financial Status
2. **Click** "Analyze Case" πŸ“Š
3. **View** comprehensive results:
   - Outcome prediction
   - Cost estimation
   - Timeline forecast
   - Risk assessment
4. **Toggle** Urdu translation 🌐

**Benefits:**
- βœ… Detailed input control
- βœ… Review before submission
- βœ… Edit anytime
- βœ… Bilingual support

</td>
</tr>
</table>

---

## πŸ› οΈ Tech Stack

| Category | Technologies |
|----------|-------------|
| **Framework** | Next.js 16, React 19, TypeScript 5 |
| **Styling** | Tailwind CSS 4 |
| **AI/ML** | Google Gemini 2.0 Flash Exp |
| **Voice** | Gemini Live WebSocket API (Kore voice) |
| **Speech** | Web Speech API (ur-PK) |
| **Deployment** | Vercel |

---

## 🌐 Deployment

### Deploy to Vercel

<div align="center">

[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/clone?repository-url=https://github.com/Ahmed-KHI/pakistan-court-case-predictor&env=NEXT_PUBLIC_GEMINI_API_KEY)

</div>

**Manual Steps:**
1. Push code to GitHub
2. Import project in [Vercel](https://vercel.com/new)
3. Add environment variable: `NEXT_PUBLIC_GEMINI_API_KEY`
4. Deploy πŸš€

### Build for Production

```bash
npm run build
npm start

πŸ“ Project Structure

pakistan-court-case-predictor/
β”‚
β”œβ”€β”€ πŸ“‚ app/
β”‚   β”œβ”€β”€ πŸ“‚ api/
β”‚   β”‚   β”œβ”€β”€ πŸ“„ predict/route.ts      # AI case analysis endpoint
β”‚   β”‚   β”œβ”€β”€ πŸ“„ translate/route.ts    # Urdu translation endpoint
β”‚   β”‚   └── πŸ“„ voice/route.ts        # Voice processing endpoint
β”‚   β”œβ”€β”€ πŸ“„ layout.tsx                # Root layout with metadata
β”‚   β”œβ”€β”€ πŸ“„ page.tsx                  # Home page component
β”‚   └── πŸ“„ globals.css               # Global styles
β”‚
β”œβ”€β”€ πŸ“‚ components/
β”‚   β”œβ”€β”€ πŸ“„ ConversationalVoice.tsx   # Voice assistant with Gemini Live
β”‚   β”œβ”€β”€ πŸ“„ PredictionDisplay.tsx     # AI prediction results UI
β”‚   └── πŸ“‚ ui/
β”‚       β”œβ”€β”€ πŸ“„ card.tsx              # Card components
β”‚       β”œβ”€β”€ πŸ“„ button.tsx            # Button components
β”‚       └── πŸ“„ badge.tsx             # Badge components
β”‚
β”œβ”€β”€ πŸ“‚ lib/
β”‚   β”œβ”€β”€ πŸ“„ gemini.ts                 # Gemini API client
β”‚   β”œβ”€β”€ πŸ“„ utils.ts                  # Utility functions
β”‚   └── πŸ“‚ legal-data/
β”‚       └── πŸ“„ pakistan-laws.ts      # Pakistani law database
β”‚
β”œβ”€β”€ πŸ“‚ docs/
β”‚   └── πŸ“„ index.html                # GitHub Pages site
β”‚
β”œβ”€β”€ πŸ“„ .env.local                    # Environment variables (create this)
β”œβ”€β”€ πŸ“„ .env.example                  # Environment template
β”œβ”€β”€ πŸ“„ vercel.json                   # Vercel deployment config
β”œβ”€β”€ πŸ“„ README.md                     # This file
└── πŸ“„ LICENSE                       # MIT License

🀝 Contributing

We Welcome Contributions! 🌟

Contributors

How to Contribute:

  1. 🍴 Fork the repository
  2. 🌿 Create feature branch: git checkout -b feature/AmazingFeature
  3. πŸ’Ύ Commit changes: git commit -m 'Add: AmazingFeature'
  4. πŸ“€ Push to branch: git push origin feature/AmazingFeature
  5. πŸ”ƒ Open Pull Request

Contribution Ideas:

  • πŸ› Bug fixes and improvements
  • ✨ New features (e.g., more case types, additional languages)
  • πŸ“š Documentation improvements
  • 🎨 UI/UX enhancements
  • πŸ§ͺ Test coverage

οΏ½ License

MIT License Β© 2025 Muhammad Ahmed

License: MIT

This project is free and open-source software licensed under the MIT License.
See the LICENSE file for full details.


πŸ‘¨β€πŸ’» Developer

Muhammad Ahmed

Full Stack Developer | AI Enthusiast | Pakistan πŸ‡΅πŸ‡°

GitHub LinkedIn Email


πŸ™ Acknowledgments

Special Thanks To:

πŸ›οΈ Governor House Karachi IT Initiative
For providing the platform and inspiration

πŸ€– Google Gemini Team
For the powerful AI technology

πŸ‡΅πŸ‡° Pakistan Tech Community
For continuous support and feedback

βš–οΈ Legal Experts
For guidance on Pakistani law implementation


πŸ“Š Repository Stats

GitHub Stars GitHub Forks GitHub Issues GitHub Pull Requests

GitHub Last Commit GitHub Repo Size GitHub Language GitHub License


🎯 Roadmap

  • βœ… Voice input in Urdu with Pakistani accent
  • βœ… AI-powered case prediction
  • βœ… Bilingual interface (English + Urdu)
  • βœ… Cost estimation in PKR
  • βœ… Risk assessment system
  • πŸ”„ Mobile app (React Native)
  • πŸ”„ More languages support (Punjabi, Sindhi, Pashto)
  • πŸ”„ Integration with court databases
  • πŸ”„ Lawyer matching system
  • πŸ”„ Document generation (case filing templates)
  • πŸ”„ Chat support with legal AI assistant

⚠️ Disclaimer

Important: This tool provides AI-generated predictions for educational purposes only. It should NOT be considered as professional legal advice. Always consult with a qualified lawyer for actual legal matters. The predictions are based on AI analysis and may not reflect actual court outcomes.


πŸ’š Support This Project

If you find this project helpful, please consider:

⭐ Starring this repository
🍴 Forking to contribute
πŸ› Reporting issues
πŸ“’ Sharing with others
β˜• Supporting development

Muhammad Ahmed (Ahmed-KHI)

GitHub
Footer

Made in Pakistan πŸ‡΅πŸ‡° | Powered by AI πŸ€– | Built for Justice βš–οΈ

Β© 2025 Pakistan Court Case Predictor. All Rights Reserved.

Releases

No releases published

Packages

No packages published

Languages