Convert bank statements into a downloadable finance report with AI-powered parsing, categorization, and anomaly detection.
- Accepts
.pdfor.csvbank statements via API upload. - Extracts and normalizes transactions.
- Categorizes spending with Google Gemini (with rule-based fallback).
- Detects unusual transactions using Isolation Forest.
- Returns a generated PDF finance report.
- Python, FastAPI, Uvicorn
- Google Gemini API (
google-generativeai) pdfplumber,pandas,scikit-learnreportlabfor PDF report generation
app/
main.py # FastAPI entrypoint
routes/
upload.py # POST /upload endpoint
services/
extractor.py # PDF text extraction
gemini_parser.py # LLM parsing + categorization
categorizer.py # Fallback categorization
anomaly.py # Anomaly detection
report_generator.py # Final PDF report generation
utils/
csv_parser.py # CSV parsing helpers
git clone https://github.com/<your-username>/<your-repo>.git
cd <your-repo>python -m venv .venvActivate it:
- Windows (PowerShell):
.venv\Scripts\Activate.ps1 - macOS/Linux:
source .venv/bin/activate
pip install -r requirements.txtcopy .env.example .env # Windows
# cp .env.example .env # macOS/LinuxSet at least:
GEMINI_API_KEY=your_api_key_here
API_BASE_URL=http://localhost:8000uvicorn app.main:app --reload --port 8000- Health check:
GET http://localhost:8000/ - Swagger docs:
http://localhost:8000/docs
curl -X POST "http://localhost:8000/upload" ^
-H "accept: application/pdf" ^
-H "Content-Type: multipart/form-data" ^
-F "file=@sample_statement.pdf" ^
--output finance_report.pdfNotes:
- Supported file types:
.pdf,.csv - Response type:
application/pdf - Output filename is auto-generated on the server response header
Environment variables (.env):
GEMINI_API_KEY: required for Gemini parsing/categorizationDATABASE_URL: currently reserved for local SQLite integrationsAPI_BASE_URL: used by clients/tools that call the API
PDF parsing failed: verify PDF is text-extractable and Gemini key is valid.Unsupported file type: upload only.pdfor.csv.- Empty/poor categorization: Gemini fallback may trigger if API quota/key fails.
- Never commit
.envor API keys. - Use a restricted-scope API key in production.
- CORS is currently open (
allow_origins=["*"]) for local development.
- Add persistent transaction storage and history.
- Add authentication and per-user workspaces.
- Add test suite coverage for route and service layers.
- Add a Streamlit or web dashboard for interactive analysis.
Add your preferred license in a LICENSE file (MIT is a common choice).