Skip to content

Repository files navigation

DocInsights: AI-Powered Document Analysis Platform

Introduction & Goals

This project delivers a Retrieval-Augmented Generation (RAG) document analysis platform. It automates the parsing of unstructured document data into structured, actionable insights using Python, allowing users to query and interact with their documents efficiently.

  • What data you are working with: Unstructured text and raw document files.

  • What tools you are using: Python, pytest for test-driven development, and custom data extractors.

  • What you are doing with these tools: Building a robust RAG pipeline that processes raw documents, extracts relevant context, applies helper logic, and serves the analyzed results through a user interface.

Goal 1: Accurately extract and chunk information from various document formats. How I know it worked: The extractors.py module successfully parses target documents, validated by a comprehensive suite of tests in test_extractors.py.

Goal 2: Ensure reliable data transformation and API routing. How I know it worked: All data transformations and routes pass 100% of their test cases via test_helpers.py and test_routes.py.

Architecture

Contents

The Data Set

  • Explain the data set: The system processes raw documents, which often contain unstructured and messy text data.

  • Why did you choose it: Documents are the primary source of enterprise knowledge, making efficient retrieval and extraction highly valuable.

  • What is problematic: Documents lack a consistent schema, meaning extraction logic must be highly resilient to formatting edge cases and artifacts.

  • What do you want to do with it: Normalize the raw text, embed it for retrieval, and extract structured metadata and insights.

How much data is it

Assuming the pipeline processes 1,000 documents a day, with an average file size of 2 MB, the daily ingestion volume is roughly 2 GB. Over a year (250 working days), this amounts to 500 GB of raw document data that needs to be parsed, chunked, and embedded into a vector space for the RAG pipeline.

Constraints

  • Compute: Local processing utilizing standard Python runtime environments.

  • Data you do not control: The varying formats, quality, and schemas of uploaded documents.

  • Time: Engineered as a streamlined solution focusing on extraction accuracy and UI usability.

Used Tools

Connect

  • API Routes (main.py): Acts as the ingestion point for receiving document payloads and handling queries.

Processing

  • Python Extraction Engine (extractors.py & helpers.py): Core logic for parsing, cleaning, and preparing document chunks for retrieval.

  • Pytest (tests/): Ensures high reliability by verifying extractors, helpers, and routes against edge cases.

Storage

  • Data Models (models.py): Defines the strict data structures and schemas used to hold the extracted information in memory before serving.

Visualization

  • User Interface (ui.py): A frontend component that allows users to upload documents and visually consume the extracted insights and RAG query results.

Pipelines

Batch Processing

The pipeline operates as a structured batch processor for individual files:

  1. Ingestion: Documents are received via the application routes.

  2. Extraction: extractors.py isolates the relevant text and metadata from the raw file.

  3. Transformation: helpers.py cleans and normalizes the extracted data into semantic chunks.

  4. Structuring: Data is mapped to schemas defined in models.py for analysis.

Visualizations

The output is presented through the interface defined in ui.py, allowing users to interact directly with the analyzed document data.

Demo

(Add a GIF or screenshot of the ui.py interface successfully extracting data and answering queries from a sample document here.)

What Breaks

  • Complex Formatting: Highly irregular documents, scanned images without OCR, or corrupted files will likely break the parsing logic in extractors.py.

  • Fix: Expand the test coverage in test_extractors.py and implement fallback regex patterns.

  • High Concurrency: Processing massive batches of heavy PDFs simultaneously could exhaust local memory.

  • Fix: Implement a message queue (like Celery or RabbitMQ) to handle document processing asynchronously.

Conclusion

This project successfully demonstrates a reliable, test-driven pipeline for unstructured document analysis. By modularizing the extraction, data modeling, and routing logic, the architecture remains clean and highly extensible. Ensuring strict test coverage across all components was key to handling the unpredictable nature of document data.

Follow Me On

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages