Aaryan041124/Heat_Map_Client
0
Stock Heat Map Client
Angular 18 frontend for uploading stock constituent files and visualizing a market heat map using GraphQL + D3 treemap rendering.
Tech Stack
- Angular 18 (standalone components)
- TypeScript (strict mode)
- SCSS
- Apollo Angular (
apollo-angular+@apollo/client) - GraphQL
- D3 (
d3)
Prerequisites
- Node.js (LTS recommended)
- npm
- Backend GraphQL API available at
http://localhost:8080/graphql
The GraphQL endpoint is read fromwindow.__APP_CONFIG__.graphqlUrl(file:src/assets/runtime-config.js).
Getting Started
- Install dependencies:
npm install- Start the development server:
npm start- Open the app:
http://localhost:4200
Available Scripts
npm start- starts Angular dev server (ng serve)npm run build- production build (ng build)npm test- test runner (ng test)
How the App Works
- User uploads an Excel file (
.xlsx) in the upload component. - File is read in browser and converted to base64.
- Client calls GraphQL mutation
importWorkbook(fileName, fileBase64). - On success, returned
batchIdis emitted to root component. - Root component calls GraphQL query
heatMap(batchId)to fetch a snapshot. - Heatmap component renders sectors/stocks with D3 treemap:
- tile area is based on
weightedValue - color intensity is based on
changePercent
Project Structure
src/
app/
components/
heatmap/
upload/
models/
heat-map.models.ts
services/
heat-map.service.ts
app.component.ts
app.component.html
assets/
sample-stocks-template.csv
main.ts
styles.scssGraphQL Operations Used
Defined in src/app/services/heat-map.service.ts.
Mutation: ImportWorkbook
Input:
fileName: String!fileBase64: String!
Response:
batchIdimportedRowsinvalidRowsmessage
Query: GetHeatMap
Input:
batchId: String(optional)
Response:
batchIdasOfmarketChangePercentsectors[]with nestedstocks[]
Notes and Known Limitations
- No route configuration yet (
provideRouter([])), currently single-view. - Heatmap component skips render if snapshot is null/empty (no explicit empty-state UI).
- GraphQL URL can be set at runtime with env var
GRAPHQL_URLwhen running the Docker image.
Troubleshooting
- If
npmornodecommand is not found, install Node.js and ensure it is on your shell PATH. - If upload/query fails, verify backend is running and
src/assets/runtime-config.js(orGRAPHQL_URL) points to the correct/graphqlURL.
Hugging Face Deployment (Docker Space)
This repo now includes a Dockerfile for Hugging Face Spaces.
Required Space Settings
SDK:DockerPORT: container listens on7860(already configured)Variables:GRAPHQL_URL=https://<your-server-space>.hf.space/graphql
Deploy
- Create a new Hugging Face Space for the client with
SDK = Docker. - Push this repository contents to that Space.
- Set
GRAPHQL_URLin SpaceSettings -> Variables. - Restart the Space.
