# shreeyashah09/end-to-end-medibot-generative-ai architecture

> Architecture diagram of the GitHub repository shreeyashah09/end-to-end-medibot-generative-ai, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-08-15). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/shreeyashah09/end-to-end-medibot-generative-ai
- Repository: https://github.com/shreeyashah09/end-to-end-medibot-generative-ai

## Overview

##### Project type and purpose
- This is a Python-based AI tool (not a full web-stack) that ingests medical reference material, constructs prompts, calls an LLM (e.g., OpenAI or Hugging Face endpoint), and returns generated medical content.
- README title “End-to-End-MediBot-Generative-AI” implies a pipeline from raw data (a PDF medical book) through prompt/template construction to model inference.

##### File structure
- Top‐level orchestrator: app.py (entry point for CLI or service).
- Data folder: holds the source PDF (Data/Medical_book.pdf.pdf).
- src/ directory:
– helper.py: routines for PDF parsing, text cleaning, chunking.
– prompt.py: logic to assemble question + context into API payload.
– __init__.py: packaging marker.
- template.py: houses reusable prompt templates or Jinja-style structures.
- research/trials.ipynb: exploratory notebooks for model testing, not part of production pipeline.
- setup.py, requirements.txt: packaging and dependency definitions.

##### README for additional insights
- No detailed architecture section, so infer from filenames and common Generative-AI pipelines.

##### Main components and their interactions
a. Data Ingestion & Preprocessing
– Component: “PDF Loader & Text Extractor” (helper.py)
– Input: Data/Medical_book.pdf.pdf
– Output: Cleaned text or tokenized chunks.
b. Prompt Construction
– Component: “Prompt Builder” (prompt.py + template.py)
– Input: User query (from app.py) + relevant text chunks
– Output: API payload (JSON) with fully formed prompt
c. Model Inference
– Component: “LLM Client” (wrapped in prompt.py or a separate layer)
– External Service: OpenAI/HF API endpoint
– Input: Prompt JSON, API key from environment or config
– Output: Generated response text
d. Output Handling
– Component: “Response Formatter” (helper.py or app.py)
– Formats returned text, handles pagination or saving results
e. Orchestration & CLI Service
– Component: “Application Entry Point” (app.py)
– Coordinates all sub-components and exposes a simple CLI or REST endpoint
f. Packaging & Installation
– setup.py & requirements.txt define dependencies and installable package
g. Research & Experimentation
– research/trials.ipynb sits outside production flow—used for model hyperparameter tuning and testing

##### Architectural patterns & design principles
- Pipeline pattern: clear linear flow from ingestion → prompt assembly → inference → output.
- Modular separation: each responsibility lives in its own file (Single Responsibility Principle).
- Dependency inversion: app.py depends on abstracted helper and prompt modules, not raw parsing code.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Data Store
    PDFDataStore(("PDF Data Store")):::datastore
    %% Processing Components
    PDFLoader["PDF Loader & Text Extractor"]:::module
    ChunkStorage["Chunk Storage (in-memory/cache)"]:::module
    %% Prompt Components
    subgraph "Prompt Construction"
        PromptBuilder["Prompt Builder"]:::module
        TemplateEngine["Template Engine"]:::module
    end
    %% Inference
    LLMClient["LLM Client (OpenAI/HF API)"]:::external
    %% Output
    ResponseFormatter["Response Formatter"]:::module
    AppOrchestrator["App Orchestrator (app.py)"]:::module
    User["CLI/User"]:::user
    %% Research Branch
    ResearchNotebook["Research & Experimentation Notebook"]:::research
    %% Packaging
    subgraph "Packaging & Installation"
        Setup["setup.py"]:::package
        Requirements["requirements.txt"]:::package
    end

    %% Flow
    PDFDataStore -->|“Extract Text”| PDFLoader
    PDFLoader -->|“Chunk Data”| ChunkStorage
    ChunkStorage -->|“Provide Context”| PromptBuilder
    TemplateEngine -->|“Apply Templates”| PromptBuilder
    PromptBuilder -->|"HTTP JSON request"| LLMClient
    LLMClient -->|"Generated Text"| ResponseFormatter
    ResponseFormatter -->|"Format Output"| AppOrchestrator
    AppOrchestrator -->|"Display Result"| User

    %% Research Branch
    PDFLoader -->|"Offline Exploration"| ResearchNotebook
    PromptBuilder -->|"Prompt Trials"| ResearchNotebook

    %% Click Events
    click PDFDataStore "https://github.com/shreeyashah09/end-to-end-medibot-generative-ai/blob/master/Data/Medical_book.pdf.pdf"
    click PDFLoader "https://github.com/shreeyashah09/end-to-end-medibot-generative-ai/blob/master/src/helper.py"
    click ChunkStorage "https://github.com/shreeyashah09/end-to-end-medibot-generative-ai/blob/master/src/helper.py"
    click PromptBuilder "https://github.com/shreeyashah09/end-to-end-medibot-generative-ai/blob/master/src/prompt.py"
    click TemplateEngine "https://github.com/shreeyashah09/end-to-end-medibot-generative-ai/blob/master/template.py"
    click LLMClient "https://github.com/shreeyashah09/end-to-end-medibot-generative-ai/blob/master/src/prompt.py"
    click ResponseFormatter "https://github.com/shreeyashah09/end-to-end-medibot-generative-ai/blob/master/src/helper.py"
    click AppOrchestrator "https://github.com/shreeyashah09/end-to-end-medibot-generative-ai/blob/master/app.py"
    click Setup "https://github.com/shreeyashah09/end-to-end-medibot-generative-ai/blob/master/setup.py"
    click Requirements "https://github.com/shreeyashah09/end-to-end-medibot-generative-ai/blob/master/requirements.txt"
    click ResearchNotebook "https://github.com/shreeyashah09/end-to-end-medibot-generative-ai/blob/master/research/trials.ipynb"

    %% Styles
    classDef datastore fill:#e0ffe0,stroke:#2d862d,color:#2d862d
    classDef module fill:#e0f0ff,stroke:#1f5fa8,color:#1f5fa8
    classDef external fill:#fff0e0,stroke:#d96d00,color:#d96d00
    classDef user fill:#f0f0f0,stroke:#888888,color:#555555
    classDef research fill:#f5e0ff,stroke:#8b2bbf,color:#8b2bbf
    classDef package fill:#f0f0f0,stroke:#555555,color:#555555
```
