# jaycoolslm/sci-chat architecture

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

- Interactive diagram: https://gitdiagram.com/jaycoolslm/sci-chat
- Repository: https://github.com/jaycoolslm/sci-chat

## Overview

##### Project type and purpose
- From the README and file tree, this is a “Streamlit App Starter Kit” tailored toward building a “sci‑chat” application: a web UI (Streamlit) that lets users chat with a scientific document‑driven LLM.
- Key features implied: simple front‑end (Streamlit), a chat orchestration layer (`chat_with_data.py`), data ingestion/scraping modules (`app/lib/scrape/*.py`), and multiple “site” pages (Analytics, ChatBot, Corpus).

##### File structure
Top‑level:
- `app/` – your application code
– `Home.py` – the Streamlit entrypoint (defines the overall page layout and navigation)
– `lib/` – core business logic
- `chat_with_data.py` – orchestrates conversations, invokes LLMs, ties in scraped data
- `scrape/` – connectors to external data sources (DOAJ, ScienceDirect)
– `sites/` – page modules, each representing a Streamlit “tab” or route:
- `ChatBot.py`, `Analytics.py`, `Corpus.py`
- `requirements.txt`, `pyvenv.cfg`, `bin/` – your virtual‑env and dependencies
- `test.py` – quick script (likely smoke tests or demo)

##### Detail level and essential elements
- Every page module and library package as its own component
- Do not omit the test harness or virtual‑env/dependencies layer—they impact deployment and reproducibility

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Layer
    subgraph "Frontend Layer"
        Home["Home.py"]:::ui
        ChatBot["ChatBot.py"]:::ui
        Analytics["Analytics.py"]:::ui
        Corpus["Corpus.py"]:::ui
    end

    %% Business Logic
    subgraph "Business Logic"
        ChatWithData["chat_with_data.py"]:::biz
    end

    %% Data Ingestion Layer
    subgraph "Data Ingestion Layer"
        DOAJ["doaj.py"]:::data
        SD["sciencedirect.py"]:::data
    end

    %% Local Storage
    LocalStorage["Local Storage"]:::data

    %% External Services
    subgraph "External Services"
        DOAJAPI["DOAJ API"]:::ext
        SDAPI["ScienceDirect API"]:::ext
        LLM["LLM Provider (OpenAI/HF)"]:::ext
    end

    %% Development Tools
    subgraph "Development & Deployment"
        Test["test.py"]:::tools
        Req["requirements.txt"]:::tools
        Venv["pyvenv.cfg"]:::tools
        Bin["bin/"]:::tools
    end

    %% Relationships
    Home -->|"navigate"| ChatBot
    Home -->|"navigate"| Analytics
    Home -->|"navigate"| Corpus

    ChatBot -->|"user query"| ChatWithData
    Analytics -->|"fetch metrics"| ChatWithData
    Corpus -->|"fetch corpus"| ChatWithData

    ChatWithData -->|"fetch data"| DOAJ
    ChatWithData -->|"fetch data"| SD
    DOAJ -->|"API call"| DOAJAPI
    SD -->|"API call"| SDAPI

    ChatWithData -->|"LLM prompt/response"| LLM

    ChatWithData -->|"store logs"| LocalStorage
    Analytics -->|"load logs"| LocalStorage

    %% Click Events
    click Home "https://github.com/jaycoolslm/sci-chat/blob/main/app/Home.py"
    click ChatBot "https://github.com/jaycoolslm/sci-chat/blob/main/app/sites/ChatBot.py"
    click Analytics "https://github.com/jaycoolslm/sci-chat/blob/main/app/sites/Analytics.py"
    click Corpus "https://github.com/jaycoolslm/sci-chat/blob/main/app/sites/Corpus.py"
    click ChatWithData "https://github.com/jaycoolslm/sci-chat/blob/main/app/lib/chat_with_data.py"
    click DOAJ "https://github.com/jaycoolslm/sci-chat/blob/main/app/lib/scrape/doaj.py"
    click SD "https://github.com/jaycoolslm/sci-chat/blob/main/app/lib/scrape/sciencedirect.py"
    click Test "https://github.com/jaycoolslm/sci-chat/blob/main/test.py"
    click Req "https://github.com/jaycoolslm/sci-chat/blob/main/requirements.txt"
    click Venv "https://github.com/jaycoolslm/sci-chat/blob/main/pyvenv.cfg"
    click Bin "https://github.com/jaycoolslm/sci-chat/tree/main/bin/"

    %% Styles
    classDef ui fill:#cce5ff,stroke:#333,stroke-width:1px
    classDef biz fill:#ccffcc,stroke:#333,stroke-width:1px
    classDef data fill:#ffe5cc,stroke:#333,stroke-width:1px
    classDef ext fill:#e0e0e0,stroke:#333,stroke-width:1px
    classDef tools fill:#f2f2f2,stroke:#333,stroke-width:1px
```
