# zeus-12/uxie architecture

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

- Interactive diagram: https://gitdiagram.com/zeus-12/uxie
- Repository: https://github.com/zeus-12/uxie

## Overview

##### Main System Components

a) Client Layer:
- Next.js Frontend (React components)
- PDF Viewer & Editor Interface
- Real-time Collaboration UI
- Authentication UI

b) API Layer:
- tRPC Routes
- Next.js API Routes
- Authentication Endpoints

c) Service Layer:
- PDF Processing
- AI/LLM Services
- Real-time Collaboration
- File Storage
- Vector Search

d) Data Layer:
- Supabase Database
- Pinecone Vector DB
- File Storage (Uploadthing)

##### Component Relationships

a) Frontend to Backend:
- tRPC calls between frontend components and API routes
- WebSocket connections for real-time collaboration
- File upload streams

b) Backend Services:
- Authentication flow with NextAuth
- PDF processing pipeline
- AI processing pipeline
- Database operations

##### Specific Implementation Details

a) PDF Processing Flow:
**Upload → OCR → Vectorization → Storage**

b) AI Integration Flow:
**User Input → Context Retrieval → LLM Processing → Response Streaming**

c) Real-time Collaboration:
**Client → Liveblocks → State Sync → Other Clients**

##### Important Technical Elements

- Prisma ORM layer
- tRPC endpoints
- NextAuth integration
- Pinecone vector search
- Uploadthing storage
- Liveblocks real-time collaboration
- React Query data management
- Zod validation layer

##### Key Workflows to Highlight

a) Document Processing:
**Upload → OCR → Vectorization → Storage → Accessibility**

b) Flashcard Generation:
**User Input → Context Retrieval → LLM Processing → AI Evaluation**

c) Collaborative Editing:
**User Action → State Update → Real-time Sync → Other Users**

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Client["Client Layer"]
        direction TB
        FE[Next.js Frontend]
        PDF["PDF Viewer & Editor"]:::component
        RTC["Real-time Collaboration UI"]:::component
        AUTH_UI["Authentication UI"]
        WORKSPACE["Workspace Interface"]:::component
        FLASH["Flashcard Interface"]:::component
        CHAT["Chat Interface"]:::component
    end

    subgraph API["API Layer"]
        direction TB
        TRPC["tRPC Routes"]:::component
        AUTH["NextAuth"]:::component
        API_ROUTES["Next.js API Routes"]
    end

    subgraph Services["Service Layer"]
        direction TB
        PDF_PROC["PDF Processing"]
        AI["AI/LLM Services"]:::component
        COLLAB["Liveblocks"]:::component
        STORAGE["File Storage"]:::component
        VECTOR["Vector Search"]:::component
    end

    subgraph Data["Data Layer"]
        direction TB
        DB[(Supabase DB)]:::component
        PINE[(Pinecone Vector DB)]:::component
        UPLOAD["Uploadthing Storage"]:::component
    end

    %% Client Layer Connections
    FE --> PDF
    FE --> RTC
    FE --> AUTH_UI
    FE --> WORKSPACE
    FE --> FLASH
    FE --> CHAT

    %% API Layer Connections
    PDF --> TRPC
    RTC --> TRPC
    WORKSPACE --> TRPC
    FLASH --> TRPC
    CHAT --> API_ROUTES
    AUTH_UI --> AUTH

    %% Service Layer Connections
    TRPC --> PDF_PROC
    TRPC --> AI
    RTC --> COLLAB
    API_ROUTES --> AI
    PDF_PROC --> VECTOR
    PDF_PROC --> STORAGE

    %% Data Layer Connections
    VECTOR --> PINE
    STORAGE --> UPLOAD
    TRPC --> DB
    AUTH --> DB

    %% Styling
    classDef component fill:#f9f,stroke:#333,stroke-width:2px
    classDef external fill:#ff9,stroke:#333,stroke-width:2px
    classDef database fill:#9cf,stroke:#333,stroke-width:2px

    %% Click Events
    click PDF "https://github.com/zeus-12/uxie/blob/main/src/components/pdf-reader/index.tsx"
    click RTC "https://github.com/zeus-12/uxie/blob/main/src/components/editor/collaboration-client.tsx"
    click AUTH "https://github.com/zeus-12/uxie/blob/main/src/pages/api/auth/[...nextauth].ts"
    click TRPC "https://github.com/zeus-12/uxie/tree/main/src/server/api/routers"
    click AI "https://github.com/zeus-12/uxie/blob/main/src/app/api/chat/route.ts"
    click VECTOR "https://github.com/zeus-12/uxie/blob/main/src/lib/pinecone.ts"
    click STORAGE "https://github.com/zeus-12/uxie/blob/main/src/lib/uploadthing.ts"
    click DB "https://github.com/zeus-12/uxie/blob/main/prisma/schema.prisma"
    click WORKSPACE "https://github.com/zeus-12/uxie/blob/main/src/components/workspace/index.tsx"
    click FLASH "https://github.com/zeus-12/uxie/blob/main/src/components/flashcard/index.tsx"
    click CHAT "https://github.com/zeus-12/uxie/blob/main/src/components/chat/index.tsx"
```
