# sameep-sharma/second-brain architecture

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

- Interactive diagram: https://gitdiagram.com/sameep-sharma/second-brain
- Repository: https://github.com/sameep-sharma/second-brain

## Overview

This is a “second brain” bookmarking app: users sign up or sign in, save YouTube and Twitter links, browse and delete saved items, and create share links for a read-only shared dashboard. The client routes user actions through hooks or page handlers to an Express API; the API authenticates protected requests and persists users, content, and share links in MongoDB. Embedded media is rendered by the client. The backend route wiring and client dashboard/content flows are sampled; some page and middleware implementations are not, so uncertain internal links are omitted.

Main entry points: [`backend/src/index.ts`](https://github.com/sameep-sharma/second-brain/blob/main/backend/src/index.ts) (API routes), [`client/src/pages/DashBoard.tsx`](https://github.com/sameep-sharma/second-brain/blob/main/client/src/pages/DashBoard.tsx) (Dashboard), [`client/src/App.tsx`](https://github.com/sameep-sharma/second-brain/blob/main/client/src/App.tsx) (App routes), [`client/src/pages/SharedDashBoard.tsx`](https://github.com/sameep-sharma/second-brain/blob/main/client/src/pages/SharedDashBoard.tsx) (Shared dashboard)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Client experience"]
  node_app["App routes<br/>[App.tsx]"]
  node_signup["Sign up<br/>[Signup.tsx]"]
  node_signin["Sign in<br/>[Signin.tsx]"]
  node_dashboard["Dashboard<br/>[DashBoard.tsx]"]
  node_shared["Shared dashboard"]
  node_create["Create content<br/>[CreateContent.tsx]"]
  node_card["Content card<br/>[Card.tsx]"]
  node_contenthook["Content hook<br/>[useContent.tsx]"]
  node_sharedhook["Shared hook"]
end

subgraph group_api["Backend API"]
  node_express["API routes<br/>[index.ts]"]
  node_middleware["Auth middleware<br/>[middleware.ts]"]
  node_utils["ID generator<br/>[utils.ts]"]
end

subgraph group_data["Persistence"]
  node_models["Data models<br/>[db.ts]"]
end

node_visitor(("User"))
node_mongodb[("MongoDB")]
node_youtube["YouTube embeds"]
node_twitter["Twitter embeds"]

node_visitor -->|"opens"| node_app
node_app -->|"routes"| node_signup
node_app -->|"routes"| node_signin
node_app -->|"routes"| node_dashboard
node_app -->|"routes"| node_shared
node_signup -->|"posts signup"| node_express
node_signin -->|"posts signin"| node_express
node_dashboard -->|"opens form"| node_create
node_dashboard -->|"loads content"| node_contenthook
node_dashboard -->|"requests sharing"| node_express
node_create -->|"posts content"| node_express
node_contenthook -->|"fetches and deletes"| node_express
node_contenthook -->|"returns content"| node_dashboard
node_shared -->|"loads shared items"| node_sharedhook
node_sharedhook -->|"fetches shared content"| node_express
node_sharedhook -->|"returns content"| node_shared
node_dashboard -->|"renders items"| node_card
node_shared -->|"renders items"| node_card
node_card -.->|"embeds video"| node_youtube
node_card -.->|"renders tweet"| node_twitter
node_express -->|"authenticates"| node_middleware
node_express -->|"generates IDs"| node_utils
node_express -->|"queries and writes"| node_models
node_express -->|"connects"| node_mongodb
node_models -->|"stores records"| node_mongodb

click node_app "https://github.com/sameep-sharma/second-brain/blob/main/client/src/App.tsx"
click node_signup "https://github.com/sameep-sharma/second-brain/blob/main/client/src/pages/Signup.tsx"
click node_signin "https://github.com/sameep-sharma/second-brain/blob/main/client/src/pages/Signin.tsx"
click node_dashboard "https://github.com/sameep-sharma/second-brain/blob/main/client/src/pages/DashBoard.tsx"
click node_shared "https://github.com/sameep-sharma/second-brain/blob/main/client/src/pages/SharedDashBoard.tsx"
click node_create "https://github.com/sameep-sharma/second-brain/blob/main/client/src/components/CreateContent.tsx"
click node_card "https://github.com/sameep-sharma/second-brain/blob/main/client/src/components/Card.tsx"
click node_contenthook "https://github.com/sameep-sharma/second-brain/blob/main/client/src/hooks/useContent.tsx"
click node_sharedhook "https://github.com/sameep-sharma/second-brain/blob/main/client/src/hooks/useSharedContent.tsx"
click node_express "https://github.com/sameep-sharma/second-brain/blob/main/backend/src/index.ts"
click node_middleware "https://github.com/sameep-sharma/second-brain/blob/main/backend/src/middleware.ts"
click node_utils "https://github.com/sameep-sharma/second-brain/blob/main/backend/src/utils.ts"
click node_models "https://github.com/sameep-sharma/second-brain/blob/main/backend/src/db.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_app,node_signup,node_signin,node_dashboard,node_shared,node_create,node_card,node_contenthook,node_sharedhook,node_visitor toneBlue
class node_express,node_middleware,node_utils,node_mongodb toneAmber
class node_models toneMint
class node_youtube,node_twitter toneIndigo
```

## Components

### Client experience

- [App routes](https://github.com/sameep-sharma/second-brain/blob/main/client/src/App.tsx): `client/src/App.tsx`
- [Sign up](https://github.com/sameep-sharma/second-brain/blob/main/client/src/pages/Signup.tsx): `client/src/pages/Signup.tsx`
- [Sign in](https://github.com/sameep-sharma/second-brain/blob/main/client/src/pages/Signin.tsx): `client/src/pages/Signin.tsx`
- [Dashboard](https://github.com/sameep-sharma/second-brain/blob/main/client/src/pages/DashBoard.tsx): `client/src/pages/DashBoard.tsx`
- [Shared dashboard](https://github.com/sameep-sharma/second-brain/blob/main/client/src/pages/SharedDashBoard.tsx): `client/src/pages/SharedDashBoard.tsx`
- [Create content](https://github.com/sameep-sharma/second-brain/blob/main/client/src/components/CreateContent.tsx): `client/src/components/CreateContent.tsx`
- [Content card](https://github.com/sameep-sharma/second-brain/blob/main/client/src/components/Card.tsx): `client/src/components/Card.tsx`
- [Content hook](https://github.com/sameep-sharma/second-brain/blob/main/client/src/hooks/useContent.tsx): `client/src/hooks/useContent.tsx`
- [Shared hook](https://github.com/sameep-sharma/second-brain/blob/main/client/src/hooks/useSharedContent.tsx): `client/src/hooks/useSharedContent.tsx`

### Backend API

- [API routes](https://github.com/sameep-sharma/second-brain/blob/main/backend/src/index.ts): `backend/src/index.ts`
- [Auth middleware](https://github.com/sameep-sharma/second-brain/blob/main/backend/src/middleware.ts): `backend/src/middleware.ts`
- [ID generator](https://github.com/sameep-sharma/second-brain/blob/main/backend/src/utils.ts): `backend/src/utils.ts`

### Persistence

- [Data models](https://github.com/sameep-sharma/second-brain/blob/main/backend/src/db.ts): `backend/src/db.ts`

### Other components

- **User**
- **MongoDB**
- **YouTube embeds**
- **Twitter embeds**

## Connections

- User → App routes: opens
- App routes → Sign up: routes
- App routes → Sign in: routes
- App routes → Dashboard: routes
- App routes → Shared dashboard: routes
- Sign up → API routes: posts signup
- Sign in → API routes: posts signin
- Dashboard → Create content: opens form
- Dashboard → Content hook: loads content
- Dashboard → API routes: requests sharing
- Create content → API routes: posts content
- Content hook → API routes: fetches and deletes
- Content hook → Dashboard: returns content
- Shared dashboard → Shared hook: loads shared items
- Shared hook → API routes: fetches shared content
- Shared hook → Shared dashboard: returns content
- Dashboard → Content card: renders items
- Shared dashboard → Content card: renders items
- Content card → YouTube embeds: embeds video
- Content card → Twitter embeds: renders tweet
- API routes → Auth middleware: authenticates
- API routes → ID generator: generates IDs
- API routes → Data models: queries and writes
- API routes → MongoDB: connects
- Data models → MongoDB: stores records
