# remsecond/evidenceai architecture

> Architecture diagram of the GitHub repository remsecond/evidenceai, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-14). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/remsecond/evidenceai
- Repository: https://github.com/remsecond/evidenceai

## Overview

##### Main System Components

a) Input Layer
- PDF Document Intake
- Google Sheets Integration
- Email Processing Interface

b) Processing Layer
- PDF Processor
- Chunking Engine
- Multi-Model LLM Processing Hub
- Document Router
- Document Analyzer

c) Storage & Output Layer
- Local Storage System
- Google Sheets Output
- AI Model Outputs
- Monitoring & Reporting

##### Component Relationships & Data Flow

a) Input Flow:
**PDF/Email Input → Document Router → PDF Processor**
- ↓
- Chunking Engine

b) Processing Flow:
**Chunking Engine → Multi-Model LLM Hub → Document Analyzer**
- ↓
- [Model Processors]
- Claude
- DeepSeek
- GPT-4
- NotebookLM
- Sonnet

c) Output Flow:
**Document Analyzer → Local Storage**
- → Google Sheets
- → Monitoring System

##### Component Details

For each major component, show:
- Input/output formats
- Key configurations
- Service dependencies
- Processing stages

##### Integration Points

Highlight:
- Google OAuth integration
- LLM API connections
- Storage interfaces
- Monitoring hooks

##### Technical Stack Indicators

Technology usage:
- Node.js runtime
- PDF processing libraries
- Google API integration
- Testing framework
- Docker containerization

##### Monitoring & Logging

Include:
- Grafana dashboard connection
- Prometheus metrics
- Custom monitoring reporters
- Log aggregation points

Key architectural patterns to emphasize:
- Pipeline processing pattern
- Service-oriented architecture
- Multi-model processing strategy
- Monitoring and observability

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Styles and classes
    classDef input fill:#a8d1f0,stroke:#000
    classDef processing fill:#90EE90,stroke:#000
    classDef storage fill:#FFE5B4,stroke:#000
    classDef monitoring fill:#FFB6C1,stroke:#000
    classDef external fill:#DDA0DD,stroke:#000
    classDef model fill:#E6E6FA,stroke:#000

    %% Input Layer
    subgraph Input
        PDF[PDF Document]:::input
        subgraph PDFDetails
            PDFValidation[File Validation]
            PDFParsing[PDF Parsing]
            MetadataExtraction[Metadata Extraction]
        end
        
        Email[Email Interface]:::input
        subgraph EmailDetails
            EmailParsing[Email Body Parsing]
            AttachmentHandling[Attachment Processing]
            HeaderAnalysis[Header Analysis]
        end
        
        Sheets[Google Sheets Input]:::input
        subgraph SheetsDetails
            DataValidation[Data Validation]
            FormatCheck[Format Checking]
            RangeSelection[Range Selection]
        end
    end

    %% Processing Layer
    subgraph Processing
        Router[Document Router]:::processing
        subgraph RouterDetails
            TypeDetection[Document Type Detection]
            PriorityAssignment[Priority Assignment]
            RouteSelection[Route Selection]
        end

        PDFProc[PDF Processor]:::processing
        subgraph PDFProcDetails
            TextExtraction[Text Extraction]
            ImageProcessing[Image Processing]
            StructureAnalysis[Structure Analysis]
        end

        Chunking[Chunking Engine]:::processing
        subgraph ChunkingDetails
            Tokenization[Tokenization]
            SizeOptimization[Size Optimization]
            ChunkOverlap[Chunk Overlap]
        end

        LLMHub[Multi-Model LLM Hub]:::processing
        DocAnalyzer[Document Analyzer]:::processing
    end

    %% Model Layer
    subgraph Models
        Claude[Claude]:::model
        DeepSeek[DeepSeek]:::model
        GPT4[GPT-4]:::model
        NotebookLM[NotebookLM]:::model
        Sonnet[Sonnet]:::model
    end

    %% Storage & Output Layer
    subgraph Output
        LocalStore[Local Storage]:::storage
        subgraph StorageDetails
            FileSystem[File System]
            Cache[Cache Layer]
            Backup[Backup System]
        end

        SheetOut[Google Sheets Output]:::storage
        Monitor[Monitoring System]:::monitoring
    end

    %% Connections
    PDF --> PDFDetails --> Router
    Email --> EmailDetails --> Router
    Sheets --> SheetsDetails --> Router
    Router --> RouterDetails --> PDFProc
    PDFProc --> PDFProcDetails --> Chunking
    Chunking --> ChunkingDetails --> LLMHub
    LLMHub --> Claude & DeepSeek & GPT4 & NotebookLM & Sonnet
    Claude & DeepSeek & GPT4 & NotebookLM & Sonnet --> DocAnalyzer
    DocAnalyzer --> LocalStore --> StorageDetails
    DocAnalyzer --> SheetOut
    DocAnalyzer --> Monitor

    %% Click events for component mapping
    click PDFProc "https://github.com/remsecond/evidenceai/blob/main/src/services/pdf-processor.js"
    click Email "https://github.com/remsecond/evidenceai/blob/main/src/services/email-processing.js"
    click Sheets "https://github.com/remsecond/evidenceai/blob/main/src/services/google-sheets.js"
    click Router "https://github.com/remsecond/evidenceai/blob/main/src/services/document-router.js"
    click DocAnalyzer "https://github.com/remsecond/evidenceai/blob/main/src/services/document-analyzer.js"
    click LLMHub "https://github.com/remsecond/evidenceai/blob/main/src/services/multi-llm-processor.js"
    click Models "https://github.com/remsecond/evidenceai/tree/main/src/services/models/"
    click LocalStore "https://github.com/remsecond/evidenceai/blob/main/src/services/local-storage.js"
    click Monitor "https://github.com/remsecond/evidenceai/blob/main/src/services/monitoring.js"

    %% Legend
    subgraph Legend
        L1[Input Components]:::input
        L2[Processing Components]:::processing
        L3[Storage Components]:::storage
        L4[Monitoring Components]:::monitoring
        L5[External Services]:::external
        L6[Model Components]:::model
    end
```
