# luisreinoso/github-stars-semantic-search architecture

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

- Interactive diagram: https://gitdiagram.com/luisreinoso/github-stars-semantic-search
- Repository: https://github.com/luisreinoso/github-stars-semantic-search

## Overview

##### Main Components

A. Client-Side Application (Browser Environment)
- Frontend UI Layer
- Service Layer
- Local Storage Layer (PGlite)

B. External Services
- GitHub API
- OpenAI API

##### Detailed Component Breakdown

A. Client-Side Components (organize in layers):

Frontend Layer:
- UI Components (represented by ui-manager.ts)
- Configuration Interface (represented by config-manager.ts)

Service Layer (based on /src/services):
- Repository Manager Service
- GitHub Service
- OpenAI Service
- Database Service
- Notification Service

Storage Layer:
- PGlite Database (browser-based SQLite)
- Browser Local Storage (for API keys)

**┌─ Browser Environment ─────────────────────────────────┐**

- ┌─ UI Layer ─────────────────────────────┐          │
- Search Interface                      │          │
- Results Display                       │          │
- Configuration Panel                   │          │
- ┘          │

- ┌─ Service Layer ──────────────────────────┐        │
- ┌─ Repository Manager ─┐ ┌─ OpenAI ─┐    │        │
- Star Management   │ │ - Embeddings│  │        │
- README Processing │ └───────────┘   │        │
- ┘                   │        │
- ┌─ Database Service ─┐ ┌─ GitHub ─┐     │        │
- Query Processing │ │ - API     │    │        │
- Storage Management│ │ - Auth    │    │        │
- ┘ └──────────┘     │        │
- ┘        │

- ┌─ Storage Layer ─────────────────────────┐       │
- ┌─ PGlite ─────┐ ┌─ Local Storage ─┐   │       │
- Embeddings │ │ - API Keys      │   │       │
- Metadata   │ │ - User Config   │   │       │
- ┘ └────────────────┘    │       │
- ┘       │
- ┘

- ↑               ↑

- ▼               ▼

**┌─ GitHub API ─┐  ┌─ OpenAI API ─┐**
- ┘  └─────────────┘

##### Authentication Flow
- User → UI → GitHub Service → GitHub API
- Credentials storage in Local Storage

##### Search Flow
- User Query → UI → Repository Manager
- Repository Manager → OpenAI Service → OpenAI API
- Repository Manager → Database Service → PGlite
- Results → UI

##### Indexing Flow
- Repository Manager → GitHub Service → GitHub API
- Repository Manager → OpenAI Service → OpenAI API
- Repository Manager → Database Service → PGlite

##### Additional Notes

- Notes about privacy and security considerations
- Version/environment information
- Data flow direction indicators
- Error handling paths

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Browser["Browser Environment"]
        subgraph UI["UI Layer"]
            UI1["Search Interface"]:::ui
            UI2["Results Display"]:::ui
            UI3["Configuration Panel"]:::ui
            click UI1 "https://github.com/LuisReinoso/github-stars-semantic-search/blob/master/src/services/ui-manager.ts"
            click UI3 "https://github.com/LuisReinoso/github-stars-semantic-search/blob/master/src/services/config-manager.ts"
        end

        subgraph Services["Service Layer"]
            subgraph RM["Repository Manager"]
                RMS1["Star Management"]:::service
                RMS2["README Processing"]:::service
                click RM "https://github.com/LuisReinoso/github-stars-semantic-search/blob/master/src/services/repository-manager.ts"
            end

            subgraph OAI["OpenAI Service"]
                OAIS["Embeddings"]:::service
                click OAI "https://github.com/LuisReinoso/github-stars-semantic-search/blob/master/src/services/openai.ts"
            end

            subgraph DBS["Database Service"]
                DBS1["Query Processing"]:::service
                DBS2["Storage Management"]:::service
                click DBS "https://github.com/LuisReinoso/github-stars-semantic-search/blob/master/src/services/database.ts"
            end

            subgraph GHS["GitHub Service"]
                GHS1["API"]:::service
                GHS2["Auth"]:::service
                click GHS "https://github.com/LuisReinoso/github-stars-semantic-search/blob/master/src/services/github.ts"
            end

            subgraph NS["Notification Service"]
                NS1["Notifications"]:::service
                click NS "https://github.com/LuisReinoso/github-stars-semantic-search/blob/master/src/services/notification.ts"
            end
        end

        subgraph Storage["Storage Layer"]
            subgraph PG["PGlite"]
                PG1["Embeddings"]:::storage
                PG2["Metadata"]:::storage
            end

            subgraph LS["Local Storage"]
                LS1["API Keys"]:::storage
                LS2["User Config"]:::storage
            end
        end
    end

    subgraph External["External Services"]
        GHAPI["GitHub API"]:::external
        OAIAPI["OpenAI API"]:::external
    end

    %% Connections
    UI1 --> RMS1
    UI2 --> RMS1
    UI3 --> LS2
    
    RMS1 --> GHS1
    RMS2 --> OAIS
    RMS1 --> DBS1
    
    GHS1 --> GHAPI
    GHS2 --> GHAPI
    
    OAIS --> OAIAPI
    
    DBS1 --> PG1
    DBS2 --> PG2
    
    LS1 -.-> GHS2
    LS1 -.-> OAIS

    %% Styles
    classDef ui fill:#a8d1ff,stroke:#2270c1
    classDef service fill:#90EE90,stroke:#006400
    classDef storage fill:#FFE4B5,stroke:#DAA520
    classDef external fill:#DCDCDC,stroke:#696969

    %% Legend
    subgraph Legend
        L1["UI Component"]:::ui
        L2["Service Component"]:::service
        L3["Storage Component"]:::storage
        L4["External Service"]:::external
    end
```
