LasaK97/End-to-End-Multi-Stage-Intelligent-Financial-Data-Extraction-System

Python

1

10 commits

updated Jun 16, 2025

See the code

README

๐Ÿ“Š Financial Document Extractor

A sophisticated AI-powered financial document processing system that extracts data from annual reports and financial statements while preserving critical semantic relationships between financial line items and their explanatory notes.

License: MIT Python 3.9+ React TypeScript FastAPI

๐Ÿ“‹ Description

The Financial Document Extractor is a comprehensive solution designed to automate the extraction of financial data from PDF documents. This system combines advanced computer vision, natural language processing, and machine learning techniques to deliver highly accurate financial data extraction while maintaining the integrity of note references and contextual relationships.

๐Ÿ’ก Why it exists:

Traditional OCR and basic NLP solutions fail to preserve the critical semantic relationships between financial line items and their explanatory notes. This system addresses that gap by implementing a multi-strategy extraction approach that maintains note reference integrity while delivering high-accuracy financial data extraction.

โœจ Features

๐Ÿ–ฅ๏ธ Backend Processing Engine

  • ๐Ÿง  Multi-Strategy LLM Extraction: Adaptive fallback mechanisms with three-tier processing strategy
  • ๐Ÿ“ Layout-Aware Document Understanding: LayoutLMv3 + Table Transformer for spatial context preservation
  • ๐Ÿ”— Note Reference Intelligence: Comprehensive pattern matching and validation system
  • ๐Ÿ’ฐ Financial Metadata Detection: Currency and rounding scale intelligence
  • โœ… Quality Assurance Framework: Multi-level validation with confidence scoring
  • โšก Real-time Processing Status: WebSocket-based status monitoring
  • ๐Ÿ“ฆ Batch Processing: Efficient multi-document processing capabilities

๐ŸŽจ Frontend Interface

  • ๐Ÿ“ค Drag & Drop Upload: Intuitive file upload with real-time progress tracking
  • ๐Ÿ“Š Interactive Dashboard: System health monitoring and key metrics display
  • ๐Ÿ“ Document Management: Grid/list views with search and filtering capabilities
  • ๐Ÿ“ˆ Results Visualization: Financial statement viewer with quality indicators
  • ๐Ÿ“‰ Analytics Dashboard: Processing trends and quality distribution charts
  • ๐Ÿ’พ Export Functionality: Multiple format support (JSON, CSV)
  • ๐Ÿ”„ Real-time Updates: Live status polling and notifications

โš™๏ธ Technical Capabilities

  • ๐Ÿ”’ Offline Processing: Complete local operation without external dependencies
  • ๐Ÿ“ Scalable Architecture: Horizontal scaling with intelligent parallelization
  • ๐Ÿ› ๏ธ Error Recovery: Robust error handling with retry mechanisms
  • โœ”๏ธ Data Validation: Semantic validation and business rule compliance
  • ๐Ÿ“Š Performance Monitoring: Comprehensive metrics and logging

๐Ÿš€ Installation

๐Ÿ“‹ Prerequisites

  • ๐Ÿ Python: 3.9 or higher
  • ๐ŸŸข Node.js: 16.0 or higher
  • ๐Ÿ—„๏ธ MongoDB: 5.0 or higher
  • ๐Ÿ’พ System RAM: 8-16GB (for model loading)
  • ๐Ÿ’ฟ Storage: 10GB+ free space (for models and data)

๐Ÿ–ฅ๏ธ Backend Setup

  1. ๐Ÿ“ฅ Clone the repository:
git clone https://github.com/LasaK97/End-to-End-Multi-Stage-Intelligent-Financial-Data-Extraction-System.git
cd End-to-End-Multi-Stage-Intelligent-Financial-Data-Extraction-System/backend
  1. ๐Ÿ”ง Create and activate virtual environment:
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate
  1. ๐Ÿ“ฆ Install Python dependencies:
