Enterprise-grade Next.js 15 + React 19 + TypeScript stock market tracking application with comprehensive TypeScript utilities, Vercel deployment, and PWA capabilities.
β
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
- 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
- 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
- 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+
- 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
- Utility Types: Comprehensive type utilities in
/types/utils.ts - Type Safety: Runtime type guards and validation
- API Types: Consistent
ApiResponse<T>andApiErrorpatterns - Component Types: Standardized props with utility types
- Node.js >= 20.0.0 (required for Next.js 15)
- pnpm >= 8.0.0
-
Clone the repository
git clone https://github.com/ryarturogi/stock-pulse/ cd stock-pulse -
Install dependencies
pnpm install
-
Set up environment variables
cp .env.example .env.local # Edit .env.local with your API keys and configuration -
Push notifications are ready to use (no VAPID required)
# Push notifications work out of the box without additional setup -
Start the development server
pnpm run dev
-
Open your browser Navigate to http://localhost:3000
pnpm run dev- Start development serverpnpm run build- Build for productionpnpm run start- Start production serverpnpm run lint- Run ESLintpnpm run lint:fix- Fix ESLint issuespnpm run format- Format code with Prettierpnpm run format:check- Check code formattingpnpm run type-check- Run TypeScript type checkingpnpm run test- Run unit testspnpm run test:watch- Run tests in watch modepnpm run test:coverage- Run tests with coveragepnpm run test:e2e- Run end-to-end testspnpm run test:e2e:ui- Run E2E tests with UIpnpm run test:e2e:debug- Debug E2E testspnpm run build:analyze- Build with bundle analyzerpnpm run deploy:vercel- Deploy to Vercel productionpnpm run deploy:preview- Deploy to Vercel previewpnpm run vercel:env- Pull environment variables from Vercel
Create environment files for different stages. See .env.example for all available variables.
# =============================================================================
# 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:3000Use Vercel environment variables or .env.production for production deployment.
You'll need API keys from:
- Finnhub - Get API Key
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
StockPulse follows an enterprise-level architecture with clear separation of concerns:
- Types - Centralized TypeScript definitions with comprehensive utility types
- Utils - Core application utilities and shared business logic
- 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
- Components - Reusable UI components across features
- Hooks - Shared React hooks for common functionality
- Utils - Feature-agnostic utility functions
// 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';- 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
This project includes comprehensive TypeScript utilities for enhanced type safety and developer experience:
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
}- 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
pnpm run test # Run all unit tests
pnpm run test:watch # Run tests in watch mode
pnpm run test:coverage # Run tests with coverage reportpnpm run test:e2e # Run E2E tests
pnpm run test:e2e:ui # Run E2E tests with UI
pnpm run test:e2e:debug # Debug E2E tests# 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# Add production environment variables
vercel env add FINNHUB_API_KEY production
# Pull environment variables locally
vercel env pull .env.localpnpm run build # Build for production
pnpm run start # Start production server locally- 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/healthendpoint for uptime monitoring
See Vercel Deployment Guide for detailed instructions.
- 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
- 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
- Welcome & Introduction - Overview of StockPulse functionality
- Add Stock Button - How to open the stock form sidebar
- Stock Search - Using the search functionality to find any stock
- Price Alerts - Setting up custom price alert thresholds
- Notifications - Enabling browser notifications for alerts
- Live Data Controls - Configuring real-time data refresh settings
- Theme Customization - Switching between light and dark modes
- Dashboard Overview - Understanding stock cards and performance indicators
- Chart Interaction - Using the interactive price chart for analysis
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- Enterprise Architecture - Follow feature-based module organization with clear separation of concerns
- Use TypeScript Utils - Always import from
@/core/typesinstead 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
- Cursor IDE Rules - Pre-configured
.cursorrulesfor 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/typesprioritization
# 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- Type-First Development - Define types before implementation
- Component-Driven - Build reusable components with utility types
- API-First - Design API contracts with consistent response types
- Test-Driven - Write tests using TypeScript utilities for type safety
- 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
- Input validation and sanitization
- API rate limiting
- Secure headers configured
- Environment variable protection
- Regular dependency updates
- Next.js optimizations (SSR, ISR, Image optimization)
- Code splitting and lazy loading
- Bundle analysis and optimization
- Lighthouse performance monitoring
- Core Web Vitals tracking
- π Architecture Guide - System design and technical decisions
- π§ͺ Testing Strategy - Comprehensive testing approach
- π Vercel Deployment - Complete deployment guide with automation
- π§ TypeScript Utilities - Comprehensive utility types documentation
- ποΈ Enterprise Architecture - Feature-based module organization
- π― Component Templates - Standardized development prompts
- βοΈ IDE Configuration - Cursor IDE optimization rules
- πͺ Tour Integration - Complete guided tour implementation with Intro.js
- π₯ Health Check - Application health monitoring
- β° Cron Jobs - Automated background tasks
- API documentation will be generated with business logic implementation
- 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
- 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
- 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)
- 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
- 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
- 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
- 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
- β 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
- β 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
- β 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
- 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
- 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
-
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
-
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
-
Production Deployment
vercel login vercel # Set environment variables in Vercel dashboard vercel --prod
- 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
- 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