# mangesh2004/notetakingapp architecture

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

- Interactive diagram: https://gitdiagram.com/mangesh2004/notetakingapp
- Repository: https://github.com/mangesh2004/notetakingapp

## Overview

##### Project type and purpose
- This is a full-stack Next.js application (“app” directory, next.config.ts, etc.)
- Purpose: A note-taking and PDF annotation workspace that supports user authentication, PDF uploads, viewing/editing PDFs, and AI-powered text assistance (Models/AiModel.tsx).
- Backend: Uses Convex as a serverless data store and function host (convex/ folder).

##### File structure
- Top-level:
- app/ – the Next.js “App Router” pages and layouts
- convex/ – serverless data schema, actions, file storage, and custom logic
- Models/ – front-end AI model component
- components/ – shared UI primitives (buttons, dialogs, inputs)
- hooks/, lib/ – utilities and custom React hooks
- public/, styles, configs (tailwind, postcss, eslint, tsconfig)

- app/ details:
- (auth)/sign-in & sign-up – authentication UI routes
- api/pdfloader/route.ts – an API endpoint to ingest PDFs
- dashboard/ – main workspace after login, with Header, Sidebar, and UploadPDF components
- workspace/[fileId]/ – dynamic workspace page showing PdfViewer, TextEditor, EditorExtinction, WorkspaceHeader
- providers/ConvexClientProvider.tsx – wrapper to supply Convex client context

- convex/ details:
- schema.ts – data model definitions (users, notes)
- users.ts, notes.ts – Convex query/mutation functions
- fileStorage.ts – PDF file handling
- myActions.ts & langchain/db.ts – custom actions, possibly for AI/text extraction

a. Main components:
- Frontend UI (Next.js React components)
- API layer (Next.js serverless routes under app/api)
- Convex backend (queries, mutations, fileStorage, custom actions)
- Database/storage (Convex’s underlying storage + PDF blobs)
- AI Model integration (Models/AiModel and/or Langchain actions)
- External services: Vercel hosting, possibly OpenAI or other LLM endpoints

b. Relationships & data flow:
1. User browser <–> Next.js frontend (pages + React components)
2. Frontend calls Next.js API routes (/api/pdfloader) or uses Convex client for live queries/mutations
3. Next.js API / Convex actions manage PDF storage, user data, notes in Convex DB
4. AI Model component invokes custom Convex actions or third-party LLM APIs to process/extract text from PDFs
5. Results are stored in Convex and pushed to the UI via real-time subscriptions

c. Architectural patterns & design principles:
- Separation of concerns: UI layer vs. API layer vs. data layer
- App Router and component reusability (atomic UI components in components/ui)
- Serverless functions for business logic (Convex)
- Real-time data sync (Convex live queries)
- Dynamic routing for resource-oriented pages (workspace/[fileId])

