# danikagupta/chrome_summary architecture

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

- Interactive diagram: https://gitdiagram.com/danikagupta/chrome_summary
- Repository: https://github.com/danikagupta/chrome_summary

## Overview

##### Project type and purpose
- This is a hybrid full-stack/local application with two UIs:
- A Streamlit Python “backend + UI” service (app.py) that calls OpenAI
- A Chrome Extension (background.js, popup.html/js) for page content extraction
- Purpose: extract the current Chrome tab’s content, send it to GPT-4.1-mini, and display a summary.

##### Main components
a. Chrome Extension
– Content Script / background.js: reads the active tab’s DOM
– popup.html / popup.js: provides a minimal user trigger UI in Chrome
b. Streamlit App (app.py)
– Frontend: Streamlit UI for showing and interacting with summaries
– Backend: Python logic that accepts page text, stores API key locally, invokes OpenAI
c. Local Storage
– A file or keychain holding the user’s OpenAI API key
d. External Service
– OpenAI GPT-4.1-mini API endpoint
e. Documentation (vertical column)
– documentation/PRD.md, EDD.md, DEPLOYMENT.md, requirements.md, README.md

##### Relationships and data flows
1) User clicks Chrome extension → extension grabs page content → sends content payload to local Streamlit server API (HTTP request)
2) Streamlit app receives payload → fetches user’s API key from local storage → calls OpenAI API → receives summary
3) Streamlit app displays summary in its web UI
4) Optionally, the extension’s popup could open the Streamlit UI or show the summary inline

##### Architectural patterns & design principles
- Separation of concerns:
- Extension solely handles page extraction & UI trigger
- Streamlit app handles orchestration, API calls, and final UI
- Single-process local service (no microservices)
- Secure local storage (API key never leaves user’s machine except to OpenAI)

##### Positioning the documentation vertically
- Stack entries top to bottom in this column:
- README.md
- PRD.md
- EDD.md
- DEPLOYMENT.md
- requirements.md

##### Final checklist
– All components labeled clearly
– Documentation in its own vertical column
– Note any ports or URLs (e.g., Streamlit default 8501)

## Diagram (Mermaid)

```mermaid
graph TD
    %% Chrome Extension
    subgraph "Chrome Extension"
        direction TB
        BackgroundScript["Background Script"]:::extension
        PopupUI["Popup UI"]:::extension
        Manifest["Manifest (manifest.json)"]:::extension
    end

    %% Streamlit App
    subgraph "Streamlit App"
        direction TB
        APIEndpoint["API Endpoint (/summarize)"]:::localapp
        UI["Streamlit UI"]:::localapp
    end

    %% Local Storage
    Storage[(API Key Storage)]:::storage

    %% External Service
    OpenAI["OpenAI GPT-4.1-mini"]:::external

    %% Documentation Column
    subgraph DOC["Documentation"]
        direction TB
        DocReadme["README.md"]:::documentation
        DocPRD["PRD.md"]:::documentation
        DocEDD["EDD.md"]:::documentation
        DocDeploy["DEPLOYMENT.md"]:::documentation
        DocReqs["requirements.md"]:::documentation
    end

    %% Connections
    PopupUI -->|"trigger extraction"| BackgroundScript
    BackgroundScript -->|"POST /summarize"| APIEndpoint
    APIEndpoint -->|"read API key"| Storage
    APIEndpoint -->|"call OpenAI API"| OpenAI
    OpenAI -->|"return summary"| APIEndpoint
    APIEndpoint -->|"display summary"| UI
    PopupUI -->|"open UI"| UI

    %% Click Events
    click BackgroundScript "https://github.com/danikagupta/chrome_summary/blob/main/chrome_extension/background.js"
    click PopupUI "https://github.com/danikagupta/chrome_summary/blob/main/chrome_extension/popup.html"
    click PopupUI "https://github.com/danikagupta/chrome_summary/blob/main/chrome_extension/popup.js"
    click Manifest "https://github.com/danikagupta/chrome_summary/blob/main/chrome_extension/manifest.json"
    click APIEndpoint "https://github.com/danikagupta/chrome_summary/blob/main/app.py"
    click DocReadme "https://github.com/danikagupta/chrome_summary/blob/main/README.md"
    click DocPRD "https://github.com/danikagupta/chrome_summary/blob/main/documentation/PRD.md"
    click DocEDD "https://github.com/danikagupta/chrome_summary/blob/main/documentation/EDD.md"
    click DocDeploy "https://github.com/danikagupta/chrome_summary/blob/main/documentation/DEPLOYMENT.md"
    click DocReqs "https://github.com/danikagupta/chrome_summary/blob/main/documentation/requirements.md"
    click APIEndpoint "https://github.com/danikagupta/chrome_summary/blob/main/requirements.txt"

    %% Styles
    classDef extension fill:#add8e6,stroke:#000
    classDef localapp fill:#90ee90,stroke:#000
    classDef storage fill:#ffffe0,stroke:#000
    classDef external fill:#dda0dd,stroke:#000
    classDef documentation fill:#d3d3d3,stroke:#000
    style DOC stroke-dasharray: 5 5,stroke:#000,fill:#f0f0f0
```
