# oam11/insightdocs architecture

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

- Interactive diagram: https://gitdiagram.com/oam11/insightdocs
- Repository: https://github.com/oam11/insightdocs

## Overview

##### Project type and purpose
- This is a single-page web/RAG application built in Python using Streamlit.
- Purpose: let users upload documents, index them with FAISS, ask questions via Groq’s Gemma2 LLM, and export the Q&A session as a PDF.

##### File structure
- Top-level files only (no separate “frontend” vs. “backend” dirs).
- app.py – the Streamlit main entrypoint (UI + orchestration)
- utils.py – shared helper functions (document I/O, chunking, embedding, PDF exports)
- index.html – optional custom static HTML/CSS used by the Streamlit app
- requirements.txt – Python dependencies (Streamlit, Groq SDK, FAISS, SentenceTransformers, ReportLab, etc.)
- No external microservices or DB clusters defined; FAISS is embedded in-process.

##### README for additional insights
- Core pipeline stages:
a. Document Processing (type detection, chunking, embedding)
b. Indexing with FAISS
c. Question Answering (semantic retrieval + Groq Gemma2 API)
d. Session Management (ID, history)
e. PDF Export (ReportLab)
- External dependencies: Groq API, Sentence Transformers.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Entities
    User((User)):::external

    %% Frontend
    subgraph "Frontend"
        UI["Streamlit UI<br/>(Streamlit)"]:::frontend
    end

    %% In-Process Services
    subgraph "In-Process Services"
        subgraph "Document Processing Pipeline"
            Detector["File-Type Detector"]:::service
            Chunker["Chunker"]:::service
            Embed["Embedding Service<br/>(SentenceTransformers)"]:::service
            FAISS["Vector Store<br/>(FAISS)"]:::data
        end
        subgraph "Q&A Pipeline"
            Retrieval["Retrieval Service"]:::service
            QA["QA Service"]:::service
        end
        Session["Session Manager<br/>(Streamlit State)"]:::service
        PDF["PDF Generator<br/>(ReportLab)"]:::service
    end

    %% External
    ExternalAPI[(Groq Gemma2 API)]:::external

    %% Configuration & Static
    Config["Configuration<br/>(requirements.txt)"]:::config
    Static["Static Assets<br/>(index.html)"]:::static

    %% Data Flows
    User --> UI
    UI --> Detector --> Chunker --> Embed --> FAISS
    UI --> Retrieval
    Retrieval --> FAISS
    Retrieval --> QA --> ExternalAPI
    QA --> UI
    UI --> Session
    Session --> UI
    UI --> PDF --> UI
    UI --> Config
    UI --> Static

    %% Click Events
    click UI "https://github.com/oam11/insightdocs/blob/main/app.py"
    click Detector "https://github.com/oam11/insightdocs/blob/main/utils.py"
    click Chunker "https://github.com/oam11/insightdocs/blob/main/utils.py"
    click Embed "https://github.com/oam11/insightdocs/blob/main/utils.py"
    click FAISS "https://github.com/oam11/insightdocs/blob/main/utils.py"
    click Retrieval "https://github.com/oam11/insightdocs/blob/main/utils.py"
    click QA "https://github.com/oam11/insightdocs/blob/main/utils.py"
    click Session "https://github.com/oam11/insightdocs/blob/main/app.py"
    click PDF "https://github.com/oam11/insightdocs/blob/main/utils.py"
    click Static "https://github.com/oam11/insightdocs/blob/main/index.html"
    click Config "https://github.com/oam11/insightdocs/blob/main/requirements.txt"

    %% Styles
    classDef frontend fill:#ADD8E6,stroke:#333,stroke-width:1px
    classDef service fill:#98FB98,stroke:#333,stroke-width:1px
    classDef data fill:#90EE90,stroke:#333,stroke-width:1px
    classDef external fill:#FFA500,stroke:#333,stroke-width:1px
    classDef config fill:#E0E0E0,stroke:#333,stroke-width:1px
    classDef static fill:#D3D3D3,stroke:#333,stroke-width:1px
```
