# hamzafarooq/building-llm-applications-from-scratch architecture

> Architecture diagram of the GitHub repository hamzafarooq/building-llm-applications-from-scratch, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/hamzafarooq/building-llm-applications-from-scratch
- Repository: https://github.com/hamzafarooq/building-llm-applications-from-scratch

## Overview

##### Main Components
- Course Modules as Individual Components: Each “Module X” folder is essentially a self-contained lesson or project example. They represent different layers of the architecture – for example:
- Module 1 & 2: Fundamental LLM principles and basic LLM examples.
- Module 3: Focuses on vector search capabilities and FAISS integration.
- Module 4: Centers on semantic search and includes a Streamlit-based deployment demo (with data files like CSVs, embeddings, pickles).
- Module 5: Deals with Retrieval-Augmented Generation (RAG) architectures.
- Module 6 & 7: Emphasize fine-tuning models, including interfacing with ChatGPT and other LLMs (e.g., Alpaca, Gemma2) as well as advanced prompt engineering.

- Core Architectural Blocks:
- LLM Core Engine: Represents the underlying language model (or models) that are trained/fine-tuned.
- Data Processing/Preprocessing: Implied in several modules for preparing datasets (e.g., tokenization, embedding generation).
- Semantic/Vector Search Engine: Highlighted in Modules 3 and 4 (using FAISS or custom algorithms).
- Retrieval System: Component that supports RAG architectures, using retrieval notebooks and integration points from Module 5.
- Deployment/UI Layer: Exemplified by the Streamlit app within Module 4, including additional data artifacts such as CSVs, pickled objects, and Python scripts.

##### Relationships and Interactions
- Interface with External Libraries/Technologies: For example, indicate the use of FAISS for vector search, Hugging Face APIs for model access, and Streamlit for the demonstration UI.

##### Architectural Patterns and Design Principles
- Modular Design: Emphasize that each module addresses a discrete aspect of the overall LLM application ecosystem.
- Separation of Concerns: Distinguish between model training, vector-based search, retrieval components, and deployment — mirroring the separation between backend processing and frontend demonstration (UI).

##### Relevant Technologies
- Jupyter Notebooks: Represent them as “interactive learning/execution environments” that drive each of the lessons.
- FAISS: Specifically note its role in Module 3 for vector search.
- Streamlit: As the front-facing UI layer in Module 4.
- Hugging Face / Custom APIs: For model fine-tuning and deployment tasks, as seen in Modules 6 and 7.

##### A Detailed Approach
1. Data & Preprocessing Layer (input data, embedding generation, tokenization).
2. Processing & Model Layer (LLM training/fine-tuning, RAG implementation, vector search with FAISS).
3. Deployment & UI Layer (Streamlit app, demo pipelines, result presentation).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Data & Preprocessing Layer
    subgraph "Data & Preprocessing Layer"
        DP["Data Processing & Preprocessing"]:::preprocess
        LLMCore["LLM Core Engine"]:::model
    end

    %% Processing & Model Layer
    subgraph "Processing & Model Layer"
        M1["Module 1 - LLM Fundamentals"]:::model
        M2["Module 2 - Basic LLM Examples"]:::model
        M3["Module 3 - Vector Search & FAISS Integration"]:::model
        M4["Module 4 - Semantic Search"]:::model
        M5["Module 5 - RAG Retrieval Layer"]:::model
        M6["Module 6 - Fine-Tuning Models"]:::model
        M7["Module 7 - Advanced Prompt Engineering"]:::model
    end

    %% Deployment & UI Layer
    subgraph "Deployment & UI Layer"
        DUI["Module 4 Deployment UI (Streamlit)"]:::deploy
    end

    %% Main Flow Connections (vertical)
    DP --> LLMCore
    LLMCore --> M1
    M1 --> M2
    M2 --> M3
    M3 --> M4
    M4 --> M5
    M5 --> M6
    M6 --> M7
    M7 --> DUI
    %% Iterative feedback loop
    M7 -- "feedback" --> LLMCore

    %% Module 1 File Mappings
    M1 --> M1a["Notebook"]:::file
    M1 --> M1b["Slides"]:::file
    click M1a "https://github.com/hamzafarooq/building-llm-applications-from-scratch/blob/main/Module 1/Module_1_Foundation_LLM_Maven_v2_module_1.ipynb"
    click M1b "https://github.com/hamzafarooq/building-llm-applications-from-scratch/blob/main/Module 1/Module_1_Foundation_LLMs-Maven-v2.pptx.pdf"

    %% Module 2 File Mappings
    M2 --> M2a["Notebook"]:::file
    M2 --> M2b["Slides"]:::file
    click M2a "https://github.com/hamzafarooq/building-llm-applications-from-scratch/blob/main/Module 2/Module_2_basic_llms.ipynb"
    click M2b "https://github.com/hamzafarooq/building-llm-applications-from-scratch/blob/main/Module 2/Module_2_Foundation_Maven-v3.pdf"

    %% Module 3 File Mappings
    M3 --> M3a["Notebook"]:::file
    M3 --> M3b["Slides"]:::file
    click M3a "https://github.com/hamzafarooq/building-llm-applications-from-scratch/blob/main/Module 3/Module_3_Foundation_FAISS.ipynb"
    click M3b "https://github.com/hamzafarooq/building-llm-applications-from-scratch/blob/main/Module 3/Module_3_Foundation_Building-Vector-Search.pptx.pdf"

    %% Module 4 File Mappings (Semantic Search)
    M4 --> M4a["SemanticSearch_Notebook_1"]:::file
    M4 --> M4b["SemanticSearch_Notebook_2"]:::file
    click M4a "https://github.com/hamzafarooq/building-llm-applications-from-scratch/blob/main/Module 4/Module_4_Foundation_semantic_search_module.ipynb"
    click M4b "https://github.com/hamzafarooq/building-llm-applications-from-scratch/blob/main/Module 4/semantic_search_module_4.ipynb"

    %% Module 5 File Mappings (RAG Retrieval)
    M5 --> M5a["Retrieval_Notebook_1"]:::file
    M5 --> M5b["Retrieval_Notebook_2"]:::file
    M5 --> M5c["RAG_Slides"]:::file
    click M5a "https://github.com/hamzafarooq/building-llm-applications-from-scratch/blob/main/Module 5/[hf_wand]Retrieval.ipynb"
    click M5b "https://github.com/hamzafarooq/building-llm-applications-from-scratch/blob/main/Module 5/cicero_large_embedding.ipynb"
    click M5c "https://github.com/hamzafarooq/building-llm-applications-from-scratch/blob/main/Module 5/Module_5_Foundation_RAG-based-solutions.pptx.pdf"

    %% Module 6 File Mappings (Fine-Tuning)
    M6 --> M6a["FineTune_Notebook_Mistral"]:::file
    M6 --> M6b["FineTune_Notebook_ChatGPT"]:::file
    M6 --> M6c["FineTune_Slides"]:::file
    click M6a "https://github.com/hamzafarooq/building-llm-applications-from-scratch/blob/main/Module 6/FineTune_Mistral.ipynb"
    click M6b "https://github.com/hamzafarooq/building-llm-applications-from-scratch/blob/main/Module 6/finetune_chatgpt.ipynb"
    click M6c "https://github.com/hamzafarooq/building-llm-applications-from-scratch/blob/main/Module 6/Module_6_Foundation-Maven-v2.pptx.pdf"

    %% Module 7 File Mappings (Advanced Prompt Engineering)
    M7 --> M7a["PromptEngineering_Notebook"]:::file
    M7 --> M7b["PromptEngineering_Slides"]:::file
    click M7a "https://github.com/hamzafarooq/building-llm-applications-from-scratch/blob/main/Module 7/Alpaca_+_Gemma2_9b_Unsloth_2x_finetuning.ipynb"
    click M7b "https://github.com/hamzafarooq/building-llm-applications-from-scratch/blob/main/Module 7/Module_7_Maven-Prompt_Engineering_MLFinetuning.pptx.pdf"

    %% Deployment UI File Mapping for Module 4 Streamlit
    DUI --- DU1["Streamlit App & Assets"]:::file
    click DU1 "https://github.com/hamzafarooq/building-llm-applications-from-scratch/tree/main/Module 4/streamlit"

    %% Styles
    classDef preprocess fill:#f9f,stroke:#333,stroke-width:2px;
    classDef model fill:#ccf,stroke:#333,stroke-width:2px;
    classDef deploy fill:#cfc,stroke:#333,stroke-width:2px;
    classDef file fill:#ffc,stroke:#333,stroke-width:2px, font-style:italic;
```
