# shreyasgm/gl_deep_search architecture

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

- Interactive diagram: https://gitdiagram.com/shreyasgm/gl_deep_search
- Repository: https://github.com/shreyasgm/gl_deep_search

## Overview

##### Project type and purpose
- This is a full-stack, containerized Agentic RAG system (“Growth Lab Deep Search”) with three main pillars:
a) An ETL pipeline that harvests, OCRs, and embeds Growth Lab publications and academic papers.
b) A backend service (FastAPI + LangGraph) exposing a question-answer API powered by vector embeddings and a retriever.
c) A lightweight frontend (Streamlit/Chainlit) for user interaction.

##### File structure
- Top-level:
- .github/workflows → CI/CD (ETL, service, frontend).
- backend/etl → ETL microservice (scrapers, processors, storage adapters).
- backend/storage → abstractions for file & cloud storage.
- backend/service → FastAPI + LangGraph service with routes, models, retriever tools.
- frontend → Streamlit UI.
- scripts/ → Dev & deployment helpers (setup, deploy, storage switch).
- Notice container configs (Dockerfile, docker‐compose.yml) in each subfolder and root.
- GitHub Actions yml files schedule ETL runs and deployments.

##### README insights
- CI: GitHub Actions triggers testing, builds containers, deploys to Cloud Run.
- ETL orchestration: local HPC (SLURM) for bulk, Cloud Run for incremental scraping.
- Vector DB: Qdrant; storage: Google Cloud Storage; RAG orchestration: LangGraph.
- API: FastAPI, Python 3.12; Frontend: Streamlit; Deployment: GCP Cloud Run.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External Data Sources
    subgraph "External Data Sources" 
        direction TB
        GL_SITE["Growth Lab Website"]:::external
        OPENALEX_API["OpenAlex API"]:::external
    end

    %% ETL Layer
    subgraph "ETL Pipeline" 
        direction TB
        subgraph "Scrapers" 
            direction TB
            GL_SCRAPER["GrowthLab Scraper"]:::ingestion
            OA_SCRAPER["OpenAlex Scraper"]:::ingestion
        end
        subgraph "ETL Scripts" 
            direction TB
            DL_SCRIPT["GL File Downloader"]:::ingestion
            GL_RUN_SCRIPT["GrowthLab Scraper Runner"]:::ingestion
            LT_SCRIPT["Lecture Transcripts Loader"]:::ingestion
            OA_RUN_SCRIPT["OpenAlex Scraper Runner"]:::ingestion
        end
        subgraph "Processors & Utils"
            direction TB
            PDF_PROCESSOR["PDF OCR Processor"]:::ingestion
            RETRY_UTIL["Retry Logic Utility"]:::ingestion
        end
        EMBEDDER["Embedder"]:::ingestion
    end

    %% Storage Layer
    subgraph "Storage Tier"
        direction TB
        GCS["GCS Bucket"]:::storage
        QDRANT["Qdrant Vector DB"]:::storage
        LOCAL_FS["Local FileSystem"]:::storage
        subgraph "Storage Adapters"
            direction TB
            BASE_ADAPTER["Base Storage Interface"]:::storage
            CLOUD_ADAPTER["Cloud Storage Adapter"]:::storage
            GCS_ADAPTER["GCS Adapter"]:::storage
            LOCAL_ADAPTER["Local FS Adapter"]:::storage
            FACTORY["Storage Factory"]:::storage
        end
    end

    %% Backend Service
    subgraph "Backend Service (FastAPI + LangGraph)"
        direction TB
        FASTAPI["FastAPI API"]:::api
        LANGGRAPH["LangGraph Agent"]:::api
        RETRIEVER["Retriever (Qdrant + Cohere)"]:::api
    end

    %% Frontend UI
    subgraph "Frontend UI"
        direction TB
        STREAMLIT["Streamlit UI"]:::frontend
    end

    %% Orchestration & CI/CD
    subgraph "Orchestration & CI/CD"
        direction TB
        GH_ACTIONS["GitHub Actions"]:::orchestration
        SLURM["SLURM HPC Jobs"]:::orchestration
        SECRET_MGR["GCP Secret Manager"]:::orchestration
        CONTAINER_REG["Container Registry"]:::orchestration
        CLOUD_RUN["GCP Cloud Run"]:::orchestration
    end

    %% Data Flows
    GL_SITE -->|HTTP| GL_SCRAPER
    OPENALEX_API -->|HTTP| OA_SCRAPER
    GL_SCRAPER --> PDF_PROCESSOR
    OA_SCRAPER --> PDF_PROCESSOR
    PDF_PROCESSOR --> EMBEDDER
    EMBEDDER --> QDRANT
    EMBEDDER --> GCS
    EMBEDDER --> LOCAL_FS

    DL_SCRIPT --> GL_SCRAPER
    GL_RUN_SCRIPT --> GL_SCRAPER
    OA_RUN_SCRIPT --> OA_SCRAPER
    LT_SCRIPT --> PDF_PROCESSOR

    FASTAPI -->|queries| RETRIEVER
    RETRIEVER -->|vector search| QDRANT
    RETRIEVER -->|rerank| RETRIEVER
    FASTAPI -->|access metadata| GCS
    FASTAPI -->|access docs| LOCAL_FS
    FASTAPI -->|calls| LANGGRAPH
    STREAMLIT -->|user query| FASTAPI
    LANGGRAPH -->|LLM APIs| OPENAI_API["OpenAI/Anthropic LLMs"]:::external

    GH_ACTIONS --> CONTAINER_REG
    CONTAINER_REG --> CLOUD_RUN
    CLOUD_RUN --> ETL_PIPELINE["ETL Pipeline"]:::ingestion
    CLOUD_RUN --> FASTAPI
    CLOUD_RUN --> STREAMLIT
    SLURM --> ETL_PIPELINE
    SECRET_MGR -->|credentials| FASTAPI
    SECRET_MGR -->|credentials| ETL_PIPELINE
    SECRET_MGR -->|credentials| STREAMLIT

    %% Click Events
    click GL_SCRAPER "https://github.com/shreyasgm/gl_deep_search/blob/main/backend/etl/scrapers/growthlab.py"
    click OA_SCRAPER "https://github.com/shreyasgm/gl_deep_search/blob/main/backend/etl/scrapers/openalex.py"
    click DL_SCRIPT "https://github.com/shreyasgm/gl_deep_search/blob/main/backend/etl/scripts/run_gl_file_downloader.py"
    click GL_RUN_SCRIPT "https://github.com/shreyasgm/gl_deep_search/blob/main/backend/etl/scripts/run_growthlab_scraper.py"
    click LT_SCRIPT "https://github.com/shreyasgm/gl_deep_search/blob/main/backend/etl/scripts/run_lecture_transcripts.py"
    click OA_RUN_SCRIPT "https://github.com/shreyasgm/gl_deep_search/blob/main/backend/etl/scripts/run_openalex_scraper.py"
    click BASE_ADAPTER "https://github.com/shreyasgm/gl_deep_search/blob/main/backend/storage/base.py"
    click CLOUD_ADAPTER "https://github.com/shreyasgm/gl_deep_search/blob/main/backend/storage/cloud.py"
    click GCS_ADAPTER "https://github.com/shreyasgm/gl_deep_search/blob/main/backend/storage/gcs.py"
    click LOCAL_ADAPTER "https://github.com/shreyasgm/gl_deep_search/blob/main/backend/storage/local.py"
    click FACTORY "https://github.com/shreyasgm/gl_deep_search/blob/main/backend/storage/factory.py"
    click RETRY_UTIL "https://github.com/shreyasgm/gl_deep_search/blob/main/backend/etl/utils/retry.py"
    click GCS "https://github.com/shreyasgm/gl_deep_search/blob/main/backend/storage/gcs.py"
    click CONTAINER_REG "https://github.com/shreyasgm/gl_deep_search/blob/main/.github/workflows/python-checks.yml"

    %% Styles
    classDef ingestion fill:#D0E8FF,stroke:#0088CC,stroke-width:1px
    classDef storage fill:#DFFFD0,stroke:#55AA00,stroke-width:1px
    classDef api fill:#FFE0B2,stroke:#FF8F00,stroke-width:1px
    classDef frontend fill:#FFF9C4,stroke:#FBC02D,stroke-width:1px
    classDef orchestration fill:#E0E0E0,stroke:#616161,stroke-width:1px
    classDef external fill:#E1BEE7,stroke:#9C27B0,stroke-width:1px
```
