Skip to content

giaphutran12/stocktwits-clone-2

Repository files navigation

Stolk

A social platform for stock traders where users can share ideas, track sentiment, and get AI-powered insights on market discussions.

What is Stolk?

Stolk (Stocks + Stalking) is a Twitter-style platform built specifically for stock traders. Users can:

  • Write posts and tag stocks using the $TICKER format (e.g., $AAPL, $TSLA)
  • Mark their sentiment as Bullish, Bearish, or Neutral on each post
  • View aggregated community sentiment for any stock
  • Get AI-generated summaries of what the community is saying
  • See news sentiment analysis with recent headlines

The goal is to help traders quickly understand market sentiment without reading through hundreds of individual posts.

Screenshots

Community Sentiment

Real-time sentiment aggregation from user posts with interactive donut chart and AI-generated insights.

Community Sentiment

News Sentiment

AI-powered analysis of recent news headlines with sentiment classification and key themes.

News Sentiment

Stock Charts

Interactive price charts with multiple timeframe options (1D, 5D, 1M, 3M, 6M, 1Y, 5Y).

Stock Charts

Post Feed with AI Analysis

Community posts with sentiment badges, AI quality ratings, and engagement features.

Post Feed

User Profiles

User profile pages showing post history and account information.

User Profile

Features

Community Sentiment

  • Real-time sentiment aggregation from user posts
  • Breakdown by Bullish / Bearish / Neutral percentages
  • Filter by time period (24h, 7d, 30d)
  • Visual donut chart showing sentiment distribution

AI Insights

  • Claude AI analyzes quality posts and extracts key themes
  • Generates summaries of community discussions
  • Sentiment strength indicators (Strong, Moderate, Weak, Mixed)
  • Confidence ratings for analysis accuracy

News Sentiment

  • Fetches recent news articles for each stock
  • AI-powered sentiment classification of headlines
  • Displays latest headlines with source attribution
  • 30-minute refresh cycle via background jobs

Stock Data

  • Real-time quotes from Yahoo Finance
  • Interactive price charts with multiple timeframes
  • Key stats: market cap, volume, 52-week range

User Features

  • Authentication via Clerk (sign up, sign in, profile)
  • Post creation with $TICKER auto-detection
  • Stock search with autocomplete
  • User profiles showing post history

Tech Stack

Category Technology
Framework Next.js 16, React 19
Language TypeScript
Styling Tailwind CSS 4, shadcn/ui
Database Neon (PostgreSQL)
ORM Prisma
Auth Clerk
Stock Data yahoo-finance2
AI Anthropic Claude (claude-sonnet-4-20250514)
Background Jobs Inngest
Charts Recharts
Deployment Vercel

Getting Started

Prerequisites

  • Node.js 18+
  • npm or yarn
  • PostgreSQL database (recommend Neon for serverless)
  • API keys for Clerk, Anthropic, and Finnhub

Installation

  1. Clone the repository
git clone https://github.com/yourusername/stolk.git
cd stolk
  1. Install dependencies
npm install
  1. Set up environment variables
cp .env.example .env
  1. Configure your .env file with the required keys (see Environment Variables below)

  2. Set up the database

npx prisma generate
npx prisma db push
  1. Run the development server
npm run dev
  1. Open http://localhost:3000

Environment Variables

Create a .env file with the following:

# Clerk Authentication
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=pk_test_...
CLERK_SECRET_KEY=sk_test_...

# Database
DATABASE_URL=postgresql://...

# Anthropic (AI)
ANTHROPIC_API_KEY=sk-ant-...

# Finnhub (News)
FINNHUB_API_KEY=...

# Inngest (Background Jobs - optional for local dev)
INNGEST_SIGNING_KEY=...

Project Structure

stolk/
├── app/                    # Next.js app router
│   ├── api/               # API routes
│   │   ├── posts/         # Post CRUD
│   │   ├── stocks/        # Stock data, sentiment
│   │   └── webhooks/      # Clerk webhooks
│   ├── stock/[symbol]/    # Stock detail pages
│   └── profile/[username] # User profiles
├── components/
│   ├── post/              # Post form, card, list
│   ├── stock/             # Charts, sentiment displays
│   ├── layout/            # Header, navigation
│   └── ui/                # shadcn/ui components
├── lib/
│   ├── anthropic.ts       # Claude AI integration
│   ├── yahoo-finance.ts   # Stock data fetching
│   ├── finnhub.ts         # News API
│   ├── inngest/           # Background job definitions
│   └── db.ts              # Prisma client
└── prisma/
    └── schema.prisma      # Database schema

How It Works

Post Flow

  1. User writes a post with $TICKER mentions
  2. Post is saved to database with parsed tickers
  3. Inngest triggers background job to analyze post quality with Claude
  4. Analysis results (quality score, themes, summary) are stored

Sentiment Aggregation

  1. API counts posts by sentiment for requested ticker and time period
  2. If enough quality posts exist, Claude generates a summary
  3. Results are cached for 15 minutes to reduce API calls
  4. Frontend displays breakdown with donut chart and AI insights

News Sentiment

  1. Inngest scheduled job runs once per month to keep background costs low
  2. Fetches recent news from Finnhub for active stocks
  3. Claude analyzes headlines and calculates sentiment percentages
  4. Results cached in database, served to frontend

Development Notes

  • The PAUSE_ALL flag in lib/anthropic.ts can disable AI calls to save costs during development
  • Yahoo Finance requires Node.js runtime (not Edge) - stock API routes have runtime = "nodejs"
  • Clerk webhooks sync user data to the database; there's also an inline fallback in the posts API

License

MIT


Built by Edward Tran

About

Twitter for stocks

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors