# asharibali/edugpt architecture

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

- Interactive diagram: https://gitdiagram.com/asharibali/edugpt
- Repository: https://github.com/asharibali/edugpt

## Overview

##### Main Components Identification

a) Frontend Layer:
- Next.js application (indicated by the app/ directory)
- UI Components (components/ directory)
- Authentication System (OCID integration)

b) Backend Services:
- FlowiseAI (LangChain orchestration)
- OpenAI Services (GPT-4, Whisper API, Moderation API)
- Blockscout Integration
- Google Custom Search API
- LangSmith API

**┌─ Client Layer ─────────────────────┐**
- Next.js Frontend                 │
- TailwindCSS Styling             │
- TypeScript Components           │
- ┬───────────────────┘
- ↓
**┌─ Authentication Layer ─────────────┐**
- Open Campus ID SDK              │
- User Management                 │
- ┬───────────────────┘
- ↓
**┌─ API Gateway Layer ────────────────┐**
- API Routes                      │
- Request Handling               │
- ┬────────────┬──────────┘
- ↓            ↓
**┌─ AI Services ─┐  ┌─ Blockchain ────┐**
- FlowiseAI   │  │ - Blockscout   │
- OpenAI      │  │   API Gateway  │
- LangChain   │  │ - Custom Tools │
- ┘  └───────────────┘

##### Data Flow Representation

Following key interactions:
- User → Frontend → Authentication
- Frontend → AI Services
- AI Services → Blockchain Services
- AI Services → External APIs

##### Additional Elements

Important components:
- Knowledge Base integration (knowledgebase/ directory)
- Prompt Engineering flow (prompt-engineering/ directory)
- External Service Dependencies
- Rate Limiting Systems
- Error Handling (app/error directory)

##### Documentation References

References to:
- API Documentation
- User Query Examples
- System Limitations
- Authentication Flow

For implementation, I recommend using tools like:
- PlantUML
- Lucidchart

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Client["Client Layer"]
        direction TB
        Frontend["Next.js Frontend"]:::frontend
        Components["UI Components"]:::frontend
        Styles["TailwindCSS Styling"]:::frontend
    end

    subgraph Auth["Authentication Layer"]
        direction TB
        OCID["Open Campus ID SDK"]:::auth
        UserMgmt["User Management"]:::auth
    end

    subgraph Gateway["API Gateway Layer"]
        direction TB
        APIRoutes["API Routes"]:::api
        ReqHandler["Request Handling"]:::api
    end

    subgraph AI["AI Services"]
        direction TB
        Flowise["FlowiseAI"]:::ai
        OpenAI["OpenAI Services"]:::ai
        LangChain["LangChain"]:::ai
        LangSmith["LangSmith API"]:::ai
    end

    subgraph Blockchain["Blockchain Services"]
        direction TB
        Blockscout["Blockscout API Gateway"]:::blockchain
        Tools["Custom Blockchain Tools"]:::blockchain
    end

    subgraph CustomTools["Custom Tools"]
        direction TB
        TxTools["Transaction Tools"]:::tools
        BlockTools["Block Tools"]:::tools
        AddrTools["Address Tools"]:::tools
        TokenTools["Token Tools"]:::tools
        ContractTools["Smart Contract Tools"]:::tools
        WithdrawTools["Withdrawal Tools"]:::tools
    end

    subgraph External["External Services"]
        direction TB
        GoogleSearch["Google Custom Search API"]:::external
        KnowledgeBase["Knowledge Base"]:::external
        PromptEng["Prompt Engineering"]:::external
    end

    %% Connections
    Frontend --> Components
    Frontend --> OCID
    Components --> APIRoutes
    OCID --> UserMgmt
    APIRoutes --> ReqHandler
    ReqHandler --> Flowise
    ReqHandler --> Blockscout
    Flowise --> OpenAI
    Flowise --> LangChain
    LangChain --> LangSmith
    Blockscout --> Tools
    Tools --> CustomTools
    Flowise --> GoogleSearch
    Flowise --> KnowledgeBase
    OpenAI --> PromptEng

    %% Click Events
    click Frontend "https://github.com/AsharibAli/EduGPT/blob/main/app/page.tsx"
    click Components "https://github.com/AsharibAli/EduGPT/tree/main/components"
    click OCID "https://github.com/AsharibAli/EduGPT/blob/main/components/ocid/OCIDProvider.tsx"
    click KnowledgeBase "https://github.com/AsharibAli/EduGPT/tree/main/knowledgebase"
    click PromptEng "https://github.com/AsharibAli/EduGPT/blob/main/prompt-engineering/prompt.md"

    %% Styling
    classDef frontend fill:#3b82f6,color:#fff
    classDef auth fill:#22c55e,color:#fff
    classDef api fill:#6b7280,color:#fff
    classDef ai fill:#a855f7,color:#fff
    classDef blockchain fill:#f97316,color:#fff
    classDef tools fill:#84cc16,color:#fff
    classDef external fill:#64748b,color:#fff

    %% Legend
    subgraph Legend
        Frontend_L["Frontend"]:::frontend
        Auth_L["Authentication"]:::auth
        API_L["API"]:::api
        AI_L["AI Services"]:::ai
        Blockchain_L["Blockchain"]:::blockchain
        Tools_L["Tools"]:::tools
        External_L["External"]:::external
    end
```
