Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SEC Filings RAG Assistant

Project Description

  • An intelligent Retrieval-Augmented Generation (RAG) system that enables natural language querying of SEC 10-K filings for comprehensive financial document analysis. Built with Flask backend and powered by Google Gemini AI, this application transforms complex financial documents into accessible insights through an intuitive web interface.

  • The system processes SEC filings from 10 well-known companies across selected industries, creating a searchable knowledge base that allows users to ask questions and receive accurate, contextual answers backed by official financial disclosures.

Key Features

Comprehensive Financial Analysis

  • Multi-Company Coverage: Analyzes SEC 10-K filings from 10 major companies in chosen industries

  • Document Upload & Processing: Seamless PDF upload functionality for additional financial documents

  • Real-time Q&A Interface: Interactive chatbot for natural language queries about financial data

  • Cross-Company Comparisons: Compare financial metrics and disclosures across multiple organizations

Advanced AI-Powered Insights

  • Google Gemini AI Integration: Leverages cutting-edge language models for accurate financial analysis

  • Contextual Responses: Provides detailed answers with source citations from specific SEC filings

  • Risk Assessment: Identifies and explains risk factors mentioned in company filings

  • Financial Trend Analysis: Extracts insights about company performance and future outlook

Professional Web Interface

  • Flask-Powered Backend: Robust server architecture for reliable document processing

  • Responsive Frontend: Clean, user-friendly interface with dashboard, upload, and analytics pages

  • Interactive Dashboard: Visual representation of key financial metrics and insights

  • Document Management: Organized storage and retrieval of processed SEC filings

Intelligent Document Processing

  • RAG Architecture: Retrieval-Augmented Generation for accurate, source-backed responses

  • Vector Database Integration: Efficient document embedding and similarity search capabilities

  • Smart Text Extraction: Processes complex SEC filing structures and formats

  • Multi-format Support: Handles various document types including HTML, XBRL, and PDF formats

Technology Stack

Backend & AI

  1. Flask: Web framework for API and routing

  2. Google Gemini AI: Advanced language model for document analysis

  3. LangChain: RAG framework for document processing and retrieval

  4. Vector Database: Document embedding storage and retrieval

  5. BeautifulSoup: HTML/XBRL parsing for SEC filings

Frontend & Interface

  1. HTML/CSS/JavaScript: Responsive web interface

  2. Bootstrap: Modern UI components and styling

  3. Chart.js: Data visualization for financial metrics

  4. AJAX: Dynamic content loading and user interactions

Data Processing

  1. EDGAR API: SEC filings data acquisition

  2. PDF Processing: Document text extraction and parsing

  3. Natural Language Processing: Text preprocessing and analysis

  4. Document Chunking: Intelligent text splitting for optimal retrieval

Project Structure

sec-filings-rag/
├── app.py                    # Flask application entry point
├── templates/
│   ├── dashboard.html        # Main dashboard interface
│   ├── upload.html          # Document upload page
│   ├── analytics.html       # Analytics and insights page
│   └── base.html            # Base template with navigation
├── static/
│   ├── css/                 # Stylesheets
│   ├── js/                  # JavaScript functionality
│   └── uploads/             # Uploaded document storage
├── src/
│   ├── document_processor.py # SEC filing processing logic
│   ├── rag_engine.py        # RAG implementation with Gemini AI
│   ├── vector_store.py      # Vector database operations
│   └── api_handlers.py      # External API integrations
├── data/
│   ├── processed/           # Processed SEC filings
│   └── embeddings/          # Document vector embeddings
├── config/
│   └── settings.py          # Configuration and API keys
├── requirements.txt         # Python dependencies
└── README.md

Installation & Setup

Prerequisites

  • Python 3.8+
  • Google Gemini AI API key
  • EDGAR API access (optional for additional filings)

Environment Setup

  1. Clone the repository
git clone https://github.com/yourusername/sec-filings-rag.git
cd sec-filings-rag
  1. Create virtual environment
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate
  1. Install dependencies
pip install -r requirements.txt
  1. Configure API keys
# Create .env file
echo "GOOGLE_API_KEY=your_gemini_api_key" > .env
echo "FLASK_SECRET_KEY=your_secret_key" >> .env

Dependencies

Flask>=2.3.0
google-generativeai>=0.3.0
langchain>=0.1.0
langchain-community>=0.0.10
beautifulsoup4>=4.12.0
requests>=2.31.0
pandas>=1.5.0
numpy>=1.24.0
faiss-cpu>=1.7.0
python-dotenv>=1.0.0

Usage

Running the Application

  1. Start the Flask server
python app.py
  1. Access the web interface

Using the RAG System

  • Document Upload

  • Use the upload page to add new SEC filings or financial documents

  • Supported formats: PDF, HTML, TXT

Interactive Q&A

Ask natural language questions about company financials

  • Example queries:
  1. "What are the main risk factors for Apple's business?"

  2. "Compare revenue growth between Microsoft and Google"

  3. "What regulatory challenges does Tesla face?"

Analytics Dashboard

  • View processed document summaries

  • Explore key financial metrics across companies

  • Access comparative analysis tools

Example Queries

  • Financial Performance
  1. "What was the revenue growth rate for [Company] in the last fiscal year?"

  2. "Analyze the profitability trends mentioned in recent filings"

  3. "Compare operating margins between technology companies"

  • Risk Analysis
  1. "What are the primary business risks identified by [Company]?"

  2. "How do companies address cybersecurity concerns in their filings?"

  3. "What regulatory risks affect the pharmaceutical industry?"

  • Strategic Insights
  1. "What expansion plans are mentioned in recent SEC filings?"

  2. "How do companies describe their competitive advantages?"

  3. "What R&D investments are highlighted in 10-K reports?"

Architecture Overview

RAG Pipeline

  • Document Ingestion: SEC filings processed and chunked for optimal retrieval

  • Vector Embedding: Text converted to embeddings using advanced models

  • Query Processing: User questions analyzed and matched with relevant document sections

  • Response Generation: Google Gemini AI generates contextual answers with source citations

Data Flow

SEC Filings → Document Processing → Vector Embeddings → Vector Store
                                                           ↓
User Query → Query Processing → Similarity Search → Context Retrieval
                                                           ↓
Context + Query → Google Gemini AI → Generated Response → User Interface

Security & Compliance

  • API Key Protection: Secure environment variable management

  • Data Privacy: Local document processing with no external data sharing

  • SEC Compliance: Proper attribution and citation of official filings

  • Rate Limiting: API usage optimization and throttling

Future Enhancements

  • Real-time Filing Updates: Automatic processing of new SEC submissions

  • Advanced Analytics: Machine learning insights and trend predictions

  • Multi-language Support: International filing analysis capabilities

  • API Development: RESTful API for third-party integrations

  • Mobile Application: Responsive mobile interface for on-the-go analysis

Contributing

  • Fork the repository
Create a feature branch (git checkout -b feature/financial-analysis)

Commit changes (git commit -m 'Add financial analysis feature')

Push to branch (git push origin feature/financial-analysis)

Open a Pull Request

License

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

Acknowledgments

  • SEC EDGAR Database: Official source for SEC filings and financial disclosures

  • Google Gemini AI: Advanced language model powering the RAG system

  • LangChain Community: Framework and tools for RAG implementation

  • Flask Community: Web framework enabling seamless deployment

Contact


Transforming financial document analysis through AI-powered insights

About

An AI-powered Retrieval-Augmented Generation system for querying SEC 10-K filings. Built with Flask, LangChain, and Google Gemini AI, it enables natural language Q&A, cross-company analysis, and financial insights through an intuitive web app.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages