MCPcopy Index your code
hub / github.com/Open-Dev-Society/OpenStock

github.com/Open-Dev-Society/OpenStock @main sqlite

repository ↗ · DeepWiki ↗
232 symbols 597 edges 95 files 0 documented · 0% 18 cross-repo links
README

Checkout new amazing projects also, OpenReadme is live

Featured|HelloGitHub OpenStock Star History Rank

Project Banner © Open Dev Society. This project is licensed under AGPL-3.0; if you modify, redistribute, or deploy it (including as a web service), you must release your source code under the same license and credit the original authors.

<img src="https://img.shields.io/badge/-Next.js-black?style=for-the-badge&logoColor=white&logo=next.js&color=000000" alt="Next.js badge" />
<img src="https://img.shields.io/badge/-TypeScript-black?style=for-the-badge&logoColor=white&logo=typescript&color=3178C6"/>
<img src="https://img.shields.io/badge/-Tailwind%20CSS-black?style=for-the-badge&logoColor=white&logo=tailwindcss&color=38B2AC"/>
<img src="https://img.shields.io/badge/-shadcn/ui-black?style=for-the-badge&logoColor=white&logo=shadcnui&color=000000"/>
<img src="https://img.shields.io/badge/-Radix%20UI-black?style=for-the-badge&logoColor=white&logo=radixui&color=000000"/>
<img src="https://img.shields.io/badge/-Better%20Auth-black?style=for-the-badge&logoColor=white&logo=betterauth&color=000000"/>
<img src="https://img.shields.io/badge/-MongoDB-black?style=for-the-badge&logoColor=white&logo=mongodb&color=00A35C"/>
<img src="https://img.shields.io/badge/-Inngest-black?style=for-the-badge&logoColor=white&logo=inngest&color=000000"/>
<img src="https://img.shields.io/badge/-Nodemailer-black?style=for-the-badge&logoColor=white&logo=gmail&color=EA4335"/>
<img src="https://img.shields.io/badge/-TradingView-black?style=for-the-badge&logoColor=white&logo=tradingview&color=2962FF"/>
<img src="https://img.shields.io/badge/-Finnhub-black?style=for-the-badge&logoColor=white&color=30B27A"/>
<img src="https://img.shields.io/badge/-CodeRabbit-black?style=for-the-badge&logoColor=white&logo=coderabbit&color=9146FF"/>

OpenStock

OpenStock is an open-source alternative to expensive market platforms. Track real-time prices, set personalized alerts, and explore detailed company insights — built openly, for everyone, forever free.

Note: OpenStock is community-built and not a brokerage. Market data may be delayed based on provider rules and your configuration. Nothing here is financial advice.

📋 Table of Contents

  1. Introduction
  2. 🌍 Open Dev Society Manifesto
  3. ⚙️ Tech Stack
  4. 🔋 Features
  5. 🤸 Quick Start
  6. 🐳 Docker Setup
  7. 🔐 Environment Variables
  8. 🧱 Project Structure
  9. 📡 Data & Integrations
  10. 🌍 Market Support
  11. 🧪 Scripts & Tooling
  12. 🤝 Contributing
  13. 🛡️ Security
  14. 📜 License
  15. 🙏 Acknowledgements

✨ Introduction

OpenStock is a modern stock market app powered by Next.js (App Router), shadcn/ui and Tailwind CSS, Better Auth for authentication, MongoDB for persistence, Finnhub for market data, and TradingView widgets for charts and market views.

🌍 Open Dev Society Manifesto

We live in a world where knowledge is hidden behind paywalls. Where tools are locked in subscriptions. Where information is twisted by bias. Where newcomers are told they’re not “good enough” to build.

We believe there’s a better way.

  • Our Belief: Technology should belong to everyone. Knowledge should be open, free, and accessible. Communities should welcome newcomers with trust, not gatekeeping.
  • Our Mission: Build free, open-source projects that make a real difference:
    • Tools that professionals and students can use without barriers.
    • Knowledge platforms where learning is free, forever.
    • Communities where every beginner is guided, not judged.
    • Resources that run on trust, not profit.
  • Our Promise: We will never lock knowledge. We will never charge for access. We will never trade trust for money. We run on transparency, donations, and the strength of our community.
  • Our Call: If you’ve ever felt you didn’t belong, struggled to find free resources, or wanted to build something meaningful — you belong here.

Because the future belongs to those who build it openly.

⚙️ Tech Stack

Core - Next.js 15 (App Router), React 19 - TypeScript - Tailwind CSS v4 (via @tailwindcss/postcss) - shadcn/ui + Radix UI primitives - Lucide icons

Auth & Data - Better Auth (email/password) with MongoDB adapter - MongoDB + Mongoose - Finnhub API for symbols, profiles, and market news - TradingView embeddable widgets

Automation & Comms - Inngest (events, cron, AI inference via Gemini) - Nodemailer (Gmail transport) - next-themes, cmdk (command palette), react-hook-form

Language composition - TypeScript (~93.4%), CSS (~6%), JavaScript (~0.6%)

🔋 Features

  • Authentication
    • Email/password auth with Better Auth + MongoDB adapter
    • Protected routes enforced via Next.js middleware
  • Global search and Command + K palette
    • Fast stock search backed by Finnhub
    • Popular stocks when idle; debounced querying
  • Watchlist
    • Per-user watchlist stored in MongoDB (unique symbol per user)
  • Stock details
    • TradingView symbol info, candlestick/advanced charts, baseline, technicals
    • Company profile and financials widgets
    • Optional cross-source sentiment insights for Reddit, X.com, news, and Polymarket
  • Market overview
    • Heatmap, quotes, and top stories (TradingView widgets)
  • Personalized onboarding
    • Collects country, investment goals, risk tolerance, preferred industry
  • Email & automation
    • AI-personalized welcome email (Gemini via Inngest)
    • Daily news summary emails (cron) personalized using user watchlists
  • Polished UI
    • shadcn/ui components, Radix primitives, Tailwind v4 design tokens
    • Dark theme by default
  • Keyboard shortcut
    • Cmd/Ctrl + K for quick actions/search

🤸 Quick Start

Prerequisites - Node.js 20+ and pnpm or npm - MongoDB connection string (MongoDB Atlas or local via Docker Compose) - Finnhub API key (free tier supported; real-time may require paid) - Gmail account for email (or update Nodemailer transport) - Optional: Google Gemini API key (for AI-generated welcome intros)

Clone and install

git clone https://github.com/Open-Dev-Society/OpenStock.git
cd OpenStock

# choose one:
pnpm install
# or
npm install

Configure environment - Create a .env file (see Environment Variables). - Verify DB connectivity:

pnpm test:db
# or
npm run test:db

Run development

# Next.js dev (Turbopack)
pnpm dev
# or
npm run dev

Run Inngest locally (workflows, cron, AI)

npx inngest-cli@latest dev

Build & start (production)

pnpm build && pnpm start
# or
npm run build && npm start

Open http://localhost:3000 to view the app.

🐳 Docker Setup

You can run OpenStock and MongoDB easily with Docker Compose.

1) Ensure Docker and Docker Compose are installed.

2) docker-compose.yml includes two services: - openstock (this app) - mongodb (MongoDB database with a persistent volume)

3) Create your .env (see examples below). For the Docker setup, use a local connection string like:

MONGODB_URI=mongodb://root:example@mongodb:27017/openstock?authSource=admin

4) Start the stack:

# from the repository root
docker compose up -d mongodb && docker compose up -d --build

5) Access the app: - App: http://localhost:3000 - MongoDB is available inside the Docker network at host mongodb:27017

Notes - The app service depends_on the mongodb service. - Credentials are defined in Compose for the MongoDB root user; authSource=admin is required on the connection string for root. - Data persists across restarts via the docker volume.

Optional: Example MongoDB service definition used in this project:

services:
  mongodb:
    image: mongo:7
    container_name: mongodb
    restart: unless-stopped
    environment:
      MONGO_INITDB_ROOT_USERNAME: root
      MONGO_INITDB_ROOT_PASSWORD: example
    ports:
      - "27017:27017"
    volumes:
      - mongo-data:/data/db
    healthcheck:
      test: ["CMD", "mongosh", "--eval", "db.adminCommand('ping')"]
      interval: 10s
      timeout: 5s
      retries: 5

volumes:
  mongo-data:

🔐 Environment Variables

Create .env at the project root. Choose either a hosted MongoDB (Atlas) URI or the local Docker URI.

Hosted (MongoDB Atlas):

# Core
NODE_ENV=development

# Database (Atlas)
MONGODB_URI=mongodb+srv://<user>:<pass>@<cluster>/<db>?retryWrites=true&w=majority

# Better Auth
BETTER_AUTH_SECRET=your_better_auth_secret
BETTER_AUTH_URL=http://localhost:3000

# Finnhub
# Note: NEXT_PUBLIC_FINNHUB_API_KEY is required for Vercel deployment
NEXT_PUBLIC_FINNHUB_API_KEY=your_finnhub_key
FINNHUB_BASE_URL=https://finnhub.io/api/v1

# Sentiment insights (optional)
ADANOS_API_KEY=your_adanos_api_key
# ADANOS_API_BASE_URL=https://api.adanos.org

# AI Provider (optional, default: "gemini")
# Supported: "gemini", "minimax", "siray"
# AI_PROVIDER=gemini

# Gemini
GEMINI_API_KEY=your_gemini_api_key

# MiniMax (optional, used when AI_PROVIDER=minimax or as fallback)
# Get your key at https://platform.minimaxi.com
# MINIMAX_API_KEY=your_minimax_api_key

# Inngest Signing Key (required for Vercel deployment)
# Get this from your Inngest dashboard: https://app.inngest.com/env/settings/keys
INNGEST_SIGNING_KEY=your_inngest_signing_key

# Email (Nodemailer via Gmail; consider App Passwords if 2FA)
NODEMAILER_EMAIL=youraddress@gmail.com
NODEMAILER_PASSWORD=your_gmail_app_password

Local (Docker Compose) MongoDB:

# Core
NODE_ENV=development

# Database (Docker)
MONGODB_URI=mongodb://root:example@mongodb:27017/openstock?authSource=admin

# Better Auth
BETTER_AUTH_SECRET=your_better_auth_secret
BETTER_AUTH_URL=http://localhost:3000

# Finnhub
# Note: NEXT_PUBLIC_FINNHUB_API_KEY is required for Vercel deployment
NEXT_PUBLIC_FINNHUB_API_KEY=your_finnhub_key
FINNHUB_BASE_URL=https://finnhub.io/api/v1

# Sentiment insights (optional)
ADANOS_API_KEY=your_adanos_api_key
# ADANOS_API_BASE_URL=https://api.adanos.org

# AI Provider (optional, default: "gemini")
# Supported: "gemini", "minimax", "siray"
# AI_PROVIDER=gemini

# Gemini
GEMINI_API_KEY=your_gemini_api_key

# MiniMax (optional, used when AI_PROVIDER=minimax or as fallback)
# Get your key at https://platform.minimaxi.com
# MINIMAX_API_KEY=your_minimax_api_key

# Inngest Signing Key (required for Vercel deployment)
# Get this from your Inngest dashboard: https://app.inngest.com/env/settings/keys
INNGEST_SIGNING_KEY=your_inngest_signing_key

# Email (Nodemailer via Gmail; consider App Passwords if 2FA)
NODEMAILER_EMAIL=youraddress@gmail.com
NODEMAILER_PASSWORD=your_gmail_app_password

Notes - Keep private keys server-side whenever possible. - If using NEXT_PUBLIC_ variables, remember they are exposed to the browser. - In production, prefer a dedicated SMTP provider over a personal Gmail. - Do not hardcode secrets in the Dockerfile; use .env and Compose.

🧱 Project Structure

app/
  (auth)/
    layout.tsx
    sign-in/page.tsx
    sign-up/page.tsx
  (root)/
    layout.tsx
    page.tsx
    help/page.tsx
    stocks/[symbol]/page.tsx
  api/inngest/route.ts
  globals.css
  layout.tsx
components/
  ui/…          # shadcn/radix primitives (button, dialog, command, input, etc.)
  forms/…       # InputField, SelectField, CountrySelectField, FooterLink
  Header.tsx, Footer.tsx, SearchCommand.tsx, WatchlistButton.tsx, …
database/
  models/watchlist.model.ts
  mongoose.ts
lib/
  actions/…     # server actions (auth, finnhub, user, watchlist)
  better-auth/…
  inngest/…     # client, functions, prompts
  nodemailer/…  # transporter, email templates
  constants.ts, utils.ts
scripts/
  test-db.mjs
types/
  global.d.ts
next.config.ts          # i.ibb.co image domain allowlist
postcss.config.mjs      # Tailwind v4 postcss setup
components.json         # shadcn config
public/assets/images/   # logos and screenshots

📡 Data & Integrations

  • Finnhub

    • Stock search, company profiles, and market news.
    • Set NEXT_PUBLIC_FINNHUB_API_KEY and FINNHUB_BASE_URL (default: https://finnhub.io/api/v1).
    • Free tiers may return delayed quotes; respect rate limits and terms.
  • Adanos sentiment insights (optional)

    • Structured stock sentiment snapshots across Reddit, X.com, news, and Polymarket.
    • Set ADANOS_API_KEY; optionally override the API host with ADANOS_API_BASE_URL.
    • Used only for the stock detail sentiment card and does not replace Finnhub or TradingView.
  • TradingView

    • Embeddable widgets used for charts, heatmap, q

Extension points exported contracts — how you extend this code

TradingViewWidgetProps (Interface)
(no doc)
components/TradingViewWidget.tsx
WatchlistButtonProps (Interface)
(no doc)
components/WatchlistButton.tsx
TradingViewWatchlistProps (Interface)
(no doc)
components/watchlist/TradingViewWatchlist.tsx
StockSentimentCardProps (Interface)
(no doc)
components/stocks/StockSentimentCard.tsx
WatchlistItem (Interface)
(no doc)
database/models/watchlist.model.ts
AIProviderConfig (Interface)
(no doc)
lib/ai-provider.ts
KitConfig (Interface)
(no doc)
lib/kit.ts
SentimentSourceInsight (Interface)
(no doc)
lib/actions/adanos.helpers.ts

Core symbols most depended-on inside this repo

cn
called by 45
lib/utils.ts
formatSymbolForTradingView
called by 32
lib/utils.ts
connectToDatabase
called by 17
database/mongoose.ts
callAIProvider
called by 15
lib/ai-provider.ts
getProviderConfig
called by 8
lib/ai-provider.ts
formatMarketCapValue
called by 8
lib/utils.ts
callAIProviderWithFallback
called by 6
lib/ai-provider.ts
getStockSentimentInsights
called by 6
lib/actions/adanos.actions.ts

Shape

Function 216
Interface 16

Languages

TypeScript100%

Modules by API surface

lib/utils.ts17 symbols
components/ui/dropdown-menu.tsx15 symbols
components/ui/select.tsx10 symbols
components/ui/dialog.tsx10 symbols
lib/actions/adanos.helpers.ts9 symbols
components/ui/command.tsx9 symbols
lib/ai-provider.ts7 symbols
lib/constants.ts6 symbols
lib/actions/finnhub.actions.ts6 symbols
components/stocks/StockSentimentCard.tsx6 symbols
lib/actions/watchlist.actions.ts5 symbols
lib/actions/auth.actions.ts5 symbols

Dependencies from manifests, versioned

@eslint/eslintrc3 · 1×
@radix-ui/react-avatar1.1.10 · 1×
@radix-ui/react-dialog1.1.15 · 1×
@radix-ui/react-dropdown-menu2.1.16 · 1×
@radix-ui/react-label2.1.7 · 1×
@radix-ui/react-popover1.1.15 · 1×
@radix-ui/react-slot1.2.3 · 1×
@types/node20 · 1×
@types/nodemailer7.0.2 · 1×
@types/react19 · 1×

Datastores touched

(mongodb)Database · 1 repos
openstockDatabase · 1 repos

For agents

$ claude mcp add OpenStock \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact