How richardzimring/heatmap works
Project type and purpose
• Purpose: display live, interactive stock-option heatmap data for any ticker, direction, and metric.
File structure
• Top level splits into two clearly separated directories:
• back-end – a Serverless/Node.js (TypeScript) service with three Lambda handlers (getDates, getOptions, getQuote) plus types and a Serverless framework config (serverless.yml).
• front-end – a React/TypeScript SPA (App.tsx, Heatmap.tsx, utilities, static assets in public/).
• Configuration files:
• back-end/serverless.yml – defines AWS Lambda functions, API Gateway endpoints, IAM roles.
• front-end/tsconfig.json, package.json, public/manifest.json – standard CRA or similar setup.
Core components & their roles
a. Frontend (React SPA)
• App.tsx, Heatmap.tsx: UI layers for rendering heatmap, controls for ticker/direction/metrics.
• init/init.tsx, utils.tsx, useWindowDimensions.js: bootstrap and helper code.
• Bundled/static assets deployed to S3 + distribution (CloudFront) or similar.
b. API Layer (AWS API Gateway)
• Routes mapped in serverless.yml to three Lambda functions.
c. Business Logic (AWS Lambda functions)
• utils.ts: shared logic for error handling, request shaping.
• types/*.ts: TypeScript interfaces for request/response payloads.
d. External Services
• Third-party stock/option data provider (HTTP API).
Relationships and data flow
1. User’s browser (React app) requests heatmap parameters (ticker, metric, direction).
2. Frontend issues REST calls to API Gateway endpoints (e.g., GET /dates, /options, /quote).
3. API Gateway routes call the corresponding AWS Lambda function.
4. Lambda function uses internal utils and types, then calls the external data provider.
5. External service returns raw data → Lambda transforms it into JSON matching types/datesResponse, options, quoteResponse → returns to API Gateway → HTTP response back to browser.
6. React UI parses JSON, updates state, re-renders the heatmap component.
Architectural patterns and design principles
• Clear separation of concerns: UI vs. domain logic vs. infra config.
• Serverless microservices: each Lambda does one job (Single Responsibility).
• Type safety everywhere (TS in front-end and back-end).
• Declarative infra-as-code (serverless.yml).
• SPA static hosting + CDN + API Gateway + Lambda for minimal ops overhead.