# ayushsoni02/linknest architecture

> Architecture diagram of the GitHub repository ayushsoni02/linknest, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-26). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ayushsoni02/linknest
- Repository: https://github.com/ayushsoni02/linknest

## Overview

LinkNest is a web-based second brain for saving links, organizing them into Nests, and rediscovering or sharing them. The principal flow is: a signed-in user submits a URL, previews and saves it, then browses content by collection or asks a Nest-specific AI question. The graph also includes authentication, public sharing, and documented search/filter capabilities. Backend excerpts are partial, so unsampled route internals and frontend wiring are represented only where the README or sampled code supports them.

Main entry points: [`MindVault-BE/src/index.ts`](https://github.com/ayushsoni02/linknest/blob/main/MindVault-BE/src/index.ts) (API routes), [`MindVault-BE/src/auth.ts`](https://github.com/ayushsoni02/linknest/blob/main/MindVault-BE/src/auth.ts) (Auth routes), [`MindVault-BE/src/db.ts`](https://github.com/ayushsoni02/linknest/blob/main/MindVault-BE/src/db.ts) (Data models), [`MindVault-FE/src/App.tsx`](https://github.com/ayushsoni02/linknest/blob/main/MindVault-FE/src/App.tsx) (LinkNest app)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Browser app"]
  node_browser["LinkNest app<br/>[App.tsx]"]
  node_dashboard["Dashboard<br/>[Dashboard.tsx]"]
end

subgraph group_identity["Identity"]
  node_authpages["Sign-in pages<br/>[Signin.tsx]"]
  node_oauthbutton["Google sign-in"]
  node_oauthcallback["OAuth callback<br/>[OAuthCallback.tsx]"]
  node_authroutes["Auth routes<br/>[auth.ts]"]
  node_middleware["JWT middleware<br/>[middleware.ts]"]
end

subgraph group_content["Link capture"]
  node_capture["Link preview<br/>[PreviewModal.tsx]"]
  node_contentclient["Content client<br/>[contentService.ts]"]
  node_extractor["Metadata extraction"]
end

subgraph group_collections["Nests and sharing"]
  node_nestworkspace["Nest workspace<br/>[NestWorkspace.tsx]"]
  node_nestshook["Nest client<br/>[useNests.tsx]"]
  node_chat["Nest RAG chat<br/>[index.ts]"]
  node_sharing["Sharing routes<br/>[index.ts]"]
end

subgraph group_platform["Backend and AI"]
  node_api["API routes<br/>[index.ts]"]
  node_ai["AI service<br/>[aiService.ts]"]
  node_models["Data models<br/>[db.ts]"]
  node_database[("MongoDB<br/>[db.ts]")]
end

node_user(("User"))
node_gemini{{"Gemini AI"}}
node_google{{"Google OAuth"}}

node_user -->|"uses"| node_browser
node_browser -->|"routes to"| node_authpages
node_authpages -->|"authenticates"| node_authroutes
node_authroutes -->|"reads and writes"| node_models
node_browser -->|"offers"| node_oauthbutton
node_oauthbutton -->|"starts OAuth"| node_authroutes
node_authroutes -.->|"redirects for sign-in"| node_google
node_authroutes -->|"redirects with token"| node_oauthcallback
node_oauthcallback -->|"fetches profile"| node_authroutes
node_user -->|"submits URL"| node_capture
node_capture -->|"requests metadata and saves"| node_contentclient
node_contentclient -->|"calls content endpoints"| node_api
node_api -->|"protects routes"| node_middleware
node_api -->|"extracts metadata"| node_extractor
node_api -->|"generates digest and embeddings"| node_ai
node_ai -->|"requests AI output"| node_gemini
node_api -->|"stores and retrieves content"| node_models
node_models -->|"persists records"| node_database
node_user -->|"browses links"| node_dashboard
node_dashboard -->|"loads and manages content"| node_contentclient
node_user -->|"opens collection"| node_nestworkspace
node_nestworkspace -->|"manages Nests"| node_nestshook
node_nestshook -->|"calls Nest endpoints"| node_api
node_api -->|"handles public access"| node_sharing
node_sharing -->|"reads and updates sharing"| node_models
node_user -->|"asks Nest question"| node_chat
node_chat -->|"embeds query and generates answer"| node_ai
node_chat -->|"loads Nest content"| node_models
node_chat -->|"requests response synthesis"| node_gemini

click node_browser "https://github.com/ayushsoni02/linknest/blob/main/MindVault-FE/src/App.tsx"
click node_authpages "https://github.com/ayushsoni02/linknest/blob/main/MindVault-FE/src/Pages/Signin.tsx"
click node_oauthbutton "https://github.com/ayushsoni02/linknest/blob/main/MindVault-FE/src/components/OAuth/GoogleOAuthButton.tsx"
click node_oauthcallback "https://github.com/ayushsoni02/linknest/blob/main/MindVault-FE/src/Pages/OAuthCallback.tsx"
click node_dashboard "https://github.com/ayushsoni02/linknest/blob/main/MindVault-FE/src/Pages/Dashboard.tsx"
click node_capture "https://github.com/ayushsoni02/linknest/blob/main/MindVault-FE/src/components/PreviewModal.tsx"
click node_contentclient "https://github.com/ayushsoni02/linknest/blob/main/MindVault-FE/src/services/contentService.ts"
click node_nestworkspace "https://github.com/ayushsoni02/linknest/blob/main/MindVault-FE/src/Pages/NestWorkspace.tsx"
click node_nestshook "https://github.com/ayushsoni02/linknest/blob/main/MindVault-FE/src/hooks/useNests.tsx"
click node_api "https://github.com/ayushsoni02/linknest/blob/main/MindVault-BE/src/index.ts"
click node_authroutes "https://github.com/ayushsoni02/linknest/blob/main/MindVault-BE/src/auth.ts"
click node_middleware "https://github.com/ayushsoni02/linknest/blob/main/MindVault-BE/src/middleware.ts"
click node_extractor "https://github.com/ayushsoni02/linknest/blob/main/MindVault-BE/src/metadataExtractor.ts"
click node_ai "https://github.com/ayushsoni02/linknest/blob/main/MindVault-BE/src/services/aiService.ts"
click node_models "https://github.com/ayushsoni02/linknest/blob/main/MindVault-BE/src/db.ts"
click node_database "https://github.com/ayushsoni02/linknest/blob/main/MindVault-BE/src/db.ts"
click node_chat "https://github.com/ayushsoni02/linknest/blob/main/MindVault-BE/src/index.ts"
click node_sharing "https://github.com/ayushsoni02/linknest/blob/main/MindVault-BE/src/index.ts"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_browser,node_dashboard,node_user toneBlue
class node_authpages,node_oauthbutton,node_oauthcallback,node_authroutes,node_middleware toneAmber
class node_capture,node_contentclient,node_extractor toneMint
class node_nestworkspace,node_nestshook,node_chat,node_sharing toneRose
class node_api,node_ai,node_models,node_database,node_gemini,node_google toneIndigo
```

## Components

### Browser app

- [LinkNest app](https://github.com/ayushsoni02/linknest/blob/main/MindVault-FE/src/App.tsx): `MindVault-FE/src/App.tsx`
- [Dashboard](https://github.com/ayushsoni02/linknest/blob/main/MindVault-FE/src/Pages/Dashboard.tsx): `MindVault-FE/src/Pages/Dashboard.tsx`

### Identity

- [Sign-in pages](https://github.com/ayushsoni02/linknest/blob/main/MindVault-FE/src/Pages/Signin.tsx): `MindVault-FE/src/Pages/Signin.tsx`
- [Google sign-in](https://github.com/ayushsoni02/linknest/blob/main/MindVault-FE/src/components/OAuth/GoogleOAuthButton.tsx): `MindVault-FE/src/components/OAuth/GoogleOAuthButton.tsx`
- [OAuth callback](https://github.com/ayushsoni02/linknest/blob/main/MindVault-FE/src/Pages/OAuthCallback.tsx): `MindVault-FE/src/Pages/OAuthCallback.tsx`
- [Auth routes](https://github.com/ayushsoni02/linknest/blob/main/MindVault-BE/src/auth.ts): `MindVault-BE/src/auth.ts`
- [JWT middleware](https://github.com/ayushsoni02/linknest/blob/main/MindVault-BE/src/middleware.ts): `MindVault-BE/src/middleware.ts`

### Link capture

- [Link preview](https://github.com/ayushsoni02/linknest/blob/main/MindVault-FE/src/components/PreviewModal.tsx): `MindVault-FE/src/components/PreviewModal.tsx`
- [Content client](https://github.com/ayushsoni02/linknest/blob/main/MindVault-FE/src/services/contentService.ts): `MindVault-FE/src/services/contentService.ts`
- [Metadata extraction](https://github.com/ayushsoni02/linknest/blob/main/MindVault-BE/src/metadataExtractor.ts): `MindVault-BE/src/metadataExtractor.ts`

### Nests and sharing

- [Nest workspace](https://github.com/ayushsoni02/linknest/blob/main/MindVault-FE/src/Pages/NestWorkspace.tsx): `MindVault-FE/src/Pages/NestWorkspace.tsx`
- [Nest client](https://github.com/ayushsoni02/linknest/blob/main/MindVault-FE/src/hooks/useNests.tsx): `MindVault-FE/src/hooks/useNests.tsx`
- [Nest RAG chat](https://github.com/ayushsoni02/linknest/blob/main/MindVault-BE/src/index.ts): `MindVault-BE/src/index.ts`
- [Sharing routes](https://github.com/ayushsoni02/linknest/blob/main/MindVault-BE/src/index.ts): `MindVault-BE/src/index.ts`

### Backend and AI

- [API routes](https://github.com/ayushsoni02/linknest/blob/main/MindVault-BE/src/index.ts): `MindVault-BE/src/index.ts`
- [AI service](https://github.com/ayushsoni02/linknest/blob/main/MindVault-BE/src/services/aiService.ts): `MindVault-BE/src/services/aiService.ts`
- [Data models](https://github.com/ayushsoni02/linknest/blob/main/MindVault-BE/src/db.ts): `MindVault-BE/src/db.ts`
- [MongoDB](https://github.com/ayushsoni02/linknest/blob/main/MindVault-BE/src/db.ts): `MindVault-BE/src/db.ts`

### Other components

- **User**
- **Gemini AI**
- **Google OAuth**

## Connections

- User → LinkNest app: uses
- LinkNest app → Sign-in pages: routes to
- Sign-in pages → Auth routes: authenticates
- Auth routes → Data models: reads and writes
- LinkNest app → Google sign-in: offers
- Google sign-in → Auth routes: starts OAuth
- Auth routes → Google OAuth: redirects for sign-in
- Auth routes → OAuth callback: redirects with token
- OAuth callback → Auth routes: fetches profile
- User → Link preview: submits URL
- Link preview → Content client: requests metadata and saves
- Content client → API routes: calls content endpoints
- API routes → JWT middleware: protects routes
- API routes → Metadata extraction: extracts metadata
- API routes → AI service: generates digest and embeddings
- AI service → Gemini AI: requests AI output
- API routes → Data models: stores and retrieves content
- Data models → MongoDB: persists records
- User → Dashboard: browses links
- Dashboard → Content client: loads and manages content
- User → Nest workspace: opens collection
- Nest workspace → Nest client: manages Nests
- Nest client → API routes: calls Nest endpoints
- API routes → Sharing routes: handles public access
- Sharing routes → Data models: reads and updates sharing
- User → Nest RAG chat: asks Nest question
- Nest RAG chat → AI service: embeds query and generates answer
- Nest RAG chat → Data models: loads Nest content
- Nest RAG chat → Gemini AI: requests response synthesis
