Skip to content

Latest commit

ย 

History

66 Commits

Folders and files

NameName
Last commit message
Last commit date
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿ” FairLens โ€” AI Bias Auditing Platform

Making AI Fair for Everyone
Detect, measure, and fix hidden bias in AI systems โ€” powered by Google Gemini


๐ŸŽฏ The Problem

AI systems used in hiring, lending, criminal justice, and healthcare are making biased decisions that discriminate against real people โ€” and most organizations don't even know it.

Real-World Case What Happened
COMPAS (US Courts) Black defendants rated HIGH risk at 2ร— the rate of white defendants
Amazon Hiring AI Algorithm penalized resumes containing "women's" โ€” 57% score penalty
Healthcare AI Black patients 41% less likely to be correctly identified as high-need

83% of HR AI tools show gender bias. These aren't hypothetical โ€” these are documented cases.


๐Ÿ’ก Our Solution

FairLens is a full-stack AI-powered platform that makes bias auditing accessible to everyone โ€” no ML expertise required.

Upload CSV โ†’ 4 Fairness Metrics in 60s โ†’ Gemini AI Explains in Plain English โ†’ PDF Report

โœจ Key Features

Feature Description
๐Ÿ” One-Click Bias Audit Upload any CSV โ†’ get DPD, EOD, DIR, Cramรฉr's V metrics instantly
๐Ÿค– Gemini AI Explanations Plain-English verdict, key findings, who's affected, fix suggestions
โš–๏ธ Legal Compliance Auto-checks against EU AI Act, EEOC 4/5 Rule, ISO 42001
๐Ÿ“„ PDF Audit Reports Professional downloadable reports for compliance teams
๐ŸŒ 10 Language Support Re-generate analysis in Hindi, Spanish, Arabic, French & more
๐Ÿ’ฌ Ask Gemini Q&A Interactive chat โ€” ask questions about your audit results
๐ŸŽฏ What-If Simulator Remove attributes & see fairness score change in real-time
๐Ÿ”— Shareable Audit Links Make any audit public with one click โ€” no login needed to view
โšก No-Login Live Demo Try 3 real datasets instantly โ€” COMPAS, Adult Income, German Credit
๐Ÿ” Google Sign-In One-click OAuth 2.0 authentication
๐ŸŒ— Dark/Light Theme Full theme support across the dashboard
๐Ÿ“ฑ Mobile Responsive Works seamlessly on desktop, tablet, and mobile

๐Ÿ—๏ธ Architecture

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                    FRONTEND (Next.js 16)                     โ”‚
โ”‚  Landing ยท Dashboard ยท Audit Results ยท Demo ยท Auth Pages     โ”‚
โ”‚  Tailwind CSS ยท Framer Motion ยท Recharts                     โ”‚
โ”‚                    Deployed on Render                         โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                       โ”‚ REST API (Axios)
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                   BACKEND (FastAPI Python)                    โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚
โ”‚  โ”‚Auth      โ”‚  โ”‚Audit     โ”‚  โ”‚Report    โ”‚  โ”‚Gemini       โ”‚ โ”‚
โ”‚  โ”‚Router    โ”‚  โ”‚Router    โ”‚  โ”‚Router    โ”‚  โ”‚Service      โ”‚ โ”‚
โ”‚  โ”‚JWT+OAuth โ”‚  โ”‚Bias Eng. โ”‚  โ”‚PDF Gen.  โ”‚  โ”‚Multi-Key    โ”‚ โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚
โ”‚                    Deployed on Render                         โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
        โ”‚                                 โ”‚
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”          โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  Neon PostgreSQL  โ”‚          โ”‚  Google Gemini 2.5 Flash    โ”‚
โ”‚  (Cloud Database) โ”‚          โ”‚  (AI Analysis + Multi-Key)  โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜          โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

๐Ÿ› ๏ธ Tech Stack

Layer Technology
Frontend Next.js 16 + TypeScript + Tailwind CSS
Animations Framer Motion
Charts Recharts
Backend FastAPI (Python 3.11)
AI Service Google Gemini 2.5 Flash (multi-key rotation)
Bias Analysis fairlearn + pandas + scikit-learn + scipy
Auth JWT (python-jose + bcrypt) + Google OAuth 2.0
Database Neon PostgreSQL (Cloud) / SQLite (local)
PDF Reports ReportLab
Deployment Render (Singapore region)

Google Technologies Used

  • โœ… Google Gemini 2.5 Flash โ€” AI-powered bias explanations, fix suggestions, Q&A chat, multi-language support
  • โœ… Google Sign-In (OAuth 2.0) โ€” One-click authentication
  • โœ… Cloud Deployment โ€” Fully deployed and live on Render

๐Ÿ“Š Fairness Metrics Explained

Metric Fair Threshold What It Measures
Demographic Parity Diff. (DPD) < 0.10 Gap in positive decision rates between groups
Equalized Odds Diff. (EOD) < 0.10 Gap in error rates (false positives/negatives) between groups
Disparate Impact Ratio (DIR) > 0.80 80% rule โ€” EEOC 4/5 Rule from US employment law
Cramรฉr's V (Bias Attribution) โ€” How strongly each attribute drives unequal outcomes