pip install -r requirements.txt
  1. โฌ‡๏ธ Download required models:
python scripts/download_models.py
  1. โš™๏ธ Set up environment variables:
cp .env.example .env
# Edit .env with following configurations (see Backend Configuration section below)
  1. ๐Ÿš€ Start the backend server:
python -m uvicorn src.api:app --reload --host 0.0.0.0 --port 8000

๐ŸŽจ Frontend Setup

  1. ๐Ÿ“‚ Navigate to frontend directory:
cd ../frontend
  1. ๐Ÿ“ฆ Install Node.js dependencies:
npm install
  1. โš™๏ธ Set up environment variables:
cp .env.local.example .env.local
# Edit .env.local with following configuration (see Frontend Configuration section below)
  1. ๐Ÿš€ Start the development server:
npm run dev

๐ŸŒ Access Points

The application will be available at:

ServiceURLDescription
๐ŸŽจ Frontendhttp://localhost:5173Main user interface
๐Ÿ”ง Backend APIhttp://localhost:8000REST API endpoints
๐Ÿ“š API Docshttp://localhost:8000/docsInteractive API documentation

๐ŸŽฏ Usage

๐Ÿš€ Quick Start

  1. ๐Ÿ“ค Upload Documents

    • Navigate to the Upload page
    • Drag and drop PDF financial documents or click to browse
    • Wait for upload confirmation
  2. โš™๏ธ Process Documents

    • Click "Extract Data" to start batch processing
    • Monitor real-time progress in the processing queue
    • View completion status and any error messages
  3. ๐Ÿ“Š View Results

    • Navigate to Documents page to see processed files
    • Click "View Results" to see extracted financial data
    • Use the export menu to download results in various formats

โš™๏ธ Configuration

๐Ÿ”ง Environment Variables

๐Ÿ–ฅ๏ธ Backend (.env)

# ๐Ÿ—„๏ธ Database Configuration
MONGODB_URL=mongodb://localhost:27017/findoc_extractor
MONGODB_DB_NAME=findoc_extractor

# ๐Ÿค– Model Configuration
MODELS_PATH=./models
CACHE_SIZE=1000

# โš™๏ธ Processing Configuration
MAX_FILE_SIZE_MB=50
BATCH_SIZE=5
WORKER_THREADS=4

# ๐ŸŒ API Configuration
API_HOST=0.0.0.0
API_PORT=8000
CORS_ORIGINS=["http://localhost:3000"]

# ๐Ÿ“ Logging
LOG_LEVEL=INFO
LOG_FILE=./logs/app.log

๐ŸŽจ Frontend (.env.local)

# ๐ŸŒ API Configuration
VITE_API_BASE_URL=http://localhost:8000
VITE_WS_URL=ws://localhost:8000/ws

# โš™๏ธ Application Configuration
VITE_ENVIRONMENT=development
VITE_MAX_FILE_SIZE_MB=50

# ๐Ÿš€ Feature Flags
VITE_ENABLE_ANALYTICS=true
VITE_ENABLE_EXPORT=true

๐Ÿค– Model Configuration

The system requires several pre-trained models that are automatically downloaded:

  • ๐Ÿ“ LayoutLMv3: For document layout understanding
  • ๐Ÿ“Š Table Transformer: For table detection and structure recognition
  • ๐Ÿง  Mistral-7B-Instruct: For intelligent text extraction

Model storage and configuration can be customized in src/config.py.

๐Ÿ› Reporting Issues

Please use the GitHub issue tracker to report bugs or request features. Include:

  • ๐Ÿ“ Detailed description of the issue
  • ๐Ÿ”„ Steps to reproduce
  • โœ… Expected vs actual behavior
  • ๐Ÿ’ป Environment details (OS, Python version, etc.)

๐Ÿ“ธ Screenshots / Demo

Dashboard Overview

Dashboard Main dashboard showing system health, processing statistics, and recent activity

