# satvik314/educhain architecture

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

- Interactive diagram: https://gitdiagram.com/satvik314/educhain
- Repository: https://github.com/satvik314/educhain

## Overview

##### Project type and purpose
- Educhain is an open-source Python library (packaged via setup.py) that provides a high-level API for generating personalized educational content using Generative AI.
- It offers two core “engines” (QnA and Content) behind a single facade class (`educhain/core/educhain.py`), plus supporting utilities, Pydantic models, and integrations with third-party LLMs.

##### File structure
- Top-level:
- setup.py, README.md, LICENSE, CONTRIBUTING.md, .gitignore – packaging & metadata
- docs/ – static documentation (features, getting-started)
- cookbook/ – example Jupyter notebooks, starter-apps, use-cases to demonstrate usage
- educhain/ – core package
- archive/ – old experiments & prototypes
- educhain_llms.txt – list of supported LLM backends
- educhain/ sub-folders:
- core/
– `config.py` (LLMConfig, default settings)
– `educhain.py` (Facade class)
- engines/
– `qna_engine.py` (Question generation workflows)
– `content_engine.py` (Lesson plans, flashcards, notes)
- models/
– `base_models.py`, `qna_models.py`, `content_models.py` (Pydantic schemas)
- utils/
– `loaders.py` (PDF, URL, text, image, video fetchers)
– `output_formatter.py` (export to JSON/CSV/PDF)

##### README for additional insights
1. QnA Engine
2. Content Engine
3. Personalization Engine (future)
- Key features: multiple LLM support via LangChain connectors, customizable prompt templates, export functionality, multimodal inputs (YouTube, images).

##### Detailed, essential architectural elements
- Don’t just list files—group by function (e.g., core vs engines vs utils)
- Consumer (notebooks/apps) → library → LLM → response path
- Pydantic layer between raw LLM output and final data model
- Export module as a first-class component
- Versioned roadmap items (future Personalization Engine)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Layer
    subgraph "Client Layer"
        direction TB
        Notebook["Jupyter Notebooks & Examples"]:::client
        StarterApps["Starter Apps"]:::client
        CustomScripts["Custom Python Scripts"]:::client
    end

    %% API / Facade Layer
    subgraph "API / Facade Layer"
        direction TB
        Educhain["Educhain Facade Class"]:::facade
        LLMConfig["LLMConfig & Strategy"]:::facade
    end

    %% Engines Layer
    subgraph "Engines Layer"
        direction TB
        QnAEngine["QnA Engine"]:::engine
        ContentEngine["Content Engine"]:::engine
        Personalization["Personalization Engine (Future)"]:::engine
    end

    %% Data Ingestion & Prompts
    subgraph "Data Ingestion & Prompt Templates"
        direction TB
        Loaders["Data Loaders (PDF/URL/Text/Image/Video)"]:::ingest
        LLMLIst["Supported LLMs List"]:::ingest
    end

    %% Integration Layer
    subgraph "Integration Layer"
        direction TB
        LLMAdapters["LLM Client Adapters"]:::integration
    end

    %% Model Layer
    subgraph "Model Layer"
        direction TB
        BaseModels["Base Models"]:::model
        QnAModels["QnA Models"]:::model
        ContentModels["Content Models"]:::model
    end

    %% Export Layer
    subgraph "Export Layer"
        direction TB
        Formatter["Output Formatter (JSON/CSV/PDF)"]:::export
    end

    %% Documentation & Support
    subgraph "Documentation & Support"
        direction TB
        Docs["Static Docs"]:::support
        Images["Diagrams & Images"]:::support
        Archive["Archived Prototypes"]:::support
    end

    %% Packaging & Metadata
    subgraph "Packaging & Metadata"
        direction TB
        Setup["setup.py"]:::meta
        Readme["README.md, LICENSE, CONTRIBUTING.md"]:::meta
    end

    %% Connections
    Notebook -->|uses API| Educhain
    StarterApps -->|uses API| Educhain
    CustomScripts -->|uses API| Educhain

    Educhain -->|generate_questions / generate_content| QnAEngine
    Educhain -->|generate_questions / generate_content| ContentEngine

    QnAEngine -->|load data| Loaders
    ContentEngine -->|load data| Loaders

    QnAEngine -->|assemble prompt| LLMLIst
    ContentEngine -->|assemble prompt| LLMLIst

    QnAEngine -->|call API| LLMAdapters
    ContentEngine -->|call API| LLMAdapters

    LLMAdapters -->|raw response| QnAEngine
    LLMAdapters -->|raw response| ContentEngine

    QnAEngine -->|validate response| BaseModels
    QnAEngine -->|validate response| QnAModels
    ContentEngine -->|validate response| BaseModels
    ContentEngine -->|validate response| ContentModels

    QnAEngine -->|return output| Formatter
    ContentEngine -->|return output| Formatter

    Formatter -->|write file| CustomScripts
    Formatter -->|write file| Notebook
    Formatter -->|write file| StarterApps

    %% Click Events
    click Notebook "https://github.com/satvik314/educhain/tree/main/cookbook/"
    click StarterApps "https://github.com/satvik314/educhain/tree/main/cookbook/starter-apps/"
    click Educhain "https://github.com/satvik314/educhain/blob/main/educhain/core/educhain.py"
    click LLMConfig "https://github.com/satvik314/educhain/blob/main/educhain/core/config.py"
    click QnAEngine "https://github.com/satvik314/educhain/blob/main/educhain/engines/qna_engine.py"
    click ContentEngine "https://github.com/satvik314/educhain/blob/main/educhain/engines/content_engine.py"
    click Loaders "https://github.com/satvik314/educhain/blob/main/educhain/utils/loaders.py"
    click LLMLIst "https://github.com/satvik314/educhain/blob/main/educhain_llms.txt"
    click BaseModels "https://github.com/satvik314/educhain/blob/main/educhain/models/base_models.py"
    click QnAModels "https://github.com/satvik314/educhain/blob/main/educhain/models/qna_models.py"
    click ContentModels "https://github.com/satvik314/educhain/blob/main/educhain/models/content_models.py"
    click Formatter "https://github.com/satvik314/educhain/blob/main/educhain/utils/output_formatter.py"
    click Docs "https://github.com/satvik314/educhain/tree/main/docs/"
    click Images "https://github.com/satvik314/educhain/tree/main/images/"
    click Archive "https://github.com/satvik314/educhain/tree/main/archive/"
    click Setup "https://github.com/satvik314/educhain/blob/main/setup.py"
    click Readme "https://github.com/satvik314/educhain/blob/main/README.md"
    click Readme "https://github.com/satvik314/educhain/tree/main/LICENSE"
    click Readme "https://github.com/satvik314/educhain/blob/main/CONTRIBUTING.md"

    %% Styles
    classDef client fill:#e2f8d8,stroke:#2b7a0b,color:#2b7a0b
    classDef facade fill:#d0e8ff,stroke:#0052cc,color:#0052cc
    classDef engine fill:#ffe0b3,stroke:#cc7000,color:#cc7000
    classDef ingest fill:#fff4b3,stroke:#cc9c00,color:#cc9c00
    classDef integration fill:#e0e0e0,stroke:#555555,color:#555555
    classDef model fill:#f2e6ff,stroke:#7030a0,color:#7030a0
    classDef export fill:#d0f0ff,stroke:#00a3cc,color:#00a3cc
    classDef support fill:#f0f0f0,stroke:#999999,color:#999999
    classDef meta fill:#f5f5f5,stroke:#666666,color:#666666
```
