Stock Ui
by juliandavis7
Stock analysis UI frontend. React + TypeScript with Tailwind CSS, shadcn/ui, Recharts. Use for React components, API integration, routing, state management, styling, charts visualization.
Skill Details
Repository Files
7 files in this skill directory
name: stock-ui description: Stock analysis UI frontend. React + TypeScript with Tailwind CSS, shadcn/ui, Recharts. Use for React components, API integration, routing, state management, styling, charts visualization.
Stock Insights UI Skill
A comprehensive React frontend for stock analysis featuring real-time data visualization, financial projections, and comparative analytics.
Tech Stack
- Framework: React 19 + React Router 7 (file-based routing)
- Language: TypeScript 5.8
- State Management: Zustand (with devtools)
- UI Components: shadcn/ui (Radix UI primitives)
- Styling: Tailwind CSS 4.1
- Charts: Recharts 2.15
- Authentication: Clerk
- Build Tool: Vite 6
- Icons: Lucide React, Tabler Icons
Project Structure
app/
├── routes/ # Page components (React Router 7 file-based)
│ ├── home.tsx # Landing page
│ ├── search.tsx # Stock metrics search
│ ├── compare.tsx # Multi-stock comparison
│ ├── charts.tsx # Financial charts visualization
│ ├── projections.tsx # Stock price projections calculator
│ └── financials.tsx # Financial statements viewer
├── components/ # Reusable React components
│ ├── charts/ # Chart-specific components
│ ├── homepage/ # Landing page sections
│ ├── dashboard/ # Dashboard layout components
│ └── ui/ # shadcn/ui base components
├── store/ # Zustand state management
│ └── stockStore.ts # Global app state
├── hooks/ # Custom React hooks
│ ├── useAuthenticatedFetch.ts # Clerk auth wrapper
│ └── use-mobile.ts # Responsive breakpoint
├── lib/ # Utility functions
│ └── utils.ts # cn() for Tailwind class merging
├── constants/ # Static data
│ └── homeModules.ts # Feature module definitions
├── root.tsx # Root layout with Clerk provider
└── routes.ts # Route configuration
Key Directories
app/routes/- Page-level components with route handlers (loaders, actions)app/components/ui/- Base UI primitives from shadcn/ui (Button, Card, Input, etc.)app/components/charts/- Recharts wrappers (RevenueChart, EPSChart, MarginChart)app/components/homepage/- Marketing page sections (navbar, pricing, features)app/store/- Zustand store with centralized state for metrics, charts, financialsapp/hooks/- Reusable hooks including authenticated API callsdocs/- Comprehensive UI specifications and implementation guides
Common Tasks
Creating Components
Components follow shadcn/ui patterns using Radix primitives and Tailwind CSS. Create functional components with TypeScript interfaces for props. Use the cn() utility from lib/utils.ts to merge Tailwind classes conditionally.
Example pattern:
interface MyComponentProps {
title: string;
onAction: () => void;
}
export function MyComponent({ title, onAction }: MyComponentProps) {
return (
<Card>
<CardHeader>
<CardTitle>{title}</CardTitle>
</CardHeader>
<CardContent>
<Button onClick={onAction}>Action</Button>
</CardContent>
</Card>
);
}
See references/components.md for detailed component hierarchy and examples.
Making API Calls
All API calls use the useAuthenticatedFetch hook which wraps requests with Clerk authentication tokens. The Zustand store provides centralized fetch actions with caching for /metrics, /charts, /financials, and /projections endpoints.
Pattern:
const { authenticatedFetch } = useAuthenticatedFetch();
const actions = useStockActions();
// Use store action (recommended - includes caching)
await actions.fetchCharts('AAPL', 'quarterly', authenticatedFetch);
// Or direct fetch (for custom endpoints)
const response = await authenticatedFetch(`${apiUrl}/custom`);
See references/api-client.md for complete API integration patterns and endpoint documentation.
Adding Routes
Routes use React Router 7's file-based routing. Create a new file in app/routes/ and register it in routes.ts. Each route can export loader (server-side data fetching), action (form handling), and default component.
Steps:
- Create
app/routes/my-route.tsx - Export default component and optional
loader/action - Add to
routes.ts:route("my-route", "routes/my-route.tsx")
See references/routing.md for routing patterns and protected routes.
Styling Components
Styling uses Tailwind CSS 4.1 with utility classes. Follow mobile-first responsive design patterns. Use the cn() utility to conditionally merge classes. shadcn/ui components accept className prop for customization.
Common patterns:
- Spacing:
p-4,px-6,py-2,space-y-4,gap-2 - Layout:
flex,grid,max-w-7xl,mx-auto,container - Colors:
bg-blue-500,text-gray-700,border-gray-200 - Responsive:
sm:text-lg,md:grid-cols-2,lg:max-w-4xl - States:
hover:bg-gray-100,focus:ring-2,disabled:opacity-50
See references/styling.md for Tailwind configuration and design tokens.
Building Charts
Charts use Recharts library with custom wrappers in app/components/charts/. Follow existing patterns for bar charts (Revenue, EPS, Operating Income) and line charts (Margins, Cash Flow). All charts support quarterly and TTM (trailing twelve months) modes.
Chart structure:
<ResponsiveContainer width="100%" height={400}>
<BarChart data={chartData}>
<CartesianGrid strokeDasharray="3 3" />
<XAxis dataKey="quarter" />
<YAxis />
<Tooltip />
<Bar dataKey="value" fill="#F59E0B" />
</BarChart>
</ResponsiveContainer>
Charts receive data from Zustand store's charts state, populated by /charts?ticker={symbol}&mode={quarterly|ttm} endpoint.
See references/components.md for chart component details and data structures.
State Management
Global state uses Zustand store (app/store/stockStore.ts) with separate slices for each feature:
globalTicker- Current selected stock symbolstockInfo- Price, market cap, shares outstandingsearch- Metrics search resultscompare- Multi-stock comparison datacharts- Chart data (revenue, EPS, margins, cash flows)projections- Base data and calculated projectionsfinancials- Historical and estimated financial statements
Usage:
// Access state
const chartsState = useChartsState();
const stockInfo = useStockInfo();
const actions = useStockActions();
// Update state
actions.setGlobalTicker('AAPL');
await actions.fetchCharts('AAPL', 'quarterly', authenticatedFetch);
See references/state-management.md for complete store structure and patterns.
API Endpoints
All endpoints require Clerk authentication via Bearer token:
GET /metrics?ticker={symbol}- Stock metrics (PE ratios, growth rates, margins)GET /charts?ticker={symbol}&mode={quarterly|ttm}- Chart data (revenue, EPS, margins, cash flows)GET /financials?ticker={symbol}- Financial statements (historical + estimates)GET /projections?ticker={symbol}- Base data for projections (revenue, net income, EPS)GET /stock-info?ticker={symbol}- Current stock info (price, market cap, shares)
Base URL: import.meta.env.VITE_API_BASE_URL
Development Commands
npm run dev # Start dev server (port 5173)
npm run build # Build for production
npm run start # Serve production build
npm run typecheck # Run TypeScript type checking
Environment Variables
Create .env file:
VITE_API_BASE_URL=http://localhost:8000 # FastAPI backend
VITE_ENV=local # Environment (local/production)
CLERK_PUBLISHABLE_KEY=pk_test_... # Clerk public key
CLERK_SECRET_KEY=sk_test_... # Clerk secret key
Key Features
- Search - Find stocks and view key metrics (PE ratios, growth rates, margins)
- Compare - Side-by-side comparison of up to 3 stocks
- Charts - Interactive financial charts with quarterly/TTM toggle
- Projections - Calculate future stock prices with custom growth inputs
- Financials - View historical and estimated financial statements
Design Patterns
- Component Composition: Build complex UIs from small, reusable components
- Custom Hooks: Extract logic into reusable hooks (useAuthenticatedFetch)
- Centralized State: Zustand store for global state, local useState for UI state
- Type Safety: TypeScript interfaces for all props, state, and API responses
- Error Boundaries: Route-level error handling with ErrorBoundary exports
- Loading States: Skeleton components and loading indicators for async operations
- Caching: Store-level caching for API responses to reduce backend load
- Responsive Design: Mobile-first Tailwind utilities with breakpoints
Reference Documentation
- components.md - Complete component hierarchy and props interfaces
- api-client.md - API integration patterns and authentication
- routing.md - React Router 7 setup and route configuration
- state-management.md - Zustand store structure and usage patterns
- styling.md - Tailwind configuration and design tokens
Additional Resources
docs/ui/- Detailed UI implementation guides for each pagedocs/prd.md- Product requirements and feature specificationsdocs/activity.md- Development activity log with implementation notes
Related Skills
Team Composition Analysis
This skill should be used when the user asks to "plan team structure", "determine hiring needs", "design org chart", "calculate compensation", "plan equity allocation", or requests organizational design and headcount planning for a startup.
Startup Financial Modeling
This skill should be used when the user asks to "create financial projections", "build a financial model", "forecast revenue", "calculate burn rate", "estimate runway", "model cash flow", or requests 3-5 year financial planning for a startup.
Startup Metrics Framework
This skill should be used when the user asks about "key startup metrics", "SaaS metrics", "CAC and LTV", "unit economics", "burn multiple", "rule of 40", "marketplace metrics", or requests guidance on tracking and optimizing business performance metrics.
Market Sizing Analysis
This skill should be used when the user asks to "calculate TAM", "determine SAM", "estimate SOM", "size the market", "calculate market opportunity", "what's the total addressable market", or requests market sizing analysis for a startup or business opportunity.
Anndata
This skill should be used when working with annotated data matrices in Python, particularly for single-cell genomics analysis, managing experimental measurements with metadata, or handling large-scale biological datasets. Use when tasks involve AnnData objects, h5ad files, single-cell RNA-seq data, or integration with scanpy/scverse tools.
Geopandas
Python library for working with geospatial vector data including shapefiles, GeoJSON, and GeoPackage files. Use when working with geographic data for spatial analysis, geometric operations, coordinate transformations, spatial joins, overlay operations, choropleth mapping, or any task involving reading/writing/analyzing vector geographic data. Supports PostGIS databases, interactive maps, and integration with matplotlib/folium/cartopy. Use for tasks like buffer analysis, spatial joins between dat
Market Research Reports
Generate comprehensive market research reports (50+ pages) in the style of top consulting firms (McKinsey, BCG, Gartner). Features professional LaTeX formatting, extensive visual generation with scientific-schematics and generate-image, deep integration with research-lookup for data gathering, and multi-framework strategic analysis including Porter's Five Forces, PESTLE, SWOT, TAM/SAM/SOM, and BCG Matrix.
Plotly
Interactive scientific and statistical data visualization library for Python. Use when creating charts, plots, or visualizations including scatter plots, line charts, bar charts, heatmaps, 3D plots, geographic maps, statistical distributions, financial charts, and dashboards. Supports both quick visualizations (Plotly Express) and fine-grained customization (graph objects). Outputs interactive HTML or static images (PNG, PDF, SVG).
Reactome Database
Query Reactome REST API for pathway analysis, enrichment, gene-pathway mapping, disease pathways, molecular interactions, expression analysis, for systems biology studies.
Excel Analysis
Analyze Excel spreadsheets, create pivot tables, generate charts, and perform data analysis. Use when analyzing Excel files, spreadsheets, tabular data, or .xlsx files.
