# ericciarla/mind-map architecture

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

- Interactive diagram: https://gitdiagram.com/ericciarla/mind-map
- Repository: https://github.com/ericciarla/mind-map

## Overview

##### Main Components

A. Client-Side (Frontend) Layer:
- Main Application UI (Next.js App Router structure)
- PDF Upload Component
- Mind Map Visualization (React Flow)
- Interactive Controls

B. Server-Side Layer:
- API Routes (/api/chat and /api/generate-quiz)
- PDF Processing Service
- AI Integration Layer

C. External Services:
- Google Gemini Pro AI
- Vercel AI SDK
- PDF Processing Services

**[Client Layer]**
- ↕
**[Server Layer]**
- ↕
**[External Services]**

##### Detailed Component Breakdown

Client Layer (Top):
- PDF Uploader Component
- Mind Map Viewer (React Flow)
- Interactive Controls

Server Layer (Middle):
- Next.js API Routes
- PDF Processing Logic
- AI Integration Handler
- Request/response flows

External Services (Bottom):
- Google Gemini Pro AI
- Vercel AI SDK
- Any other external services

##### Data Flow Representation

- File processing (thick lines)

##### Important Elements to Highlight

- PDF Upload Flow:
- [Upload Component] → [PDF Processor] → [AI Analysis] → [Mind Map Generation]

- AI Integration Flow:
- [Server] → [Gemini Pro API] → [Process Response] → [Update Mind Map]

##### Technical Details

- Next.js 14 App Router structure
- React Flow integration points
- API endpoint locations
- Environment variable dependencies
- State management flow

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Styles and Classes
    classDef frontend fill:#e1f5fe,stroke:#01579b
    classDef server fill:#e8f5e9,stroke:#1b5e20
    classDef external fill:#f3e5f5,stroke:#4a148c
    classDef api fill:#fff3e0,stroke:#e65100
    classDef data fill:#fbe9e7,stroke:#bf360c

    %% Frontend Layer
    subgraph Frontend
        AppUI["Main Application UI"]
        Layout["Application Layout"]
        PDFUpload["PDF Upload Component"]
        MindMapViz["Mind Map Visualization"]
        UIControls["UI Components"]
        MarkdownRender["Markdown Renderer"]
        ScoreComp["Score Component"]
        Styles["Global & Mind Map Styling"]
    end

    %% Server Layer
    subgraph Server
        ServerActions["Server Actions"]
        ChatAPI["Chat API Route"]
        QuizAPI["Quiz Generation API"]
        PDFProcessor["PDF Processing Service"]
        TypeDefs["Type Definitions"]
        Schemas["Data Schemas"]
        Utils["Utility Functions"]
    end

    %% External Services
    subgraph External
        GeminiAI["Google Gemini Pro AI"]
        VercelAI["Vercel AI SDK"]
    end

    %% Relationships
    AppUI --> Layout
    Layout --> PDFUpload
    Layout --> MindMapViz
    Layout --> UIControls
    PDFUpload --> ServerActions
    ServerActions --> PDFProcessor
    PDFProcessor --> GeminiAI
    ChatAPI --> GeminiAI
    QuizAPI --> GeminiAI
    GeminiAI --> VercelAI
    MindMapViz --> MarkdownRender
    MindMapViz --> ScoreComp
    ServerActions --> TypeDefs
    ServerActions --> Schemas
    ServerActions --> Utils

    %% Click Events
    click AppUI "https://github.com/ericciarla/mind-map/blob/main/app/(preview)/page.tsx"
    click Layout "https://github.com/ericciarla/mind-map/blob/main/app/(preview)/layout.tsx"
    click PDFUpload "https://github.com/ericciarla/mind-map/blob/main/components/PDFExtractor.tsx"
    click MindMapViz "https://github.com/ericciarla/mind-map/blob/main/components/MindMap.tsx"
    click ChatAPI "https://github.com/ericciarla/mind-map/blob/main/app/api/chat/route.ts"
    click QuizAPI "https://github.com/ericciarla/mind-map/blob/main/app/api/generate-quiz/route.ts"
    click ServerActions "https://github.com/ericciarla/mind-map/blob/main/app/(preview)/actions.ts"
    click TypeDefs "https://github.com/ericciarla/mind-map/blob/main/app/types/types.ts"
    click Schemas "https://github.com/ericciarla/mind-map/blob/main/lib/schemas.ts"
    click Utils "https://github.com/ericciarla/mind-map/blob/main/lib/utils.ts"
    click UIControls "https://github.com/ericciarla/mind-map/tree/main/components/ui"
    click MarkdownRender "https://github.com/ericciarla/mind-map/blob/main/components/markdown.tsx"
    click ScoreComp "https://github.com/ericciarla/mind-map/blob/main/components/score.tsx"
    click Styles "https://github.com/ericciarla/mind-map/blob/main/app/(preview)/globals.css"

    %% Style Applications
    class AppUI,Layout,PDFUpload,MindMapViz,UIControls,MarkdownRender,ScoreComp,Styles frontend
    class ServerActions,ChatAPI,QuizAPI,PDFProcessor,TypeDefs,Schemas,Utils server
    class GeminiAI,VercelAI external
```
