🏦 AI-powered SME loan analysis tool for BFPME Tunisia — GPT-4o extraction, Plotly charts, and 100% offline failsafe mode.
> **An AI-powered document processing assistant for BFPME credit risk officers evaluating SME loan applications and business plans (_Plans d'affaires_) in Tunisia.**
---
## 🎯 What is BFPME AI Credit Agent?
The **Banque de Financement des Petites et Moyennes Entreprises (BFPME)** is Tunisia's specialized bank for SME financing. Credit risk officers must manually analyze dense business plans to extract key financial data and assess loan viability.
This tool **automates that process** — upload any business plan (`.txt` or `.pdf`), and the app instantly extracts all critical Tunisian financial variables, visualizes the investment structure, and lets you interrogate the document through a smart AI chatbot.
---
## ✨ Features
### 📊 Tab 1 — Executive Dashboard
- Auto-extracted KPI cards (Coût Total, Crédit BFPME, TRI, VAN, Délai de Récupération, Emplois)
- Automatic **risk rating** (FAIBLE / MODÉRÉ / ÉLEVÉ) based on TRI and payback period
- Financial projections table (An 1 → An 3)
- Raw document text viewer
### 📈 Tab 2 — Financial Visualizations
- **Donut chart** — Financing structure breakdown (Apport, FOPRODI, SICAR, BFPME)
- **Bar chart** — Investment vs. financing comparison
- **CA Evolution** — Revenue projections over 3 years
- **TRI Gauge** — Internal rate of return vs. cost of capital
- **Guarantee Coverage** chart vs. BFPME credit
### 🤖 Tab 3 — AI Chatbot
- Quick-question chips for instant answers
- **Live mode:** GPT-4o powered contextual responses
- **Failsafe mode:** Semantic rule-based dictionary with banking-grade answers
- Covers: risks, TRI, VAN, guarantees, payback, employment, recommendations
### ⚙️ Sidebar Controls
- 📂 File uploader (`.txt` / `.pdf`)
- 🔑 Optional OpenAI API key input
- 🟢 / 🟡 Live engine status indicator
- 🌿 One-click **sample project** loader (Agritech Sidi Bouzid)
---
## 🔄 Dual-Engine Architecture
```
┌─────────────────────────────────────────────────────────┐
│ BFPME AI Credit Agent …