# sandy3559/clarinotes architecture

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

- Interactive diagram: https://gitdiagram.com/sandy3559/clarinotes
- Repository: https://github.com/sandy3559/clarinotes

## Overview

##### Project type and purpose
- This is a full-stack Next.js web application that enables users to upload, view, and annotate PDFs in a workspace enriched with AI/ML features.
- It uses Next.js’s App Router for page routing, API routes for serverless endpoints, and Convex as the real-time database, authentication, and serverless function platform.

##### File structure
- Top-level directories:
- app/ – Next.js pages, layouts, server/client components (auth, dashboard, workspace, public pages)
- components/ – UI primitives (buttons, dialogs, inputs, progress)
- convex/ – Convex schema, serverless actions, file storage integration, LangChain DB adapter
- lib/ – shared utilities
- public/ – static assets
- Key files:
- app/api/pdf-loader/route.js – serverless API endpoint for ingesting PDFs
- middleware.js – Next.js middleware, likely for authentication or redirects
- configs/AIModel.js – configuration for AI model usage (e.g., OpenAI keys)
- next.config.mjs, postcss.config.mjs, jsconfig.json – build and tooling configs

##### README for additional insights
- Basic Next.js bootstrapped README; no architecture details.
- Confirms use of next/font, standard Vercel deployment.

##### Detailed capture of essential elements
- Break out the UI sub-components under the dashboard and workspace into a zoomed-in inset if needed (Header, SideBar, PdfViewer, TextEditor)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client-Side
    subgraph "Client-Side (Browser)"
        direction TB
        Browser["Client (Browser)"]:::client
        SignIn["Sign-In Page"]:::client
        SignUp["Sign-Up Page"]:::client
        DashboardUI["Dashboard UI Components"]:::client
        WorkspaceUI["Workspace UI Components"]:::client
        PublicPages["Public & Static Pages"]:::client
        UIPrimitives["UI Primitives Library"]:::client
    end

    click SignIn "https://github.com/sandy3559/clarinotes/blob/main/app/(auth)/sign-in/[[...sign-in]]/page.jsx"
    click SignUp "https://github.com/sandy3559/clarinotes/blob/main/app/(auth)/sign-up/[[...sign-up]]/page.jsx"
    click DashboardUI "https://github.com/sandy3559/clarinotes/blob/main/app/dashboard/page.js"
    click WorkspaceUI "https://github.com/sandy3559/clarinotes/blob/main/app/workspace/[fileId]/page.js"
    click UIPrimitives "https://github.com/sandy3559/clarinotes/blob/main/components/ui/button.jsx"

    %% Next.js Server/API Layer
    subgraph "Next.js Server/API Layer"
        direction TB
        AppRouter["Next.js App Router"]:::server
        Middleware["Next.js Middleware"]:::server
        APIPdfLoader["/api/pdf-loader (PDF Ingestion API)"]:::server
        Utils["Shared Utilities (lib/utils.js)"]:::server
        Configs["Next.js Build Configs"]:::server
        Styles["Global Styles"]:::server
    end

    click AppRouter "https://github.com/sandy3559/clarinotes/tree/main/app/"
    click Middleware "https://github.com/sandy3559/clarinotes/blob/main/middleware.js"
    click APIPdfLoader "https://github.com/sandy3559/clarinotes/blob/main/app/api/pdf-loader/route.js"
    click Utils "https://github.com/sandy3559/clarinotes/blob/main/lib/utils.js"
    click Configs "https://github.com/sandy3559/clarinotes/blob/main/next.config.mjs"
    click Styles "https://github.com/sandy3559/clarinotes/blob/main/app/globals.css"

    %% Convex Platform
    subgraph "Convex Platform"
        direction TB
        RealTimeDB["Convex Real-Time DB"]:::convex
        AuthConvex["Convex Auth & AuthZ"]:::convex
        FileStorage["Convex FileStorage"]:::convex
        subgraph "Serverless Functions"
            direction TB
            myAction["myAction.js"]:::convex
            notes["notes.js"]:::convex
            LangChain["LangChain DB Adapter"]:::convex
        end
    end

    click RealTimeDB "https://github.com/sandy3559/clarinotes/blob/main/convex/schema.js"
    click AuthConvex "https://github.com/sandy3559/clarinotes/blob/main/convex/user.js"
    click FileStorage "https://github.com/sandy3559/clarinotes/blob/main/convex/fileStorage.js"
    click myAction "https://github.com/sandy3559/clarinotes/blob/main/convex/myAction.js"
    click notes "https://github.com/sandy3559/clarinotes/blob/main/convex/notes.js"
    click LangChain "https://github.com/sandy3559/clarinotes/blob/main/convex/langchain/db.js"

    %% External AI Service
    ExternalAI["External AI Service (OpenAI)"]:::external
    click ExternalAI "https://github.com/sandy3559/clarinotes/blob/main/configs/AIModel.js"

    %% External Storage
    Storage["External Storage (S3/Vercel KV)"]:::storage

    %% Connections
    Browser -->|Page Navigation & SSR/CSR| AppRouter
    Browser -->|API Calls| APIPdfLoader
    Browser -->|Uses Primitives| UIPrimitives
    AppRouter -->|Auth Check| AuthConvex
    AppRouter -->|DB Operations| RealTimeDB
    Middleware -->|Validate Session| AuthConvex
    APIPdfLoader -->|Upload PDF| FileStorage
    FileStorage -->|Store Files| Storage
    RealTimeDB <-->|Real-Time Sync| WorkspaceUI
    myAction -->|Call AI Model| ExternalAI
    notes -->|Call AI Model| ExternalAI
    LangChain -->|Call AI Model| ExternalAI
    AppRouter -->|Proxy LLM Requests| ExternalAI

    %% Styles
    classDef client fill:#D6EFFF,stroke:#333,stroke-width:1px
    classDef server fill:#DFFFE0,stroke:#333,stroke-width:1px
    classDef convex fill:#FFE2A3,stroke:#333,stroke-width:1px
    classDef external fill:#E3D4FE,stroke:#333,stroke-width:1px
    classDef storage fill:#F0F0F0,stroke:#333,stroke-width:1px
```
