# di37/research-paper-analyst architecture

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

- Interactive diagram: https://gitdiagram.com/di37/research-paper-analyst
- Repository: https://github.com/di37/research-paper-analyst

## Overview

Key Components to Include:

##### Frontend Layer
- Components for:
- PDF Upload Component
- Model Selection Dropdown
- API Key Configuration
- Chat Interface
- Analysis Results Display

##### Application Core
- Three main modules (represented as separate components):
- Main Application Controller (main.py)
- Gemini Interface Module
- Research Paper Analyst Module

##### Utility Layer
- Constants Manager
- Helper Functions
- Environment Configuration

##### External Services
- Google Gemini AI API
- File System (for PDF storage)

- [User Layer]
- ↓
- [Frontend Layer]
- ↓
- [Application Core]
- ↓
- [Utility Layer]
- ↓
- [External Services]

- PDF files
- API requests/responses
- Analysis results
- User queries
- Streaming responses

Special Considerations:

##### Streaming nature of the application
- A "Stream" indicator for real-time responses

##### Environment Configuration
- .env configuration flow to the application
- API key management

##### The clear data flow paths between components

Remember to maintain clarity while showing the complexity of the system, particularly focusing on the real-time streaming aspects and the interaction with the Gemini AI API.

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles
    classDef frontend fill:#3498db,stroke:#2980b9,color:white
    classDef core fill:#2ecc71,stroke:#27ae60,color:white
    classDef utility fill:#f1c40f,stroke:#f39c12,color:black
    classDef external fill:#9b59b6,stroke:#8e44ad,color:white
    classDef stream stroke-dasharray: 5 5

    %% User Layer
    User((User))

    %% Frontend Layer
    subgraph Frontend
        UI["Streamlit Web Interface"]:::frontend
        PDF["PDF Upload Component"]:::frontend
        ModelSelect["Model Selection Dropdown"]:::frontend
        APIConfig["API Key Configuration"]:::frontend
        ChatUI["Chat Interface"]:::frontend
        Results["Analysis Results Display"]:::frontend
    end

    %% Application Core
    subgraph AppCore
        MainController["Main Application Controller"]:::core
        GeminiModule["Gemini Interface Module"]:::core
        AnalystModule["Research Paper Analyst Module"]:::core
    end

    %% Utility Layer
    subgraph Utilities
        Constants["Constants Manager"]:::utility
        Helpers["Helper Functions"]:::utility
        EnvConfig["Environment Configuration"]:::utility
    end

    %% External Services
    subgraph External
        GeminiAPI["Google Gemini AI API"]:::external
        FileSystem["File System"]:::external
    end

    %% Relationships
    User --> UI
    UI --> MainController
    MainController --> UI
    PDF --> FileSystem
    MainController --> GeminiModule
    GeminiModule --> MainController
    MainController --> AnalystModule
    AnalystModule --> MainController
    GeminiModule --> GeminiAPI
    GeminiAPI --> GeminiModule

    %% Utility Dependencies
    Constants --> MainController
    Constants --> GeminiModule
    Constants --> AnalystModule
    Helpers --> MainController
    Helpers --> GeminiModule
    Helpers --> AnalystModule
    EnvConfig --> MainController

    %% Click Events
    click MainController "https://github.com/di37/research-paper-analyst/blob/main/main.py"
    click GeminiModule "https://github.com/di37/research-paper-analyst/blob/main/gemini_interface/gemini_interface.py"
    click AnalystModule "https://github.com/di37/research-paper-analyst/blob/main/research_paper_analyst/prompt.py"
    click Constants "https://github.com/di37/research-paper-analyst/blob/main/utilities/constants.py"
    click Helpers "https://github.com/di37/research-paper-analyst/blob/main/utilities/helper.py"
    click EnvConfig "https://github.com/di37/research-paper-analyst/blob/main/.env.example"

    %% Legend
    subgraph Legend
        Frontend_L["Frontend Component"]:::frontend
        Core_L["Core Component"]:::core
        Utility_L["Utility Component"]:::utility
        External_L["External Service"]:::external
    end
```