Document Upload Interface

Upload Interface Drag-and-drop file upload with real-time progress tracking

Results Visualization

Results View Financial statement viewer with extracted data and quality indicators

๐Ÿ—๏ธ Architecture Overview

The system follows a modern microservices architecture with intelligent data processing pipelines:

๐Ÿ›๏ธ System Architecture (Backend)

System Architecture Complete backend system architecture showing all components and their interactions

๐Ÿ”„ Data Flow Architecture (Backend)

Data Flow Complete data flow showing the multi-stage processing pipeline from document upload to structured output

๐Ÿง  Extraction Strategy Framework (Backend)

Extraction Strategy Multi-strategy adaptive extraction approach with progressive fallback mechanisms

๐Ÿ”— Note Reference Intelligence (Backend)

Note Reference Advanced pattern recognition system for maintaining financial line item to note relationships

๐Ÿ› ๏ธ Technology Stack

ComponentTechnologyPurpose
๐ŸŽจ FrontendReact + TypeScriptModern UI with type safety
โšก Build ToolViteFast development and optimized builds
๐ŸŽฏ BackendFastAPIHigh-performance async API
๐Ÿ—„๏ธ DatabaseMongoDBDocument storage and metadata
๐Ÿค– AI ModelsLayoutLMv3, Mistral-7BDocument understanding and extraction
๐Ÿ“ก CommunicationREST + WebSocketAPI and real-time updates

๐Ÿ“Š Performance Characteristics

  • Processing Speed: 30-120 seconds per document
  • Accuracy: 85-95% line item extraction rate
  • Metadata Accuracy: 90-98% for currency and scale detection
  • Note Reference Accuracy: 80-90% successful mapping
  • Scalability: Supports horizontal scaling with load balancing

๐Ÿ“ž Contact / Support

  • Project Maintainer: Lasantha Kulasooriya
  • Issues: Use GitHub Issues for bug reports and feature requests

๐Ÿ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

LasaK97/End-to-End-Multi-Stage-Intelligent-Financial-Data-Extraction-System

Python

1

10 commits

updated Jun 16, 2025

See the code

README

๐Ÿ“Š Financial Document Extractor

A sophisticated AI-powered financial document processing system that extracts data from annual reports and financial statements while preserving critical semantic relationships between financial line items and their explanatory notes.

License: MIT Python 3.9+ React TypeScript FastAPI

๐Ÿ“‹ Description

The Financial Document Extractor is a comprehensive solution designed to automate the extraction of financial data from PDF documents. This system combines advanced computer vision, natural language processing, and machine learning techniques to deliver highly accurate financial data extraction while maintaining the integrity of note references and contextual relationships.

๐Ÿ’ก Why it exists:

Traditional OCR and basic NLP solutions fail to preserve the critical semantic relationships between financial line items and their explanatory notes. This system addresses that gap by implementing a multi-strategy extraction approach that maintains note reference integrity while delivering high-accuracy financial data extraction.

โœจ Features

๐Ÿ–ฅ๏ธ Backend Processing Engine

  • ๐Ÿง  Multi-Strategy LLM Extraction: Adaptive fallback mechanisms with three-tier processing strategy
  • ๐Ÿ“ Layout-Aware Document Understanding: LayoutLMv3 + Table Transformer for spatial context preservation
  • ๐Ÿ”— Note Reference Intelligence: Comprehensive pattern matching and validation system
  • ๐Ÿ’ฐ Financial Metadata Detection: Currency and rounding scale intelligence
  • โœ… Quality Assurance Framework: Multi-level validation with confidence scoring
  • โšก Real-time Processing Status: WebSocket-based status monitoring
  • ๐Ÿ“ฆ Batch Processing: Efficient multi-document processing capabilities

๐ŸŽจ Frontend Interface

  • ๐Ÿ“ค Drag & Drop Upload: Intuitive file upload with real-time progress tracking
  • ๐Ÿ“Š Interactive Dashboard: System health monitoring and key metrics display
  • ๐Ÿ“ Document Management: Grid/list views with search and filtering capabilities
  • ๐Ÿ“ˆ Results Visualization: Financial statement viewer with quality indicators
  • ๐Ÿ“‰ Analytics Dashboard: Processing trends and quality distribution charts
  • ๐Ÿ’พ Export Functionality: Multiple format support (JSON, CSV)
  • ๐Ÿ”„ Real-time Updates: Live status polling and notifications

โš™๏ธ Technical Capabilities

  • ๐Ÿ”’ Offline Processing: Complete local operation without external dependencies
  • ๐Ÿ“ Scalable Architecture: Horizontal scaling with intelligent parallelization
  • ๐Ÿ› ๏ธ Error Recovery: Robust error handling with retry mechanisms
  • โœ”๏ธ Data Validation: Semantic validation and business rule compliance
  • ๐Ÿ“Š Performance Monitoring: Comprehensive metrics and logging

๐Ÿš€ Installation

๐Ÿ“‹ Prerequisites

  • ๐Ÿ Python: 3.9 or higher
  • ๐ŸŸข Node.js: 16.0 or higher
  • ๐Ÿ—„๏ธ MongoDB: 5.0 or higher
  • ๐Ÿ’พ System RAM: 8-16GB (for model loading)
  • ๐Ÿ’ฟ Storage: 10GB+ free space (for models and data)

๐Ÿ–ฅ๏ธ Backend Setup

  1. ๐Ÿ“ฅ Clone the repository:
git clone https://github.com/LasaK97/End-to-End-Multi-Stage-Intelligent-Financial-Data-Extraction-System.git
cd End-to-End-Multi-Stage-Intelligent-Financial-Data-Extraction-System/backend
  1. ๐Ÿ”ง Create and activate virtual environment:
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate
  1. ๐Ÿ“ฆ Install Python dependencies:
pip install -r requirements.txt
  1. โฌ‡๏ธ Download required models:
python scripts/download_models.py
  1. โš™๏ธ Set up environment variables:
cp .env.example .env
# Edit .env with following configurations (see Backend Configuration section below)
  1. ๐Ÿš€ Start the backend server:
python -m uvicorn src.api:app --reload --host 0.0.0.0 --port 8000

๐ŸŽจ Frontend Setup

  1. ๐Ÿ“‚ Navigate to frontend directory:
cd ../frontend
  1. ๐Ÿ“ฆ Install Node.js dependencies:
npm install
  1. โš™๏ธ Set up environment variables:
cp .env.local.example .env.local
# Edit .env.local with following configuration (see Frontend Configuration section below)
  1. ๐Ÿš€ Start the development server:
npm run dev

๐ŸŒ Access Points

The application will be available at:

ServiceURLDescription
๐ŸŽจ Frontendhttp://localhost:5173Main user interface
๐Ÿ”ง Backend APIhttp://localhost:8000REST API endpoints
๐Ÿ“š API Docshttp://localhost:8000/docsInteractive API documentation

๐ŸŽฏ Usage

๐Ÿš€ Quick Start

  1. ๐Ÿ“ค Upload Documents

    • Navigate to the Upload page
    • Drag and drop PDF financial documents or click to browse
    • Wait for upload confirmation
  2. โš™๏ธ Process Documents

    • Click "Extract Data" to start batch processing
    • Monitor real-time progress in the processing queue
    • View completion status and any error messages
  3. ๐Ÿ“Š View Results

    • Navigate to Documents page to see processed files
    • Click "View Results" to see extracted financial data
    • Use the export menu to download results in various formats

โš™๏ธ Configuration

๐Ÿ”ง Environment Variables

๐Ÿ–ฅ๏ธ Backend (.env)

# ๐Ÿ—„๏ธ Database Configuration
MONGODB_URL=mongodb://localhost:27017/findoc_extractor
MONGODB_DB_NAME=findoc_extractor