โšก Quick Start (Local Development)

Prerequisites

1. Clone & Setup Backend

git clone https://github.com/Manin1311/Exceptional_Duo.git
cd Exceptional_Duo/backend
pip install -r requirements.txt
copy .env.example .env        # Windows
# cp .env.example .env        # Mac/Linux

2. Configure API Keys

Edit backend/.env:

GEMINI_API_KEY=your_primary_key_here
GEMINI_API_KEY_1=your_second_key_here   # optional, for rotation
SECRET_KEY=any-long-random-string
DATABASE_URL=sqlite:///./fairlens.db
ALLOWED_ORIGINS=http://localhost:3000

๐Ÿ’ก Multiple API keys enable automatic rotation when one hits rate limits.

3. Start Backend

uvicorn main:app --reload --port 8000

4. Start Frontend

cd ../frontend
npm install
npm run dev

5. Open in Browser

URL Page
http://localhost:3000 Landing page
http://localhost:3000/demo Live demo (no login needed)
http://localhost:3000/register Create account
http://localhost:3000/dashboard Audit dashboard


๐Ÿ“ Project Structure

Exceptional_Duo/
โ”œโ”€โ”€ frontend/                  # Next.js 16 + TypeScript
โ”‚   โ”œโ”€โ”€ app/
โ”‚   โ”‚   โ”œโ”€โ”€ page.tsx           # Landing page
โ”‚   โ”‚   โ”œโ”€โ”€ login/             # Login page
โ”‚   โ”‚   โ”œโ”€โ”€ register/          # Registration page
โ”‚   โ”‚   โ”œโ”€โ”€ dashboard/         # Audit dashboard
โ”‚   โ”‚   โ”œโ”€โ”€ demo/              # No-login demo page
โ”‚   โ”‚   โ””โ”€โ”€ audit/
โ”‚   โ”‚       โ”œโ”€โ”€ new/           # New audit wizard
โ”‚   โ”‚       โ”œโ”€โ”€ [id]/          # Audit results (authenticated)
โ”‚   โ”‚       โ””โ”€โ”€ public/[id]/   # Shared public audit view
โ”‚   โ””โ”€โ”€ lib/
โ”‚       โ”œโ”€โ”€ api.ts             # Axios API client
โ”‚       โ”œโ”€โ”€ auth-context.tsx   # Auth provider
โ”‚       โ””โ”€โ”€ wake-up.tsx        # Backend wake-up ping
โ”œโ”€โ”€ backend/                   # FastAPI Python
โ”‚   โ”œโ”€โ”€ main.py                # App entry point
โ”‚   โ”œโ”€โ”€ Dockerfile             # Docker build
โ”‚   โ”œโ”€โ”€ requirements.txt       # Python dependencies
โ”‚   โ”œโ”€โ”€ routers/
โ”‚   โ”‚   โ”œโ”€โ”€ auth.py            # JWT + Google OAuth
โ”‚   โ”‚   โ”œโ”€โ”€ audit.py           # Bias analysis + demo + share
โ”‚   โ”‚   โ””โ”€โ”€ report.py          # PDF report generation
โ”‚   โ”œโ”€โ”€ services/
โ”‚   โ”‚   โ”œโ”€โ”€ gemini_service.py  # Gemini AI (multi-key rotation)
โ”‚   โ”‚   โ””โ”€โ”€ bias_engine.py     # Fairness metrics engine
โ”‚   โ”œโ”€โ”€ models/
โ”‚   โ”‚   โ”œโ”€โ”€ database.py        # SQLAlchemy models
โ”‚   โ”‚   โ””โ”€โ”€ schemas.py         # Pydantic schemas
โ”‚   โ””โ”€โ”€ demo_datasets/         # Pre-loaded CSV datasets
โ”‚       โ”œโ”€โ”€ compas.csv
โ”‚       โ”œโ”€โ”€ adult_income.csv
โ”‚       โ””โ”€โ”€ german_credit.csv
โ””โ”€โ”€ render.yaml                # Render deployment blueprint

๐Ÿ”ฎ Future Roadmap

  • ๐Ÿ”„ Auto-Mitigation โ€” Automatically rebalance datasets to reduce bias
  • ๐Ÿ“Š CI/CD API โ€” REST API for pipeline integration (audit before deploy)
  • ๐Ÿ‘ฅ Team Workspaces โ€” Multi-user organizations with role-based access
  • ๐Ÿ“ˆ Bias Monitoring โ€” Track fairness scores over time
  • ๐Ÿง  NLP & Image Bias โ€” Extend beyond tabular data
  • ๐Ÿ›๏ธ More Regulations โ€” India DPDP Act, Canada AIDA

About

๐Ÿ” AI Bias Auditing Platform powered by Google Gemini. Detect, measure, & fix hidden discrimination in AI models (DPD, EOD, DIR) with plain-English insights, PDF reports & compliance checks (EU AI Act, EEOC).

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages