# ankursingh10/zerocode-ml-assignment architecture

> Architecture diagram of the GitHub repository ankursingh10/zerocode-ml-assignment, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-09-13). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ankursingh10/zerocode-ml-assignment
- Repository: https://github.com/ankursingh10/zerocode-ml-assignment

## Overview

##### Project type and purpose
- This is a Python-based Retrieval-Augmented Generation (RAG) system with three main “tiers”:
a) A data/embedding pipeline that builds a FAISS index from a QA dataset
b) A model/service layer exposing a FastAPI “/chat” endpoint that retrieves similar docs and calls a HuggingFace LLM for answer generation
c) An evaluation pipeline to compare RAG vs. base model performance
- It’s Dockerized for reproducible deployment.

##### File structure
- Top-level:
- .env.example, requirements.txt, Dockerfile, docker-compose.yml – config and orchestration
- Embeddings/ – precomputed FAISS index, QA CSV and pickle data
- data/ – raw dataset and cleaning script
- app/ – source for index building, RAG logic, and FastAPI server
- Evaluation/ – evaluation report (and presumably evaluation code)
- Naming suggests a clear separation of concerns: data ingestion/cleaning, index building, model/service code, evaluation and deployment files.

##### README for additional insights
- Features call out RAG using HuggingFaceH4/zephyr-7b-beta, FAISS retrieval, FastAPI endpoint, evaluation pipeline, Docker support.
- Run instructions show three phases: build index, run server, run evaluation.
- The presence of hyperparameter.md and dataset.md indicates tuning and dataset documentation phases.

##### Details
- Docker Compose service block with environment variable injection (.env).
- That build_index.py is typically run once before deployment.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Data Preparation Layer
    subgraph "Data Preparation"
        rawCSV[(medquad.csv)]:::data
        cleaning["DataCleaning.py"]:::data
    end
    rawCSV --> cleaning

    %% Indexing Layer
    subgraph "Model/Indexing"
        buildIndex["build_index.py"]:::data
        embDir[(Embeddings/)]:::data
    end
    cleaning --> buildIndex --> embDir

    %% Service/API Layer
    subgraph "Service/API"
        client(("Client\n(app/client.py)")):::external
        http[/POST /chat/]:::external
        api["main.py\n(FastAPI)"]:::service
        ragLogic["rag.py"]:::logic
        HFModel{{"HuggingFace Model\n(HuggingFaceH4/zephyr-7b-beta)"}}:::external
    end
    embDir --> ragLogic --> api
    client --> http --> api
    api --> ragLogic
    ragLogic -->|retrieves| embDir
    ragLogic -->|calls LLM| HFModel

    %% Evaluation Layer
    subgraph "Evaluation"
        evalScript["Evaluation Script"]:::eval
        evalReport[(RAG_vs_Base_Model_Evaluation.pdf)]:::eval
        baseModel{{"Base LLM"}}:::external
    end
    evalScript -->|uses RAG| ragLogic
    evalScript -->|uses Base| baseModel
    evalScript --> evalReport

    %% Orchestration & Configuration
    subgraph "Orchestration & Config"
        dockerfile["Dockerfile"]:::infra
        compose["docker-compose.yml"]:::infra
        env[".env.example"]:::infra
        req["requirements.txt"]:::infra
    end
    dockerfile --> api
    compose --> api
    compose --> buildIndex
    compose --> evalScript
    env --> compose
    req --> dockerfile

    %% Documentation
    subgraph "Documentation"
        dataDoc["dataset.md"]:::doc
        hyperDoc["hyperparameter.md"]:::doc
    end

    %% Click Events
    click rawCSV "https://github.com/ankursingh10/zerocode-ml-assignment/blob/main/data/medquad.csv"
    click cleaning "https://github.com/ankursingh10/zerocode-ml-assignment/blob/main/data/DataCleaning.py"
    click buildIndex "https://github.com/ankursingh10/zerocode-ml-assignment/blob/main/app/build_index.py"
    click embDir "https://github.com/ankursingh10/zerocode-ml-assignment/tree/main/Embeddings/"
    click ragLogic "https://github.com/ankursingh10/zerocode-ml-assignment/blob/main/app/rag.py"
    click api "https://github.com/ankursingh10/zerocode-ml-assignment/blob/main/app/main.py"
    click client "https://github.com/ankursingh10/zerocode-ml-assignment/blob/main/app/client.py"
    click evalReport "https://github.com/ankursingh10/zerocode-ml-assignment/blob/main/Evaluation/RAG_vs_Base_Model_Evaluation.pdf"
    click dockerfile "https://github.com/ankursingh10/zerocode-ml-assignment/tree/main/Dockerfile"
    click compose "https://github.com/ankursingh10/zerocode-ml-assignment/blob/main/docker-compose.yml"
    click env "https://github.com/ankursingh10/zerocode-ml-assignment/blob/main/.env.example"
    click req "https://github.com/ankursingh10/zerocode-ml-assignment/blob/main/requirements.txt"
    click dataDoc "https://github.com/ankursingh10/zerocode-ml-assignment/blob/main/dataset.md"
    click hyperDoc "https://github.com/ankursingh10/zerocode-ml-assignment/blob/main/hyperparameter.md"

    %% Styles
    classDef data fill:#ADD8E6,stroke:#000,color:#000
    classDef service fill:#90EE90,stroke:#000,color:#000
    classDef logic fill:#FFA500,stroke:#000,color:#000
    classDef eval fill:#DDA0DD,stroke:#000,color:#000
    classDef infra fill:#D3D3D3,stroke:#000,color:#000
    classDef external fill:#FFB6C1,stroke:#000,color:#000
    classDef doc fill:#FFFFE0,stroke:#000,color:#000
```
