# umesh181/bighead architecture

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

- Interactive diagram: https://gitdiagram.com/umesh181/bighead
- Repository: https://github.com/umesh181/bighead

## Overview

##### Main Components

- Frontend (Next.js App):
- The app directory contains the main pages (e.g., app/page.tsx, app/dashboard/page.tsx) and sub-modules. Emphasize separate sections like:
- Dashboard: Includes sub-features—the Search pages, Documents (with dynamic routing [documentId] pages for chat panels, delete buttons, etc.), and Notes (with similar dynamic routing and creation forms).
- Global Layout & Providers: Files like app/layout.tsx, app/providers.tsx, and app/header.tsx which provide global styling and context for rendering.

- Shared UI Components:
- Additionally, the components/ui folder contains UI primitives like buttons, forms, and cards. These should be represented as part of the overall design.

- Backend/Business Logic (Convex):
- The convex directory indicates the backend service that handles API routes and data models. Files like schema.ts, documents.ts, notes.ts, chats.ts, memberships.ts, and custom configuration (auth.config.ts and clerk.ts) suggest using Convex for data persistence and business logic.

- Utility/Support Libraries:
- The lib directory, which contains shared utility functions, should be noted as support functions that are used across both frontend and backend.

- External Integrations/Services:
- While not explicitly detailed beyond Convex and Clerk integration, indicate cloud deployment/hosting on Vercel (as highlighted in the README) along with potential use of Next.js font optimization and other Next.js specific features.

##### Relationships and Interactions

- Directional flow from the end user's browser to the Frontend (Next.js Pages and Components). Within the UI, indicate that these pages interact with shared UI components and layout elements.
- That utilities from the lib folder support business logic or UI interactions.

##### Architectural Patterns and Design Principles