# ๐Ÿค– Model Configuration
MODELS_PATH=./models
CACHE_SIZE=1000

# โš™๏ธ Processing Configuration
MAX_FILE_SIZE_MB=50
BATCH_SIZE=5
WORKER_THREADS=4

# ๐ŸŒ API Configuration
API_HOST=0.0.0.0
API_PORT=8000
CORS_ORIGINS=["http://localhost:3000"]

# ๐Ÿ“ Logging
LOG_LEVEL=INFO
LOG_FILE=./logs/app.log

๐ŸŽจ Frontend (.env.local)

# ๐ŸŒ API Configuration
VITE_API_BASE_URL=http://localhost:8000
VITE_WS_URL=ws://localhost:8000/ws

# โš™๏ธ Application Configuration
VITE_ENVIRONMENT=development
VITE_MAX_FILE_SIZE_MB=50

# ๐Ÿš€ Feature Flags
VITE_ENABLE_ANALYTICS=true
VITE_ENABLE_EXPORT=true

๐Ÿค– Model Configuration

The system requires several pre-trained models that are automatically downloaded:

  • ๐Ÿ“ LayoutLMv3: For document layout understanding
  • ๐Ÿ“Š Table Transformer: For table detection and structure recognition
  • ๐Ÿง  Mistral-7B-Instruct: For intelligent text extraction

Model storage and configuration can be customized in src/config.py.

๐Ÿ› Reporting Issues

Please use the GitHub issue tracker to report bugs or request features. Include:

  • ๐Ÿ“ Detailed description of the issue
  • ๐Ÿ”„ Steps to reproduce
  • โœ… Expected vs actual behavior
  • ๐Ÿ’ป Environment details (OS, Python version, etc.)

๐Ÿ“ธ Screenshots / Demo

Dashboard Overview

Dashboard Main dashboard showing system health, processing statistics, and recent activity

Document Upload Interface

Upload Interface Drag-and-drop file upload with real-time progress tracking

Results Visualization

Results View Financial statement viewer with extracted data and quality indicators

๐Ÿ—๏ธ Architecture Overview

The system follows a modern microservices architecture with intelligent data processing pipelines:

๐Ÿ›๏ธ System Architecture (Backend)

System Architecture Complete backend system architecture showing all components and their interactions

๐Ÿ”„ Data Flow Architecture (Backend)

Data Flow Complete data flow showing the multi-stage processing pipeline from document upload to structured output

๐Ÿง  Extraction Strategy Framework (Backend)

Extraction Strategy Multi-strategy adaptive extraction approach with progressive fallback mechanisms

๐Ÿ”— Note Reference Intelligence (Backend)

Note Reference Advanced pattern recognition system for maintaining financial line item to note relationships

๐Ÿ› ๏ธ Technology Stack

ComponentTechnologyPurpose
๐ŸŽจ FrontendReact + TypeScriptModern UI with type safety
โšก Build ToolViteFast development and optimized builds
๐ŸŽฏ BackendFastAPIHigh-performance async API
๐Ÿ—„๏ธ DatabaseMongoDBDocument storage and metadata
๐Ÿค– AI ModelsLayoutLMv3, Mistral-7BDocument understanding and extraction
๐Ÿ“ก CommunicationREST + WebSocketAPI and real-time updates

๐Ÿ“Š Performance Characteristics

  • Processing Speed: 30-120 seconds per document
  • Accuracy: 85-95% line item extraction rate
  • Metadata Accuracy: 90-98% for currency and scale detection
  • Note Reference Accuracy: 80-90% successful mapping
  • Scalability: Supports horizontal scaling with load balancing

๐Ÿ“ž Contact / Support

  • Project Maintainer: Lasantha Kulasooriya
  • Issues: Use GitHub Issues for bug reports and feature requests

๐Ÿ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.