# mahmoudmabrok/chatwithcode architecture

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

- Interactive diagram: https://gitdiagram.com/mahmoudmabrok/chatwithcode
- Repository: https://github.com/mahmoudmabrok/chatwithcode

## Overview

##### Main Components Identification

a) User Interface Layer:
- Streamlit Web Interface (from app.py)

b) Core Processing Layer:
- LLM Integration (Ollama with deepseek-coder-v2 model)
- Vector Store Management (FAISS)
- Embedding System (HuggingFaceEmbeddings)
- Document Processing (LangChain)

c) Storage Layer:
- FAISS Vector Store (vector_store_index directory)
- Local Git Repository (external input)

**[User Interface Layer]**
- ↓
**[Core Processing Layer]**
- ↓
**[Storage Layer]**

##### Detailed Component Representation

- Rectangles: Main components (UI, Processing, Storage)
- Hexagons: External services (Ollama, Local Git Repo)
- Rounded rectangles: Processing components (Embeddings, Document Processor)

##### Data Flow Representation

Two main flows:
a) Knowledge Base Creation Flow:
**Local Git Repo → Document Processor → Embeddings → FAISS Storage**

b) Query Flow:
**User Input → LLM → Vector Store Query → Response Generation → UI**

##### Component Details

For each component, include:
- Component name
- Primary function
- Key technologies used (e.g., "Streamlit UI", "FAISS Vector Store")

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles and classes
    classDef ui fill:#2E86C1,stroke:#1B4F72,color:white
    classDef processing fill:#27AE60,stroke:#196F3D,color:white
    classDef storage fill:#8E44AD,stroke:#4A235A,color:white
    classDef external fill:#E67E22,stroke:#A04000,color:white
    classDef flow fill:#95A5A6,stroke:#616A6B,color:white

    %% User Interface Layer
    subgraph UI
        WebUI["Streamlit Web Interface"]:::ui
    end
    click WebUI "https://github.com/MahmoudMabrok/ChatWithCode/blob/main/app.py"

    %% Core Processing Layer
    subgraph Processing
        LLM["Ollama LLM<br/>(deepseek-coder-v2)"]:::processing
        VectorMgmt["Vector Store<br/>Management"]:::processing
        Embeddings["HuggingFace<br/>Embeddings"]:::processing
        DocProcessor["Document<br/>Processor"]:::processing
    end
    click LLM "https://github.com/MahmoudMabrok/ChatWithCode/blob/main/app.py"
    click VectorMgmt "https://github.com/MahmoudMabrok/ChatWithCode/blob/main/app.py"
    click Embeddings "https://github.com/MahmoudMabrok/ChatWithCode/blob/main/app.py"
    click DocProcessor "https://github.com/MahmoudMabrok/ChatWithCode/blob/main/app.py"

    %% Storage Layer
    subgraph Storage
        FAISS[("FAISS<br/>Vector Store")]:::storage
        GitRepo["Local Git<br/>Repository"]:::external
    end
    click FAISS "https://github.com/MahmoudMabrok/ChatWithCode/blob/main/vector_store_index/index.faiss"

    %% Development Components
    DevEnv["Development<br/>Environment"]:::flow
    Dependencies["Project<br/>Dependencies"]:::flow
    click DevEnv "https://github.com/MahmoudMabrok/ChatWithCode/blob/main/.devcontainer/devcontainer.json"
    click Dependencies "https://github.com/MahmoudMabrok/ChatWithCode/blob/main/requirements.txt"

    %% Relationships - Knowledge Base Creation Flow
    GitRepo --> DocProcessor
    DocProcessor --> Embeddings
    Embeddings --> FAISS

    %% Relationships - Query Flow
    WebUI --> LLM
    LLM --> VectorMgmt
    VectorMgmt --> FAISS
    FAISS --> LLM
    LLM --> WebUI

    %% Legend
    subgraph Legend
        UI_L["UI Component"]:::ui
        PROC_L["Processing Component"]:::processing
        STORE_L["Storage Component"]:::storage
        EXT_L["External Component"]:::external
        FLOW_L["Development Component"]:::flow
    end
```
