Skip to content

About

Repository: AI-Powered-Bank-Statement-Credit-Report-Analyzer

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

Finlyzer — AI-Powered Bank Statement & Credit Report Analyzer

Intelligent financial document analysis platform that uses Google Gemini AI to extract, categorize, and summarize transactions from bank statements and credit reports — containerized with Docker for cloud deployment.


✨ Features

Capability Description
Bank Statement Analysis Extracts transactions from PDF bank statements using Gemini vision, calculates debit/credit/balance, and identifies recurring patterns
Credit Report Analysis Parses credit report PDFs to extract credit score, open loans, credit cards, and overdue status
AI-Powered OCR Converts PDF pages to images and uses Gemini multi-modal models for high-accuracy data extraction
Parallel Processing Distributes workload across up to 4 Google API keys using ThreadPoolExecutor for faster analysis
Beneficiary Normalization Groups and normalizes beneficiary names using AI to unify similar entries (e.g., "apollo pharmacy" → "Apollo Pharmacy")
Monthly Summaries Generates month-by-month credit/debit breakdowns and transaction-type analysis (UPI, ECS, NACH, ACH)
Recurring Transaction Detection Identifies beneficiaries with transactions across ≥ 3 months
Cloud-Native Storage Uploads/downloads files via Google Cloud Storage (GCS) for scalable, stateless processing
Streamlit Frontend Interactive web UI for file upload and result visualization with tables and summaries

🏗️ Architecture

┌─────────────────────┐         ┌──────────────────────────┐
│   Streamlit Frontend│────────▶│   FastAPI Backend         │
│   (port 8080)       │  HTTP   │   (port 8000)            │
│                     │◀────────│                          │
└─────────────────────┘         │  ┌────────────────────┐  │
                                │  │ bank_data_analyzer  │  │
                                │  │ credit_report_      │  │
                                │  │   analyzer           │  │
                                │  └────────┬───────────┘  │
                                └───────────┼──────────────┘
                                            │
                          ┌─────────────────┼─────────────────┐
                          ▼                 ▼                 ▼
                   Google Cloud       Gemini AI API     Groq API
                   Storage (GCS)      (Vision + Text)   (Auxiliary)

Both services are containerized with Docker for deployment.


📁 Project Structure

Finlyzer/
├── requirements.txt                 # Unified Python dependencies (backend + frontend)
│
├── back gke/                        # Backend service
│   ├── main.py                      # FastAPI app — /upload, /process, /health endpoints
│   ├── bank_data_analyzer.py        # Bank statement processing pipeline (9 steps)
│   ├── credit_report_analyzer.py    # Credit report extraction pipeline
│   ├── Dockerfile                   # Backend container (Python 3.12 + Poppler)
│   ├── .env.template                # Environment variable template
│   ├── credentials.template.json    # GCP service account key template
│   └── .gitignore
│
└── front gke/                       # Frontend service
    ├── app.py                       # Streamlit web application
    ├── Dockerfile                   # Frontend container (Python 3.12)
    ├── .env.template                # Environment variable template
    └── .gitignore

⚙️ Prerequisites

  • Python 3.12+
  • Poppler (required by pdf2image for PDF-to-image conversion)
    • Windows: download from poppler-windows and add to PATH
    • Linux/Docker: apt-get install -y poppler-utils
  • Google Cloud Platform account with:
    • A GCS bucket created
    • A service account key (credentials.json) with Storage Admin permissions
    • Gemini API key(s) from Google AI Studio
  • Groq API key from Groq Console (used for auxiliary extraction)
  • Docker (for containerized deployment)

🚀 Getting Started

1. Clone the Repository

git clone <repository-url>
cd "Finlyzer"

2. Backend Setup

cd "back gke"

# Create environment file from template
cp .env.template .env

# Create credentials file from template
cp credentials.template.json credentials.json

Edit .env with your actual values:

GOOGLE_API_KEY=your-primary-gemini-api-key
GOOGLE_API_KEY_2=your-second-gemini-api-key
GOOGLE_API_KEY_3=your-third-gemini-api-key
GOOGLE_API_KEY_4=your-fourth-gemini-api-key
GCS_BUCKET_NAME=your-gcs-bucket-name
GOOGLE_APPLICATION_CREDENTIALS=credentials.json
GROQ_API_KEY=your-groq-api-key

Edit credentials.json with your actual GCP service account key.

# Install dependencies (from project root)
pip install -r ../requirements.txt

# Run the backend
uvicorn main:app --host 0.0.0.0 --port 8000 --reload

3. Frontend Setup

cd "front gke"

# Create environment file from template
cp .env.template .env

Edit .env:

GOOGLE_API_KEY=your-gemini-api-key
BACKEND_URL=http://localhost:8000
GCS_BUCKET_NAME=your-gcs-bucket-name
# Install dependencies (from project root)
pip install -r ../requirements.txt

# Run the frontend
streamlit run app.py --server.port 8080

The app will be accessible at http://localhost:8080.


🐳 Docker Deployment

Build & Run Backend

cd "back gke"
docker build -t finlyzer-backend .
docker run -p 8000:8000 \
  -e GCS_BUCKET_NAME=your-bucket \
  -e GROQ_API_KEY=your-groq-key \
  -v /path/to/credentials.json:/app/credentials.json \
  finlyzer-backend

Build & Run Frontend

cd "front gke"
docker build -t finlyzer-frontend .
docker run -p 8080:8080 \
  -e BACKEND_URL=http://host.docker.internal:8000 \
  finlyzer-frontend

📡 API Endpoints

Method Endpoint Description
GET / Health check — returns service status
GET /health/ Detailed health — includes bucket name
POST /upload/ Upload a PDF file to GCS — returns { filename }
POST /process/ Process uploaded files — accepts applicant_no, bank_file_name, credit_file_name

Example — Process Files

curl -X POST http://localhost:8000/process/ \
  -F "applicant_no=12345" \
  -F "bank_file_name=<uploaded_filename>.pdf" \
  -F "credit_file_name=<uploaded_filename>.pdf"

🧠 Bank Statement Processing Pipeline

The bank_main() function orchestrates a 9-step pipeline:

Step Action
1 Extract transactions from PDF via Gemini Vision (parallel across API keys)
2 Calculate Previous Balance, Debit, and Credit from sequential balances
3 Generate monthly credit/debit/net summary
4 Extract beneficiary names from descriptions using AI (parallel batches)
5 Normalize beneficiary names to unify duplicates
6 Group transactions by beneficiary
7 Identify recurring transactions (≥ 3 months)
8 Summarize recurring transactions with averages
9 Analyze transaction types (UPI, ECS, NACH, ACH) by month

🔑 Environment Variables

Backend (back gke/.env)

Variable Required Description
GOOGLE_API_KEY ✅ Primary Gemini API key
GOOGLE_API_KEY_2 ⬜ Second API key for parallel processing
GOOGLE_API_KEY_3 ⬜ Third API key for parallel processing
GOOGLE_API_KEY_4 ⬜ Fourth API key for parallel processing
GCS_BUCKET_NAME ✅ Google Cloud Storage bucket name
GOOGLE_APPLICATION_CREDENTIALS ✅ Path to GCP service account JSON (default: credentials.json)
GROQ_API_KEY ✅ Groq API key for auxiliary text extraction

Frontend (front gke/.env)

Variable Required Description
BACKEND_URL ✅ Backend API URL (default: http://localhost:8000)
GOOGLE_API_KEY ⬜ Gemini API key (if used)
GCS_BUCKET_NAME ⬜ GCS bucket name

🛡️ Security Notes

Caution

  • Never commit credentials.json or .env files to version control.
  • Use credentials.template.json and .env.template as references.
  • The .gitignore files are configured to exclude sensitive files.
  • All API keys and service account paths are loaded from environment variables.

🧰 Tech Stack

Layer Technology
Backend Python, FastAPI, Gunicorn, Uvicorn
Frontend Python, Streamlit
AI/ML Google Gemini (1.5 Pro, 2.5 Pro), Groq, Agno framework
Cloud Storage Google Cloud Storage
PDF Processing pdf2image, pdfplumber, Poppler
Containerization Docker
Data Processing Pandas, NumPy

📄 License

This project is proprietary. All rights reserved.

About

Repository: AI-Powered-Bank-Statement-Credit-Report-Analyzer

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages