Skip to content

StockPulse - Real-time Stock Market Tracker | Enterprise-grade Next.js 15 + React 19 + TypeScript stock market tracking application with comprehensive TypeScript utilities, Vercel deployment, and PWA capabilities.

Notifications You must be signed in to change notification settings

ryarturogi/stock-pulse

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

123 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

StockPulse - Real-time Stock Market Tracker

Enterprise-grade Next.js 15 + React 19 + TypeScript stock market tracking application with comprehensive TypeScript utilities, Vercel deployment, and PWA capabilities.

πŸ“Š Project Status

βœ… Complete Implementation - Full stock tracking application with real-time data 🎯 User Experience - Interactive guided tour system for seamless onboarding πŸ“¦ TypeScript Utilities - Comprehensive type system for enhanced developer experience
πŸš€ Production Ready - Full Vercel deployment with automated CI/CD pipeline πŸ§ͺ Testing Framework - Complete testing setup with Jest and Playwright πŸ“– Documentation - Comprehensive guides and compliance documentation

Status: Ready for production deployment and demo with complete user onboarding

πŸš€ Features

  • Next.js 15 + React 19 - Latest framework features with React Compiler optimizations
  • Enterprise Architecture - Feature-based module organization with clear separation of concerns
  • TypeScript-First Development - Comprehensive utility types for type safety and consistency
  • Real-time Stock Tracking - Live market data with secure API polling and WebSocket fallback
  • WebPush Notifications - Price alerts using Web Notifications API with Service Worker
  • Progressive Web App - Offline functionality and app-like experience
  • Guided User Tour - Interactive onboarding with Intro.js for new users
  • Production Ready - Secure API handling, rate limiting, and Vercel deployment
  • Developer Experience - Cursor IDE and Claude Code rules for enhanced productivity

πŸ› οΈ Tech Stack

Core Framework

  • Framework: Next.js 15 (App Router) with React Compiler & Turbopack
  • UI Library: React 19 with Concurrent Features
  • Language: TypeScript 5.6 (Strict Mode)
  • Styling: Tailwind CSS 3.4 + PostCSS
  • State Management: Zustand 5.0

Development & Testing

  • Testing: Jest + React Testing Library 16 + Playwright
  • User Experience: Shepherd.js guided tours for onboarding
  • Linting: ESLint 9 (Flat Config) + Prettier 3.3
  • Git Hooks: Husky + lint-staged
  • Package Manager: pnpm 8+

Deployment & Infrastructure

  • Hosting: Vercel with Edge Functions and built-in CI/CD
  • PWA: next-pwa with Service Worker and Push Notifications
  • Automation: Vercel Git integration with automatic deployments
  • Monitoring: Health checks and error tracking ready

TypeScript Architecture

  • Utility Types: Comprehensive type utilities in /types/utils.ts
  • Type Safety: Runtime type guards and validation
  • API Types: Consistent ApiResponse<T> and ApiError patterns
  • Component Types: Standardized props with utility types

πŸ“‹ Prerequisites

  • Node.js >= 20.0.0 (required for Next.js 15)
  • pnpm >= 8.0.0

πŸš€ Quick Start

  1. Clone the repository

    git clone https://github.com/ryarturogi/stock-pulse/
    cd stock-pulse
  2. Install dependencies

    pnpm install
  3. Set up environment variables

    cp .env.example .env.local
    # Edit .env.local with your API keys and configuration
  4. Push notifications are ready to use (no VAPID required)

    # Push notifications work out of the box without additional setup
  5. Start the development server

    pnpm run dev
  6. Open your browser Navigate to http://localhost:3000

πŸ“š Available Scripts

  • pnpm run dev - Start development server
  • pnpm run build - Build for production
  • pnpm run start - Start production server
  • pnpm run lint - Run ESLint
  • pnpm run lint:fix - Fix ESLint issues
  • pnpm run format - Format code with Prettier
  • pnpm run format:check - Check code formatting
  • pnpm run type-check - Run TypeScript type checking
  • pnpm run test - Run unit tests
  • pnpm run test:watch - Run tests in watch mode
  • pnpm run test:coverage - Run tests with coverage
  • pnpm run test:e2e - Run end-to-end tests
  • pnpm run test:e2e:ui - Run E2E tests with UI
  • pnpm run test:e2e:debug - Debug E2E tests
  • pnpm run build:analyze - Build with bundle analyzer
  • pnpm run deploy:vercel - Deploy to Vercel production
  • pnpm run deploy:preview - Deploy to Vercel preview
  • pnpm run vercel:env - Pull environment variables from Vercel

πŸ”§ Configuration

Environment Variables

Create environment files for different stages. See .env.example for all available variables.

Development (.env.local)

# =============================================================================
# StockPulse Environment Configuration
# =============================================================================

# 🌐 PUBLIC VARIABLES (Client-side accessible)
NEXT_PUBLIC_APP_NAME=StockPulse
NEXT_PUBLIC_APP_VERSION=1.0.0
NEXT_PUBLIC_FEATURE_PORTFOLIO=true
NEXT_PUBLIC_FEATURE_ALERTS=true

# πŸ”’ PRIVATE VARIABLES (Server-side only)
# Stock API Keys
FINNHUB_API_KEY=your_finnhub_api_key

# Push Notifications (No VAPID required)
# Push notifications work without additional configuration

# CORS Configuration
CORS_ORIGIN=http://localhost:3000

Production

Use Vercel environment variables or .env.production for production deployment.

⚠️ Security Note: Never commit secrets to git. Use Vercel's environment variable management.

API Keys

You'll need API keys from:

  1. Finnhub - Get API Key

πŸ—οΈ Project Structure

stock-pulse/
β”œβ”€β”€ app/                           # Next.js 15 App Router
β”‚   β”œβ”€β”€ api/                      # API routes
β”‚   β”‚   β”œβ”€β”€ health/              # Health check endpoint
β”‚   β”‚   β”œβ”€β”€ quote/               # Stock quote endpoints
β”‚   β”‚   β”œβ”€β”€ push/                # Push notification APIs
β”‚   β”‚   └── cron/                # Vercel cron jobs
β”‚   β”œβ”€β”€ layout.tsx               # Root layout with React 19
β”‚   β”œβ”€β”€ page.tsx                 # Home page
β”‚   β”œβ”€β”€ loading.tsx              # Global loading UI
β”‚   β”œβ”€β”€ error.tsx                # Global error UI
β”‚   └── globals.css              # Global Tailwind styles
β”œβ”€β”€ src/                         # Enterprise source structure
β”‚   β”œβ”€β”€ core/                    # Core application modules
β”‚   β”‚   β”œβ”€β”€ types/               # TypeScript type definitions
β”‚   β”‚   β”‚   β”œβ”€β”€ index.ts         # Central type exports
β”‚   β”‚   β”‚   β”œβ”€β”€ utils.ts         # Utility types
β”‚   β”‚   β”‚   └── stock.ts         # Stock-specific types
β”‚   β”‚   └── utils/               # Core utility functions
β”‚   β”œβ”€β”€ features/                # Feature-based modules
β”‚   β”‚   β”œβ”€β”€ stocks/              # Stock tracking feature
β”‚   β”‚   β”‚   β”œβ”€β”€ components/      # Stock-related components
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ StockForm.tsx
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ StockCard.tsx
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ StockChart.tsx
β”‚   β”‚   β”‚   β”‚   └── index.ts
β”‚   β”‚   β”‚   β”œβ”€β”€ services/        # Stock API services
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ stockService.ts
β”‚   β”‚   β”‚   β”‚   └── index.ts
β”‚   β”‚   β”‚   β”œβ”€β”€ stores/          # Stock state management
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ stockStore.ts
β”‚   β”‚   β”‚   β”‚   └── index.ts
β”‚   β”‚   β”‚   └── index.ts         # Feature exports
β”‚   β”‚   └── notifications/       # Notification feature
β”‚   β”‚       β”œβ”€β”€ services/        # Notification services
β”‚   β”‚       β”‚   β”œβ”€β”€ notificationService.ts
β”‚   β”‚       β”‚   └── index.ts
β”‚   β”‚       └── index.ts         # Feature exports
β”‚   β”œβ”€β”€ shared/                  # Shared modules
β”‚   β”‚   β”œβ”€β”€ components/          # Shared components
β”‚   β”‚   β”‚   └── ui/              # Base UI components
β”‚   β”‚   β”‚       β”œβ”€β”€ Button.tsx
β”‚   β”‚   β”‚       └── index.ts
β”‚   β”‚   β”œβ”€β”€ hooks/               # Shared custom hooks
β”‚   β”‚   β”‚   β”œβ”€β”€ useTour.ts       # Guided tour functionality
β”‚   β”‚   β”‚   β”œβ”€β”€ useTourConfig.ts # Tour step configurations
β”‚   β”‚   β”‚   └── index.ts
β”‚   β”‚   └── utils/               # Shared utility functions
β”‚   └── styles/                  # Global styles and themes
β”‚       └── intro.css            # Tour component styling
β”œβ”€β”€ public/                      # Static assets
β”‚   β”œβ”€β”€ manifest.json           # PWA manifest
β”‚   β”œβ”€β”€ sw.js                   # Service worker (next-pwa)
β”‚   └── icons/                  # App icons
β”œβ”€β”€ docs/                        # Comprehensive documentation
β”‚   β”œβ”€β”€ ARCHITECTURE.md         # System architecture
β”‚   β”œβ”€β”€ VERCEL-DEPLOYMENT.md    # Deployment guide
β”‚   └── TEST-REVIEW.md          # Testing strategy
β”œβ”€β”€ claude.rules/               # Claude Code development prompts
β”‚   β”œβ”€β”€ create-component.prompt  # Component creation template
β”‚   β”œβ”€β”€ create-api-route.prompt  # API route template
β”‚   β”œβ”€β”€ create-page.prompt       # Page creation template
β”‚   └── bootstrap-dev-env.prompt # Environment setup
β”œβ”€β”€ tests/                      # Test files and configurations
β”œβ”€β”€ vercel.json                 # Vercel deployment configuration
β”œβ”€β”€ .cursorrules               # Cursor IDE configuration
└── tailwind.config.js         # Tailwind CSS configuration

🏒 Enterprise Architecture

Feature-Based Module Organization

StockPulse follows an enterprise-level architecture with clear separation of concerns:

Core Modules (/src/core/)

  • Types - Centralized TypeScript definitions with comprehensive utility types
  • Utils - Core application utilities and shared business logic

Feature Modules (/src/features/)

  • Stocks - Complete stock tracking functionality with components, services, and state
  • Notifications - WebPush notification system with Service Worker integration
  • Each feature is self-contained with its own components, services, and stores

Shared Modules (/src/shared/)

  • Components - Reusable UI components across features
  • Hooks - Shared React hooks for common functionality
  • Utils - Feature-agnostic utility functions

Import Path Strategy

// Core types and utilities
import { StockOption, ApiResponse } from '@/core/types';

// Feature-specific functionality
import { useStockStore, StockForm } from '@/features/stocks';
import { getNotificationService } from '@/features/notifications';

// Shared components and utilities
import { Button } from '@/shared/components/ui';

Benefits

  • Scalability - Easy to add new features without affecting existing code
  • Maintainability - Clear boundaries between different application concerns
  • Testability - Isolated modules can be tested independently
  • Team Collaboration - Different teams can work on different features simultaneously
  • Code Reusability - Shared components and utilities prevent duplication

πŸ”§ TypeScript Utilities

This project includes comprehensive TypeScript utilities for enhanced type safety and developer experience:

Core Utility Types

import { ApiResponse, AsyncState, ComponentProps, DeepPartial, isDefined } from '@/core/types';

// API responses
const response: ApiResponse<UserData> = await fetchUser();

// Component props with utilities
interface ButtonProps extends ComponentProps, Disableable, Sizeable {
  variant: 'primary' | 'secondary';
}

// Async state management
const [userState, setUserState] = useState<AsyncState<User>>({
  loading: true,
  data: undefined,
  error: undefined,
});

// Runtime type checking
if (isDefined(data) && isString(data.name)) {
  // Type-safe operations
}

Available Utility Categories

  • Basic Types: DeepPartial, RequiredBy, PartialBy, OptionalExcept
  • API Types: ApiResponse, ApiError, PaginatedResponse, HttpMethod
  • Component Types: ComponentProps, WithClassName, Disableable, Loadable
  • State Types: AsyncState, FormState, ValidationResult
  • Type Guards: isDefined, isString, isNumber, isBoolean, isObject

πŸ§ͺ Testing

Unit Tests

pnpm run test                # Run all unit tests
pnpm run test:watch         # Run tests in watch mode
pnpm run test:coverage      # Run tests with coverage report

End-to-End Tests

pnpm run test:e2e           # Run E2E tests
pnpm run test:e2e:ui        # Run E2E tests with UI
pnpm run test:e2e:debug     # Debug E2E tests

πŸš€ Deployment

Vercel Deployment (Recommended)

Automated Setup

# Install Vercel CLI
npm install -g vercel

# Login and deploy
vercel login
vercel

# Set up environment variables manually in Vercel dashboard

# Deploy to production
pnpm run deploy:vercel

Manual Environment Setup

# Add production environment variables
vercel env add FINNHUB_API_KEY production

# Pull environment variables locally
vercel env pull .env.local

Production Build

pnpm run build             # Build for production
pnpm run start             # Start production server locally

Vercel Deployment Features

  • Git Integration - Automatic deployments on every push to main
  • Preview Deployments - Every PR gets a unique preview URL with full functionality
  • Cron Jobs - Automated stock price updates every 5 minutes via Vercel Cron
  • Edge Functions - Global performance optimization and fast response times
  • Built-in Analytics - Performance monitoring and Core Web Vitals tracking
  • Health Monitoring - /api/health endpoint for uptime monitoring

See Vercel Deployment Guide for detailed instructions.

πŸ“± PWA Features

  • Offline Support - Works without internet connection
  • Push Notifications - Real-time price alerts
  • App-like Experience - Install on mobile/desktop
  • Background Sync - Sync data when connection is restored

🎯 User Experience Features

Interactive Guided Tour

  • Auto-start for New Users - Comprehensive 10-step onboarding tour using Intro.js
  • Smart Navigation - Context-aware tour that opens/closes UI elements as needed
  • Mobile Optimized - Responsive tour steps with touch-friendly interactions
  • Dark Mode Compatible - Tour styling adapts to user's theme preference
  • Manual Restart - Help button (?) in header allows users to replay the tour anytime

Tour Coverage

  1. Welcome & Introduction - Overview of StockPulse functionality
  2. Add Stock Button - How to open the stock form sidebar
  3. Stock Search - Using the search functionality to find any stock
  4. Price Alerts - Setting up custom price alert thresholds
  5. Notifications - Enabling browser notifications for alerts
  6. Live Data Controls - Configuring real-time data refresh settings
  7. Theme Customization - Switching between light and dark modes
  8. Dashboard Overview - Understanding stock cards and performance indicators
  9. Chart Interaction - Using the interactive price chart for analysis

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Development Guidelines

  • Enterprise Architecture - Follow feature-based module organization with clear separation of concerns
  • Use TypeScript Utils - Always import from @/core/types instead of creating custom types
  • Feature Module Structure - Group related components, services, and stores within feature modules
  • Follow Strict Typing - Use utility types for consistent API responses and component props
  • Write Comprehensive Tests - Unit tests for components, integration tests for API routes
  • Use Conventional Commits - Follow conventional commit message format
  • Pre-commit Checks - Linting, formatting, and type checking run automatically
  • Update Documentation - Keep README and docs in sync with changes

πŸ§‘β€πŸ’» Developer Experience

IDE Configuration

  • Cursor IDE Rules - Pre-configured .cursorrules for optimal development
  • Claude Code Prompts - Standardized templates in claude.rules/ directory
  • TypeScript IntelliSense - Enhanced auto-completion with utility types
  • Import Organization - Automatic import sorting with @/core/types prioritization

Code Generation Templates

# Available Claude Code prompts:
claude.rules/create-component.prompt    # React component with TypeScript utils
claude.rules/create-api-route.prompt    # Next.js API route with type safety
claude.rules/create-page.prompt         # Next.js page with proper metadata
claude.rules/bootstrap-dev-env.prompt   # Full project setup template

Development Workflow

  1. Type-First Development - Define types before implementation
  2. Component-Driven - Build reusable components with utility types
  3. API-First - Design API contracts with consistent response types
  4. Test-Driven - Write tests using TypeScript utilities for type safety

πŸ“ Code Quality

  • TypeScript 5.6 - Strict mode with comprehensive utility types
  • ESLint 9 - Flat config with Next.js and TypeScript rules
  • Prettier 3.3 - Consistent code formatting
  • Jest + RTL - Unit testing with TypeScript support
  • Playwright - E2E testing with type-safe page objects
  • Vercel Security - Built-in security scanning and dependency updates

πŸ”’ Security

  • Input validation and sanitization
  • API rate limiting
  • Secure headers configured
  • Environment variable protection
  • Regular dependency updates

πŸ“Š Performance

  • Next.js optimizations (SSR, ISR, Image optimization)
  • Code splitting and lazy loading
  • Bundle analysis and optimization
  • Lighthouse performance monitoring
  • Core Web Vitals tracking

πŸ“– Documentation

Core Documentation

Development Resources

API Documentation

πŸ“ˆ Current Application State

βœ… Implemented Features

Core Functionality

  • Stock Selection & Watchlist - Users can select from predefined stocks (AAPL, GOOGL, MSFT, AMZN, TSLA, META, NVDA, NFLX)
  • Price Alerts - Users can set custom price alert thresholds for each watched stock
  • Real-time Data Updates - Secure API polling every 30 seconds (minimum) for rate limit compliance
  • Price History Tracking - 100 data points per stock for chart visualization

User Interface

  • Responsive Design - Left sidebar form, main dashboard with search functionality
  • Dark/Light Mode - Theme toggle with system preference detection
  • Guided Tour System - Interactive onboarding with Shepherd.js for new user education
  • Stock Cards - Real-time price display with change indicators and trend visualization
  • Interactive Charts - Recharts integration with multiple time ranges (1H, 1D, 1W, 1M)
  • Search & Filter - Real-time search across watched stocks by symbol or name

Notifications

  • WebPush Notifications - Price alerts using Web Notifications API + Service Worker
  • Permission Management - User-controlled notification enable/disable with browser permission handling
  • Smart Alerting - Only notifies when price crosses alert threshold (prevents spam)

Technical Implementation

  • Enterprise Architecture - Feature-based modules with clear separation of concerns
  • TypeScript-First - Comprehensive type safety with utility types and runtime guards
  • State Persistence - Zustand store with localStorage for watched stocks persistence
  • Error Handling - Comprehensive error boundaries and user-friendly error messages
  • Security - Server-side API keys, client-side rate limiting, input validation

πŸ—οΈ Architecture Highlights

API Integration

  • Finnhub Stock API - Real-time stock quotes with proper error handling
  • Secure Server-Side Calls - API keys never exposed to client-side
  • Rate Limiting Compliance - 30-second minimum refresh intervals
  • Fallback Mechanisms - Graceful degradation when API is unavailable

State Management

  • Zustand Store - Lightweight, type-safe state management
  • localStorage Persistence - Watched stocks survive page refreshes
  • Optimistic Updates - Immediate UI feedback with error rollback
  • Selective Re-renders - Optimized selectors prevent unnecessary component updates

Performance Optimizations

  • Code Splitting - Feature-based modules loaded on demand
  • Component Memoization - React.memo and useMemo for expensive operations
  • Bundle Optimization - Next.js automatic optimizations with Turbopack
  • Progressive Loading - Lazy loading for charts and non-critical components

🎯 Production Readiness

Security

  • βœ… Environment variable security audit completed
  • βœ… API keys properly secured on server-side
  • βœ… Input validation and sanitization
  • βœ… CORS configuration for production deployment
  • βœ… Rate limiting implemented for API protection

Performance

  • βœ… Next.js production build optimization
  • βœ… TypeScript compilation without errors
  • βœ… ESLint and Prettier code quality checks
  • βœ… Bundle size optimization with tree shaking
  • βœ… Core Web Vitals optimized

Deployment

  • βœ… Vercel deployment configuration complete
  • βœ… Environment variable setup for production
  • βœ… PWA manifest and service worker configured
  • βœ… Automated CI/CD pipeline ready
  • βœ… Health check endpoint for monitoring

πŸ”§ Technical Specifications

Dependencies

  • Next.js 15 - App Router with React 19 and React Compiler
  • TypeScript 5.6 - Strict mode with comprehensive utility types
  • Tailwind CSS 3.4 - Utility-first styling with custom configuration
  • Zustand 5.0 - State management with persistence middleware
  • Recharts - Chart visualization with responsive design
  • Intro.js 8.3 - Interactive guided tours for user onboarding
  • Lucide React - Modern icon system with tree shaking

Browser Support

  • Modern Browsers - Chrome 88+, Firefox 87+, Safari 14+, Edge 88+
  • PWA Features - Service Worker, Web Notifications, App Install
  • Mobile Support - Responsive design with touch-friendly interactions
  • Offline Capability - Basic functionality available without network

πŸš€ Demo Instructions

  1. Initial Setup

    git clone <repository>
    cd stock-pulse
    pnpm install
    cp .env.example .env.local
    # Add your FINNHUB_API_KEY to .env.local
    pnpm run dev
  2. Test the Application

    • Open http://localhost:3000
    • Experience the guided tour - Automatically starts for new users
    • Add a stock (e.g., AAPL) with a price alert (e.g., $150)
    • Enable notifications when prompted
    • Watch real-time price updates in the dashboard
    • Toggle between dark/light modes
    • Search for stocks in the search bar
    • Restart the tour anytime - Click the help (?) button in the header
  3. Production Deployment

    vercel login
    vercel
    # Set environment variables in Vercel dashboard
    vercel --prod

πŸ“Š Metrics & Monitoring

  • API Response Times - < 500ms average for stock quotes
  • Page Load Performance - Lighthouse score 90+ for all metrics
  • Error Tracking - Console logging with error boundaries
  • User Experience - Optimistic updates with 100ms response time
  • Notification Delivery - < 1 second from price threshold trigger

πŸ™ Acknowledgments

  • Next.js team for the amazing framework
  • Tailwind CSS for the utility-first CSS framework
  • Finnhub for market data APIs
  • The open-source community for the excellent libraries

About

StockPulse - Real-time Stock Market Tracker | Enterprise-grade Next.js 15 + React 19 + TypeScript stock market tracking application with comprehensive TypeScript utilities, Vercel deployment, and PWA capabilities.

Topics

Resources

Stars

Watchers

Forks

Contributors 2

  •  
  •