# open-dev-society/openstock architecture

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

- Interactive diagram: https://gitdiagram.com/open-dev-society/openstock
- Repository: https://github.com/open-dev-society/openstock

## Overview

OpenStock is a stock research and watchlist web app. Users search for a symbol, open its market and company information, and can manage personal watchlists and alerts; authentication and onboarding personalize that experience. The graph also preserves documented market-overview, sentiment, and scheduled email capabilities. The tree, README, and sampled files support these boundaries, but unsampled page and automation implementations limit certainty about some wiring.

Main entry points: [`lib/inngest/functions.ts`](https://github.com/open-dev-society/openstock/blob/main/lib/inngest/functions.ts) (Scheduled workflows), [`components/SearchCommand.tsx`](https://github.com/open-dev-society/openstock/blob/main/components/SearchCommand.tsx) (Stock search), [`app/(root)/stocks/[symbol]/page.tsx`](https://github.com/open-dev-society/openstock/blob/main/app/(root)/stocks/%5Bsymbol%5D/page.tsx) (Stock details), [`lib/actions/auth.actions.ts`](https://github.com/open-dev-society/openstock/blob/main/lib/actions/auth.actions.ts) (Auth actions)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["Stock experience"]
  node_home["Market overview<br/>[page.tsx]"]
  node_search["Stock search<br/>[SearchCommand.tsx]"]
  node_detail["Stock details<br/>[page.tsx]"]
  node_tradingview["Market widgets"]
  node_sentiment["Sentiment insights"]
end

subgraph group_identity["Identity and profiles"]
  node_authpages["Sign-in and signup<br/>[page.tsx]"]
  node_authactions["Auth actions<br/>[auth.actions.ts]"]
  node_authconfig["Better Auth<br/>[auth.ts]"]
  node_middleware["Route protection<br/>[index.ts]"]
end

subgraph group_watch["Watchlists and alerts"]
  node_watchpage["Watchlist page<br/>[page.tsx]"]
  node_watchmanager["Watchlist manager"]
  node_watchactions["Watchlist actions"]
  node_alerts["Alert actions<br/>[alert.actions.ts]"]
  node_watchstore[("Watchlist records<br/>[watchlist.model.ts]")]
  node_alertstore[("Alert records<br/>[alert.model.ts]")]
end

subgraph group_automation["Automation and messaging"]
  node_automationroute["Inngest endpoint<br/>[route.ts]"]
  node_functions["Scheduled workflows<br/>[functions.ts]"]
  node_mailer["Email delivery<br/>[index.ts]"]
end

subgraph group_services["Data and integrations"]
  node_dbconnect["MongoDB connection<br/>[mongoose.ts]"]
  node_finnhubactions["Market data actions<br/>[finnhub.actions.ts]"]
  node_sentimentactions["Sentiment actions<br/>[adanos.actions.ts]"]
  node_aiprovider["AI provider<br/>[ai-provider.ts]"]
end

node_visitor(("Visitor"))
node_member(("Signed-in user"))
node_finnhub{{"Finnhub"}}
node_tvservice{{"TradingView"}}
node_inngest{{"Inngest"}}
node_emailservice{{"Gmail transport"}}

node_visitor -->|"browses"| node_home
node_visitor -->|"signs in or up"| node_authpages
node_member -->|"searches"| node_search
node_search -->|"queries symbols"| node_finnhubactions
node_finnhubactions -->|"fetches market data"| node_finnhub
node_search -->|"opens symbol"| node_detail
node_detail -->|"displays charts"| node_tradingview
node_tradingview -->|"loads widgets"| node_tvservice
node_detail -.->|"shows insights"| node_sentiment
node_sentiment -.->|"requests analysis"| node_sentimentactions
node_sentimentactions -.->|"requests inference"| node_aiprovider
node_authpages -->|"submits credentials"| node_authactions
node_authactions -->|"calls auth API"| node_authconfig
node_authconfig -->|"connects database"| node_dbconnect
node_authconfig -.->|"sends reset email"| node_emailservice
node_middleware -->|"checks session cookie"| node_member
node_member -->|"opens watchlist"| node_watchpage
node_watchpage -->|"renders manager"| node_watchmanager
node_watchmanager -->|"embeds watchlist"| node_tvservice
node_watchmanager -->|"manages symbols"| node_watchactions
node_watchactions -->|"reads and writes"| node_watchstore
node_watchstore -->|"uses connection"| node_dbconnect
node_member -->|"manages alerts"| node_alerts
node_alerts -->|"reads and writes"| node_alertstore
node_alertstore -->|"uses connection"| node_dbconnect
node_authactions -->|"sends signup event"| node_inngest
node_inngest -->|"invokes endpoint"| node_automationroute
node_automationroute -->|"registers workflows"| node_functions
node_functions -->|"sends summaries"| node_mailer
node_mailer -->|"delivers email"| node_emailservice
node_functions -->|"checks stored alerts"| node_alertstore
node_functions -.->|"requests inference"| node_aiprovider
node_home -->|"shows market views"| node_tradingview

click node_home "https://github.com/open-dev-society/openstock/blob/main/app/(root)/page.tsx"
click node_search "https://github.com/open-dev-society/openstock/blob/main/components/SearchCommand.tsx"
click node_detail "https://github.com/open-dev-society/openstock/blob/main/app/(root)/stocks/%5Bsymbol%5D/page.tsx"
click node_tradingview "https://github.com/open-dev-society/openstock/blob/main/components/TradingViewWidget.tsx"
click node_sentiment "https://github.com/open-dev-society/openstock/blob/main/components/stocks/StockSentimentCard.tsx"
click node_authpages "https://github.com/open-dev-society/openstock/blob/main/app/(auth)/sign-in/page.tsx"
click node_authactions "https://github.com/open-dev-society/openstock/blob/main/lib/actions/auth.actions.ts"
click node_authconfig "https://github.com/open-dev-society/openstock/blob/main/lib/better-auth/auth.ts"
click node_middleware "https://github.com/open-dev-society/openstock/blob/main/middleware/index.ts"
click node_watchpage "https://github.com/open-dev-society/openstock/blob/main/app/(root)/watchlist/page.tsx"
click node_watchmanager "https://github.com/open-dev-society/openstock/blob/main/components/watchlist/WatchlistManager.tsx"
click node_watchactions "https://github.com/open-dev-society/openstock/blob/main/lib/actions/watchlist.actions.ts"
click node_alerts "https://github.com/open-dev-society/openstock/blob/main/lib/actions/alert.actions.ts"
click node_watchstore "https://github.com/open-dev-society/openstock/blob/main/database/models/watchlist.model.ts"
click node_alertstore "https://github.com/open-dev-society/openstock/blob/main/database/models/alert.model.ts"
click node_dbconnect "https://github.com/open-dev-society/openstock/blob/main/database/mongoose.ts"
click node_finnhubactions "https://github.com/open-dev-society/openstock/blob/main/lib/actions/finnhub.actions.ts"
click node_sentimentactions "https://github.com/open-dev-society/openstock/blob/main/lib/actions/adanos.actions.ts"
click node_automationroute "https://github.com/open-dev-society/openstock/blob/main/app/api/inngest/route.ts"
click node_functions "https://github.com/open-dev-society/openstock/blob/main/lib/inngest/functions.ts"
click node_mailer "https://github.com/open-dev-society/openstock/blob/main/lib/nodemailer/index.ts"
click node_aiprovider "https://github.com/open-dev-society/openstock/blob/main/lib/ai-provider.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_home,node_search,node_detail,node_tradingview,node_sentiment,node_member,node_tvservice toneBlue
class node_authpages,node_authactions,node_authconfig,node_middleware toneAmber
class node_watchpage,node_watchmanager,node_watchactions,node_alerts,node_watchstore,node_alertstore toneMint
class node_automationroute,node_functions,node_mailer toneRose
class node_dbconnect,node_finnhubactions,node_sentimentactions,node_aiprovider,node_visitor,node_finnhub,node_inngest,node_emailservice toneIndigo
```

## Components

### Stock experience

- [Market overview](https://github.com/open-dev-society/openstock/blob/main/app/(root)/page.tsx): `app/(root)/page.tsx`
- [Stock search](https://github.com/open-dev-society/openstock/blob/main/components/SearchCommand.tsx): `components/SearchCommand.tsx`
- [Stock details](https://github.com/open-dev-society/openstock/blob/main/app/(root)/stocks/%5Bsymbol%5D/page.tsx): `app/(root)/stocks/[symbol]/page.tsx`
- [Market widgets](https://github.com/open-dev-society/openstock/blob/main/components/TradingViewWidget.tsx): `components/TradingViewWidget.tsx`
- [Sentiment insights](https://github.com/open-dev-society/openstock/blob/main/components/stocks/StockSentimentCard.tsx): `components/stocks/StockSentimentCard.tsx`

### Identity and profiles

- [Sign-in and signup](https://github.com/open-dev-society/openstock/blob/main/app/(auth)/sign-in/page.tsx): `app/(auth)/sign-in/page.tsx`
- [Auth actions](https://github.com/open-dev-society/openstock/blob/main/lib/actions/auth.actions.ts): `lib/actions/auth.actions.ts`
- [Better Auth](https://github.com/open-dev-society/openstock/blob/main/lib/better-auth/auth.ts): `lib/better-auth/auth.ts`
- [Route protection](https://github.com/open-dev-society/openstock/blob/main/middleware/index.ts): `middleware/index.ts`

### Watchlists and alerts

- [Watchlist page](https://github.com/open-dev-society/openstock/blob/main/app/(root)/watchlist/page.tsx): `app/(root)/watchlist/page.tsx`
- [Watchlist manager](https://github.com/open-dev-society/openstock/blob/main/components/watchlist/WatchlistManager.tsx): `components/watchlist/WatchlistManager.tsx`
- [Watchlist actions](https://github.com/open-dev-society/openstock/blob/main/lib/actions/watchlist.actions.ts): `lib/actions/watchlist.actions.ts`
- [Alert actions](https://github.com/open-dev-society/openstock/blob/main/lib/actions/alert.actions.ts): `lib/actions/alert.actions.ts`
- [Watchlist records](https://github.com/open-dev-society/openstock/blob/main/database/models/watchlist.model.ts): `database/models/watchlist.model.ts`
- [Alert records](https://github.com/open-dev-society/openstock/blob/main/database/models/alert.model.ts): `database/models/alert.model.ts`

### Automation and messaging

- [Inngest endpoint](https://github.com/open-dev-society/openstock/blob/main/app/api/inngest/route.ts): `app/api/inngest/route.ts`
- [Scheduled workflows](https://github.com/open-dev-society/openstock/blob/main/lib/inngest/functions.ts): `lib/inngest/functions.ts`
- [Email delivery](https://github.com/open-dev-society/openstock/blob/main/lib/nodemailer/index.ts): `lib/nodemailer/index.ts`

### Data and integrations

- [MongoDB connection](https://github.com/open-dev-society/openstock/blob/main/database/mongoose.ts): `database/mongoose.ts`
- [Market data actions](https://github.com/open-dev-society/openstock/blob/main/lib/actions/finnhub.actions.ts): `lib/actions/finnhub.actions.ts`
- [Sentiment actions](https://github.com/open-dev-society/openstock/blob/main/lib/actions/adanos.actions.ts): `lib/actions/adanos.actions.ts`
- [AI provider](https://github.com/open-dev-society/openstock/blob/main/lib/ai-provider.ts): `lib/ai-provider.ts`

### Other components

- **Visitor**
- **Signed-in user**
- **Finnhub**
- **TradingView**
- **Inngest**
- **Gmail transport**

## Connections

- Visitor → Market overview: browses
- Visitor → Sign-in and signup: signs in or up
- Signed-in user → Stock search: searches
- Stock search → Market data actions: queries symbols
- Market data actions → Finnhub: fetches market data
- Stock search → Stock details: opens symbol
- Stock details → Market widgets: displays charts
- Market widgets → TradingView: loads widgets
- Stock details → Sentiment insights: shows insights
- Sentiment insights → Sentiment actions: requests analysis
- Sentiment actions → AI provider: requests inference
- Sign-in and signup → Auth actions: submits credentials
- Auth actions → Better Auth: calls auth API
- Better Auth → MongoDB connection: connects database
- Better Auth → Gmail transport: sends reset email
- Route protection → Signed-in user: checks session cookie
- Signed-in user → Watchlist page: opens watchlist
- Watchlist page → Watchlist manager: renders manager
- Watchlist manager → TradingView: embeds watchlist
- Watchlist manager → Watchlist actions: manages symbols
- Watchlist actions → Watchlist records: reads and writes
- Watchlist records → MongoDB connection: uses connection
- Signed-in user → Alert actions: manages alerts
- Alert actions → Alert records: reads and writes
- Alert records → MongoDB connection: uses connection
- Auth actions → Inngest: sends signup event
- Inngest → Inngest endpoint: invokes endpoint
- Inngest endpoint → Scheduled workflows: registers workflows
- Scheduled workflows → Email delivery: sends summaries
- Email delivery → Gmail transport: delivers email
- Scheduled workflows → Alert records: checks stored alerts
- Scheduled workflows → AI provider: requests inference
- Market overview → Market widgets: shows market views
