# priya-dwivedi/chat-with-code architecture

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

- Interactive diagram: https://gitdiagram.com/priya-dwivedi/chat-with-code
- Repository: https://github.com/priya-dwivedi/chat-with-code

## Overview

Key Components to Include:

##### Frontend Layer
- Streamlit Web Interface
- User Input Components (OpenAI API key, GitHub repository input)
- Chat Interface

##### Core Processing Layer
- Repository Handler (for cloning and managing GitHub repositories)
- Text Processing Engine (for chunking code)
- Embedding System (for converting code chunks to embeddings)
- QA Retrieval System (Langchain)

##### External Services
- OpenAI API (for LLM interactions)
- GitHub (for repository access)
- Deeplake (for storing embeddings)

##### Component Relationships
- User → Streamlit Interface
- Streamlit Interface → Repository Handler
- Repository Handler → GitHub
- Text Processing Engine → Embedding System
- Embedding System → Deeplake
- QA Retrieval System → OpenAI API
- QA Retrieval System → Chat Interface

##### Specific Implementation Details
- Environment variables configuration (.env)
- Main application file (chatbot.py)
- Utility functions (utils.py)

##### Asynchronous nature of the chat interface

Level of Detail:
- Keep high-level architecture visible
- Main processing steps
- External dependencies
- Maintain clarity on data flow
- Configuration components

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Styles and classes
    classDef frontend fill:#3498db,stroke:#2980b9,color:white
    classDef external fill:#2ecc71,stroke:#27ae60,color:white
    classDef processing fill:#e67e22,stroke:#d35400,color:white
    classDef storage fill:#9b59b6,stroke:#8e44ad,color:white
    classDef config fill:#95a5a6,stroke:#7f8c8d,color:white

    %% User and Frontend
    User((User))
    StreamlitUI[Streamlit Web Interface]:::frontend
    ChatInterface[Chat Interface]:::frontend
    InputComponents[User Input Components]:::frontend

    %% Core Processing
    RepoHandler[Repository Handler]:::processing
    TextProcessor[Text Processing Engine]:::processing
    EmbeddingSystem[Embedding System]:::processing
    QASystem[QA Retrieval System]:::processing

    %% External Services
    subgraph External
        GitHub[GitHub API]:::external
        OpenAI[OpenAI API]:::external
        Deeplake[(Deeplake Storage)]:::storage
    end

    %% Configuration
    Config[".env Configuration"]:::config

    %% Relationships
    User --> StreamlitUI
    StreamlitUI --> InputComponents
    InputComponents --> RepoHandler
    RepoHandler --> GitHub
    RepoHandler --> TextProcessor
    TextProcessor --> EmbeddingSystem
    EmbeddingSystem --> Deeplake
    EmbeddingSystem --> QASystem
    QASystem --> OpenAI
    QASystem --> ChatInterface
    ChatInterface --> User
    Config -.-> StreamlitUI

    %% Click Events
    click StreamlitUI "https://github.com/priya-dwivedi/chat-with-code/blob/main/chatbot.py"
    click RepoHandler "https://github.com/priya-dwivedi/chat-with-code/blob/main/utils.py"
    click TextProcessor "https://github.com/priya-dwivedi/chat-with-code/blob/main/utils.py"
    click EmbeddingSystem "https://github.com/priya-dwivedi/chat-with-code/blob/main/utils.py"
    click QASystem "https://github.com/priya-dwivedi/chat-with-code/blob/main/utils.py"
    click Config "https://github.com/priya-dwivedi/chat-with-code/blob/main/.env"

    %% Legend
    subgraph Legend
        Frontend[Frontend Components]:::frontend
        ExternalServ[External Services]:::external
        ProcessingComp[Processing Components]:::processing
        StorageComp[Storage Components]:::storage
        ConfigComp[Configuration]:::config
    end
```