- Use a layered architecture approach – separate presentation (pages/layouts/components) from business logic (Convex modules which act as API endpoints and data orchestration).
- The dynamic routing in the dashboard (using [documentId] and [noteId] directories) should be noted as an example of route-based modularity.
- Component reusability and separation of concerns (UI components separated into main and editor-specific segments).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Layer
    subgraph "Client Layer"
        CLIENT["User's Browser"]:::client
    end

    %% Next.js Frontend
    subgraph "Next.js Frontend"
        subgraph "Main Pages & Layouts"
            A1["Home Page"]:::frontend
            A2["Dashboard Home"]:::frontend
            A3["Layout"]:::frontend
            A4["Providers"]:::frontend
            A5["Header"]:::frontend
            A6["Dashboard Layout"]:::frontend
        end
    end

    %% Dashboard Feature Modules
    subgraph "Dashboard Feature Modules"
        subgraph "Search Module"
            B1["Search Page"]:::frontend
            B2["Search Form"]:::frontend
        end
        subgraph "Documents Module"
            D1["Documents Listing"]:::frontend
            D2["Document Card"]:::frontend
            D3["Upload Doc Button"]:::frontend
            D4["Upload Doc Form"]:::frontend
            D5["Document Details"]:::frontend
            D6["Chat Panel"]:::frontend
            D7["Delete Doc Button"]:::frontend
            D8["Question Form"]:::frontend
        end
        subgraph "Notes Module"
            N1["Notes Listing"]:::frontend
            N2["Note Card"]:::frontend
            N3["Create Note Button"]:::frontend
            N4["Create Note Form"]:::frontend
            N5["Note Details"]:::frontend
        end
        SN["Side Navigation"]:::frontend
    end

    %% Shared UI Components
    subgraph "Shared UI Components"
        subgraph "General UI Components"
            UI1["Navbar"]:::ui
            UI2["Footer"]:::ui
            UI3["Hero"]:::ui
            UI4["FAQ"]:::ui
            UI5["About"]:::ui
            UI6["Call-to-Action"]:::ui
            UI7["Features"]:::ui
            UI8["Hero Cards"]:::ui
        end
        subgraph "Rich Text Editor"
            RE1["Novel Editor"]:::ui
            RE2["Advanced Editor"]:::ui
            RE3["Extensions"]:::ui
            RE4["Image Upload"]:::ui
            RE5["Slash Command"]:::ui
            subgraph "Editor Selectors"
                ES1["Color Selector"]:::ui
                ES2["Link Selector"]:::ui
                ES3["Node Selector"]:::ui
                ES4["Text Buttons"]:::ui
            end
        end
        REPR["UI Primitives & Utilities"]:::ui
    end

    %% Backend / Business Logic (Convex)
    subgraph "Backend/Business Logic (Convex)"
        subgraph "Convex API"
            C1["Schema"]:::backend
            C2["Auth Config"]:::backend
            C3["Clerk Config"]:::backend
            C4["Chats"]:::backend
            C5["Documents Service"]:::backend
            C6["Memberships"]:::backend
            C7["Notes Service"]:::backend
            C8["Search Service"]:::backend
            C9["HTTP Utilities"]:::backend
        end
        GA["Generated API Files"]:::backend
    end

    %% Utility/Support Libraries
    subgraph "Utility/Support Libraries"
        U["Shared Utilities"]:::util
    end

    %% External Integrations & Deployment
    subgraph "External Integrations & Deployment"
        EX2["Vercel Deployment"]:::external
    end

    %% Relationships and Data Flow
    CLIENT -->|"loads"| A1
    A1 -->|"navigatesTo"| A2
    A1 -->|"renders"| A3
    A1 -->|"renders"| UI1
    A2 -->|"includes"| SN
    A2 -->|"includes"| B1
    A2 -->|"includes"| D1
    A2 -->|"includes"| N1

    %% Dashboard Module Details
    B1 -->|"contains"| B2

    D1 -->|"displays"| D2
    D1 -->|"triggers"| D3
    D1 -->|"triggers"| D4
    D5 -->|"contains"| D6
    D5 -->|"contains"| D7
    D5 -->|"contains"| D8

    N1 -->|"displays"| N2
    N1 -->|"triggers"| N3
    N1 -->|"triggers"| N4
    N4 -->|"shows"| N5

    %% Interactions between Frontend and Backend
    B2 -->|"calls"| C8
    D4 -->|"calls"| C5
    D8 -->|"calls"| C5
    N4 -->|"calls"| C7

    %% Utility Usage
    A3 -->|"utilizes"| U
    C5 -->|"uses"| U

    %% Deployment Connections
    A1 -->|"deployedTo"| EX2
    C1 -->|"deployedTo"| EX2

    %% Click Events for Frontend – Next.js App Pages & Layouts
    click A1 "https://github.com/umesh181/bighead/blob/main/app/page.tsx"
    click A2 "https://github.com/umesh181/bighead/blob/main/app/dashboard/page.tsx"
    click A3 "https://github.com/umesh181/bighead/blob/main/app/layout.tsx"
    click A4 "https://github.com/umesh181/bighead/blob/main/app/providers.tsx"
    click A5 "https://github.com/umesh181/bighead/blob/main/app/header.tsx"
    click A6 "https://github.com/umesh181/bighead/blob/main/app/dashboard/layout.tsx"

    %% Click Events for Dashboard Feature Modules
    click B1 "https://github.com/umesh181/bighead/blob/main/app/dashboard/Search/page.tsx"
    click B2 "https://github.com/umesh181/bighead/blob/main/app/dashboard/Search/search-form.tsx"
    click D1 "https://github.com/umesh181/bighead/blob/main/app/dashboard/documents/page.tsx"
    click D2 "https://github.com/umesh181/bighead/blob/main/app/dashboard/documents/document-card.tsx"
    click D3 "https://github.com/umesh181/bighead/blob/main/app/dashboard/documents/upload-document-button.tsx"
    click D4 "https://github.com/umesh181/bighead/blob/main/app/dashboard/documents/upload-document-form.tsx"
    click D5 "https://github.com/umesh181/bighead/blob/main/app/dashboard/documents/[documentId]/page.tsx"
    click D6 "https://github.com/umesh181/bighead/blob/main/app/dashboard/documents/[documentId]/chat-panel.tsx"
    click D7 "https://github.com/umesh181/bighead/blob/main/app/dashboard/documents/[documentId]/delete-document-button.tsx"
    click D8 "https://github.com/umesh181/bighead/blob/main/app/dashboard/documents/[documentId]/question-form.tsx"
    click N1 "https://github.com/umesh181/bighead/blob/main/app/dashboard/notes/page.tsx"
    click N2 "https://github.com/umesh181/bighead/blob/main/app/dashboard/notes/note-card.tsx"
    click N3 "https://github.com/umesh181/bighead/blob/main/app/dashboard/notes/create-note-button.tsx"
    click N4 "https://github.com/umesh181/bighead/blob/main/app/dashboard/notes/create-note-form.tsx"
    click N5 "https://github.com/umesh181/bighead/blob/main/app/dashboard/notes/[noteId]/page.tsx"
    click SN "https://github.com/umesh181/bighead/blob/main/app/dashboard/side-nav.tsx"

    %% Click Events for Shared UI Components
    click UI1 "https://github.com/umesh181/bighead/blob/main/components/Navbar.tsx"
    click UI2 "https://github.com/umesh181/bighead/blob/main/components/Footer.tsx"
    click UI3 "https://github.com/umesh181/bighead/blob/main/components/Hero.tsx"
    click UI4 "https://github.com/umesh181/bighead/blob/main/components/FAQ.tsx"
    click UI5 "https://github.com/umesh181/bighead/blob/main/components/About.tsx"
    click UI6 "https://github.com/umesh181/bighead/blob/main/components/Cta.tsx"
    click UI7 "https://github.com/umesh181/bighead/blob/main/components/Features.tsx"
    click UI8 "https://github.com/umesh181/bighead/blob/main/components/HeroCards.tsx"
    click RE1 "https://github.com/umesh181/bighead/blob/main/components/NovelEditor.tsx"
    click RE2 "https://github.com/umesh181/bighead/blob/main/components/editor/advanced-editor.tsx"
    click RE3 "https://github.com/umesh181/bighead/blob/main/components/editor/extensions.ts"
    click RE4 "https://github.com/umesh181/bighead/blob/main/components/editor/image-upload.tsx"
    click RE5 "https://github.com/umesh181/bighead/blob/main/components/editor/slash-command.tsx"
    click ES1 "https://github.com/umesh181/bighead/blob/main/components/editor/selectors/color-selector.tsx"
    click ES2 "https://github.com/umesh181/bighead/blob/main/components/editor/selectors/link-selector.tsx"
    click ES3 "https://github.com/umesh181/bighead/blob/main/components/editor/selectors/node-selector.tsx"
    click ES4 "https://github.com/umesh181/bighead/blob/main/components/editor/selectors/text-buttons.tsx"
    click REPR "https://github.com/umesh181/bighead/tree/main/components/ui"

    %% Click Events for Convex Backend/Business Logic
    click C1 "https://github.com/umesh181/bighead/blob/main/convex/schema.ts"
    click C2 "https://github.com/umesh181/bighead/blob/main/convex/auth.config.ts"
    click C3 "https://github.com/umesh181/bighead/blob/main/convex/clerk.ts"
    click C4 "https://github.com/umesh181/bighead/blob/main/convex/chats.ts"
    click C5 "https://github.com/umesh181/bighead/blob/main/convex/documents.ts"
    click C6 "https://github.com/umesh181/bighead/blob/main/convex/memberships.ts"
    click C7 "https://github.com/umesh181/bighead/blob/main/convex/notes.ts"
    click C8 "https://github.com/umesh181/bighead/blob/main/convex/search.ts"
    click C9 "https://github.com/umesh181/bighead/blob/main/convex/http.ts"
    click GA "https://github.com/umesh181/bighead/tree/main/convex/_generated"

    %% Click Event for Utility/Support Libraries
    click U "https://github.com/umesh181/bighead/blob/main/lib/utils.ts"

    %% Styles
    classDef client fill:#B0E0E6,stroke:#000,stroke-width:2px;
    classDef frontend fill:#98FB98,stroke:#000,stroke-width:2px;
    classDef ui fill:#E0FFFF,stroke:#000,stroke-width:2px;
    classDef backend fill:#F08080,stroke:#000,stroke-width:2px;
    classDef util fill:#D3D3D3,stroke:#000,stroke-width:2px;
    classDef external fill:#FFA07A,stroke:#000,stroke-width:2px;
```
