Skip to content

AI-powered financial document analysis and reporting API using FastAPI and Google Gemini

Notifications You must be signed in to change notification settings

Koolvansh07/financial-document-analyzer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Financial Document Analysis API

A Python-based REST API deployed on Google Cloud Platform (GCP) that analyzes financial documents (credit card statements, tax returns, bank statements) to provide insights, detect anomalies, and generate comprehensive PDF reports.

Features

  • Multi-format Document Processing: Supports PDF, images (JPG, PNG), Excel (XLSX), and CSV files
  • AI-Powered Data Extraction: Uses Google Gemini API for intelligent document parsing
  • Comprehensive Financial Analysis:
    • Category-wise spending breakdown
    • Month-over-month trends
    • Suspicious activity detection
    • Personalized recommendations
  • Professional PDF Reports: Generates detailed reports with charts and visualizations
  • Async Processing: Handles concurrent requests efficiently
  • Enterprise Security: End-to-end encryption, PII masking, auto-deletion

Tech Stack

  • Framework: FastAPI
  • AI/ML: Google Gemini API
  • PDF Generation: ReportLab + Matplotlib/Seaborn
  • Deployment: Google Cloud Run
  • Authentication: API Key + OAuth2

Quick Start

Prerequisites

  • Python 3.10+
  • Google Cloud account
  • Gemini API key

Installation

pip install -r requirements.txt

Configuration

Create a .env file:

GEMINI_API_KEY=your_gemini_api_key
GCP_PROJECT_ID=your_project_id
ENVIRONMENT=development

Run Locally

uvicorn app.main:app --reload --port 8000

Deploy to Cloud Run

gcloud run deploy financial-analyzer \
  --source . \
  --platform managed \
  --region us-central1 \
  --allow-unauthenticated

API Endpoints

POST /analyze

Upload and analyze a financial document

Request:

curl -X POST "http://localhost:8000/analyze" \
  -H "X-API-Key: your_api_key" \
  -F "file=@statement.pdf"

Response:

{
  "job_id": "abc123",
  "status": "processing",
  "message": "Document uploaded successfully"
}

GET /status/{job_id}

Check processing status

Response:

{
  "job_id": "abc123",
  "status": "completed",
  "progress": 100
}

GET /report/{job_id}

Download generated PDF report

Returns PDF file or cloud storage URL

Architecture

┌─────────────┐
│   Client    │
└──────┬──────┘
       │
       ▼
┌─────────────────┐
│   FastAPI App   │
└────────┬────────┘
         │
    ┌────┴────┐
    ▼         ▼
┌────────┐ ┌──────────┐
│ Gemini │ │  Cloud   │
│  API   │ │ Storage  │
└────────┘ └──────────┘

Security

  • End-to-end encryption for uploads
  • PII data masking (credit card numbers, SSNs)
  • Temporary storage with auto-deletion after 24 hours
  • Rate limiting (100 requests/hour per API key)
  • API key authentication

Performance

  • Processes documents up to 50 pages
  • Report generation: 30-60 seconds
  • Concurrent request handling with async processing
  • Auto-scaling on Cloud Run

License

MIT License

About

AI-powered financial document analysis and reporting API using FastAPI and Google Gemini

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published