d. Key technologies & libraries:
- Next.js App Router (React + Server Components + Client Components)
- Convex (serverless DB + functions + file storage)
- Tailwind CSS for styling
- TypeScript throughout
- Langchain or custom AI integration (convex/langchain)
- Sonner for toasts, other UI utilities

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Presentation Layer
    subgraph "Next.js Frontend"
        direction TB
        Browser["User Browser"]:::external
        RootLayout["Root Layout"]:::frontend
        HomePage["Home Page"]:::frontend
        SignIn["Auth Sign-In"]:::frontend
        SignUp["Auth Sign-Up"]:::frontend
        DashboardLayout["Dashboard Layout"]:::frontend
        DashboardPage["Dashboard Main Page"]:::frontend
        Header["Dashboard Header"]:::frontend
        Sidebar["Dashboard Sidebar"]:::frontend
        UploadPDF["Dashboard UploadPDF"]:::frontend
        WorkspacePage["Workspace Page"]:::frontend
        WorkspaceHeader["Workspace Header"]:::frontend
        PdfViewer["PDF Viewer"]:::frontend
        TextEditor["Text Editor"]:::frontend
        EditorExtinction["Editor Extensions"]:::frontend
        ConvexProvider["ConvexClientProvider"]:::frontend
        Button["UI Button"]:::frontend
        Dialog["UI Dialog"]:::frontend
        Input["UI Input"]:::frontend
        Sonner["Toasts (Sonner)"]:::frontend
        UseMobile["use-mobile Hook"]:::frontend
        Utils["Utility Functions"]:::frontend
        AiModel["AI Model Component"]:::frontend
    end

    %% Application Layer
    subgraph "Next.js API & Convex Functions"
        direction TB
        APIRoute["PDF Ingestion API"]:::api
        Schema["Convex Schema"]:::api
        Users["Convex Users"]:::api
        Notes["Convex Notes"]:::api
        FileStorage["Convex FileStorage"]:::api
        MyActions["Convex Custom Actions"]:::api
        LangchainDB["Convex Langchain DB"]:::api
    end

    %% Data Layer
    subgraph "Data & External Services"
        direction TB
        ConvexDB["Convex Database"]:::data
        PDFStorage["PDF Blob Storage"]:::data
        OpenAI["OpenAI / LLM API"]:::external
        Vercel["Vercel Hosting"]:::external
    end

    %% Connections
    Browser -->|"renders"| RootLayout
    RootLayout --> HomePage
    RootLayout --> SignIn
    RootLayout --> SignUp
    RootLayout --> DashboardLayout
    DashboardLayout --> DashboardPage
    DashboardPage --> Header
    DashboardPage --> Sidebar
    DashboardPage --> UploadPDF
    DashboardLayout --> ConvexProvider
    DashboardPage --> ConvexProvider
    UploadPDF -->|"REST call"| APIRoute
    APIRoute -->|"stores file"| FileStorage
    FileStorage --> PDFStorage
    DashboardPage -->|"Convex query"| Users
    WorkspacePage --> WorkspaceHeader
    WorkspacePage --> PdfViewer
    WorkspacePage --> TextEditor
    WorkspacePage --> EditorExtinction
    WorkspacePage --> ConvexProvider
    TextEditor -->|"Convex mutation"| Notes
    PdfViewer -->|"fetch PDF"| FileStorage
    EditorExtinction --> AiModel
    AiModel -->|"invoke action"| MyActions
    MyActions -->|"DB mutation"| Notes
    MyActions -->|"calls LLM"| OpenAI
    LangchainDB -->|"DB queries"| ConvexDB
    Users --> ConvexDB
    Notes --> ConvexDB
    ConvexDB -->|"realtime update"| ConvexProvider
    Vercel --> Browser

    %% Legend
    subgraph "Legend"
        direction TB
        F["Blue: Frontend Components"]:::frontend
        A["Green: API / Functions"]:::api
        D["Orange: Data Storage"]:::data
        E["Gray: External Services"]:::external
    end

    %% Click Events
    click RootLayout "https://github.com/mangesh2004/notetakingapp/blob/main/app/layout.tsx"
    click HomePage "https://github.com/mangesh2004/notetakingapp/blob/main/app/page.tsx"
    click SignIn "https://github.com/mangesh2004/notetakingapp/blob/main/app/(auth)/sign-in/[[...sign-in]]/page.tsx"
    click SignUp "https://github.com/mangesh2004/notetakingapp/blob/main/app/(auth)/sign-up/[[...sign-up]]/page.tsx"
    click DashboardLayout "https://github.com/mangesh2004/notetakingapp/blob/main/app/dashboard/layout.tsx"
    click DashboardPage "https://github.com/mangesh2004/notetakingapp/blob/main/app/dashboard/page.tsx"
    click Header "https://github.com/mangesh2004/notetakingapp/blob/main/app/dashboard/_components/Header.tsx"
    click Sidebar "https://github.com/mangesh2004/notetakingapp/blob/main/app/dashboard/_components/Sidebar.tsx"
    click UploadPDF "https://github.com/mangesh2004/notetakingapp/blob/main/app/dashboard/_components/UploadPDF.tsx"
    click WorkspacePage "https://github.com/mangesh2004/notetakingapp/blob/main/app/workspace/[fileId]/page.tsx"
    click WorkspaceHeader "https://github.com/mangesh2004/notetakingapp/blob/main/app/workspace/_components/WorkspaceHeader.tsx"
    click PdfViewer "https://github.com/mangesh2004/notetakingapp/blob/main/app/workspace/_components/PdfViewer.tsx"
    click TextEditor "https://github.com/mangesh2004/notetakingapp/blob/main/app/workspace/_components/TextEditor.tsx"
    click EditorExtinction "https://github.com/mangesh2004/notetakingapp/blob/main/app/workspace/_components/EditorExtinction.tsx"
    click ConvexProvider "https://github.com/mangesh2004/notetakingapp/blob/main/app/providers/ConvexClientProvider.tsx"
    click APIRoute "https://github.com/mangesh2004/notetakingapp/blob/main/app/api/pdfloader/route.ts"
    click Button "https://github.com/mangesh2004/notetakingapp/blob/main/components/ui/button.tsx"
    click Dialog "https://github.com/mangesh2004/notetakingapp/blob/main/components/ui/dialog.tsx"
    click Input "https://github.com/mangesh2004/notetakingapp/blob/main/components/ui/input.tsx"
    click Sonner "https://github.com/mangesh2004/notetakingapp/blob/main/components/ui/sonner.tsx"
    click AiModel "https://github.com/mangesh2004/notetakingapp/blob/main/Models/AiModel.tsx"
    click UseMobile "https://github.com/mangesh2004/notetakingapp/blob/main/hooks/use-mobile.tsx"
    click Utils "https://github.com/mangesh2004/notetakingapp/blob/main/lib/utils.ts"
    click Schema "https://github.com/mangesh2004/notetakingapp/blob/main/convex/schema.ts"
    click Users "https://github.com/mangesh2004/notetakingapp/blob/main/convex/users.ts"
    click Notes "https://github.com/mangesh2004/notetakingapp/blob/main/convex/notes.ts"
    click FileStorage "https://github.com/mangesh2004/notetakingapp/blob/main/convex/fileStorage.ts"
    click MyActions "https://github.com/mangesh2004/notetakingapp/blob/main/convex/myActions.ts"
    click LangchainDB "https://github.com/mangesh2004/notetakingapp/blob/main/convex/langchain/db.ts"

    %% Styles
    classDef frontend fill:#D0E8FF,stroke:#004EA8,stroke-width:1px
    classDef api fill:#D0F3D8,stroke:#137D2F,stroke-width:1px
    classDef data fill:#FFE5B4,stroke:#CC8400,stroke-width:1px
    classDef external fill:#E0E0E0,stroke:#7D7D7D,stroke-width:1px
```
