Skip to content

feat: Add demo web application showcasing TinyGrid SDK#7

Open
kvkenyon wants to merge 4 commits into
mainfrom
feat/demo-web-app
Open

feat: Add demo web application showcasing TinyGrid SDK#7
kvkenyon wants to merge 4 commits into
mainfrom
feat/demo-web-app

Conversation

@kvkenyon
Copy link
Copy Markdown
Owner

@kvkenyon kvkenyon commented Dec 29, 2025

Adds a full-stack demo app with:

  • FastAPI backend wrapping TinyGrid SDK endpoints
  • React/TypeScript frontend with Vite
  • Bloomberg/Palantir-inspired dark terminal UI
  • Docker Compose setup for easy deployment

Features:

  • Dashboard with grid metrics, load forecast, renewables
  • Settlement point prices with time-series charts
  • Load and renewable generation forecasts
  • Historical data query interface

Backend endpoints:

  • /api/load-forecast - Load forecast by zone
  • /api/wind-forecast - Wind generation forecast
  • /api/solar-forecast - Solar generation forecast
  • /api/spp - Settlement point prices
  • /api/historical - Archive data access

Also updates pyrightconfig.json and ruff.toml to exclude the demo from CI checks since it has its own separate dependencies.


Note

Demo application added under examples/demo/

  • FastAPI backend (backend/) exposing TinyGrid-powered endpoints: dashboard (/status, /fuel-mix, /renewable, /supply-demand), prices (/spp, /lmp, /lmp-combined, /daily-prices, *-grid), forecasts (/load, /load-forecast, /wind-forecast, /solar-forecast), historical (/historical, /historical/endpoints)
  • Real-time price caching: incremental RT LMP/SPP cache and daily DA SPP cache with startup prefetch
  • Dockerized backend (Python 3.13) installing local tinygrid/pyercot and running uvicorn

React + TypeScript + Vite frontend (frontend/)

  • Pages: Dashboard, Prices, Forecasts, Historical with TanStack Query, Recharts, Tailwind/DaisyUI
  • API client/hooks for all backend routes; Nginx config and Dockerfile for production build

Deployment and docs

  • docker-compose.yml to run frontend+backend; .env.example and comprehensive README for setup
  • CLAUDE.md expanded with architecture, demo details, and usage guidance

Tooling/housekeeping

  • .pre-commit-config.yaml: run ruff format .
  • .gitignore: add venv/ and Node ignores; examples/.gitignore for demo artifacts

Written by Cursor Bugbot for commit df50a30. This will update automatically on new commits. Configure here.

Adds a full-stack demo app with:
- FastAPI backend wrapping TinyGrid SDK endpoints
- React/TypeScript frontend with Vite
- Bloomberg/Palantir-inspired dark terminal UI
- Docker Compose setup for easy deployment

Features:
- Dashboard with grid metrics, load forecast, renewables
- Settlement point prices with time-series charts
- Load and renewable generation forecasts
- Historical data query interface

Backend endpoints:
- /api/load-forecast - Load forecast by zone
- /api/wind-forecast - Wind generation forecast
- /api/solar-forecast - Solar generation forecast
- /api/spp - Settlement point prices
- /api/historical - Archive data access

Also updates pyrightconfig.json and ruff.toml to exclude the demo
from CI checks since it has its own separate dependencies.
@codecov
Copy link
Copy Markdown

codecov Bot commented Dec 29, 2025

Codecov Report

❌ Patch coverage is 47.50000% with 21 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
tinygrid/ercot/api.py 44.44% 20 Missing ⚠️
tinygrid/ercot/transforms.py 50.00% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

- Integrated prefetching of Day-Ahead LMP data in the FastAPI backend.
- Added a new endpoint for real-time fuel mix estimation based on current generation data.
- Implemented caching for Day-Ahead LMP data to optimize performance.
- Enhanced frontend components with DaisyUI for improved UI consistency and responsiveness.
- Updated various components and pages to utilize new data fetching hooks and display real-time information.
- Improved error handling and loading states across the application.
- Refactored CSS styles to align with DaisyUI theming and removed legacy styles.
- Added new utility functions for time formatting and data display consistency.
{
"time": time_str,
"location": str(row.get(loc_col, "")) if loc_col else "",
"rt_price": float(row.get("Price", row.get("LMP", 0))),
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing NaN handling in price data conversion

The get_lmp_combined endpoint converts price values with float(row.get("Price", row.get("LMP", 0))) without handling NaN values. If the "Price" column exists but contains NaN, row.get() returns the NaN value (the fallback is only used when the key doesn't exist). This differs from dashboard.py which has a safe_float helper that explicitly handles NaN/Inf values. NaN floats can cause JSON serialization errors with the standard library encoder, potentially resulting in 500 responses when the API data contains missing price values.

Additional Locations (1)

Fix in Cursor Fix in Web

)
if not load_df.empty:
# Get record closest to current hour
current_hour = datetime.now().hour
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inconsistent timezone handling uses server local time

The get_fuel_mix_realtime function correctly creates a Central Time aware timestamp on line 186 using datetime.now(ct), but then inconsistently uses naive datetime.now() without timezone for the API date parameters and current_hour selection. ERCOT data is indexed by Central Time, so if the server runs in a different timezone (common for cloud deployments in UTC), the API request may fetch the wrong date's data and select the wrong hour's row from the DataFrame. For example, a UTC server at 1am on Jan 2nd would request Jan 2nd data and select hour 1, when it should be requesting Jan 1st data and selecting hour 19 Central Time.

Additional Locations (2)

Fix in Cursor Fix in Web

… features

- Updated the FastAPI backend to support asynchronous data fetching for load, wind, and solar forecasts.
- Added new async wrappers for various ERCOT API methods to improve performance and responsiveness.
- Introduced a new endpoint for fetching locational marginal prices (LMP) optimized for grid display.
- Enhanced frontend components to utilize new async data fetching hooks, improving loading states and error handling.
- Updated the demo application to include a full-stack web application showcasing TinyGrid SDK features with improved UI elements.
- Refactored existing components for better code organization and maintainability.
- Improved documentation and added new utility functions for better data handling.
# tinygrid is expected to be installed in the environment

# CORS and other utilities
python-multipart>=0.0.6
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing python-dotenv dependency causes import error

The client.py file imports and uses load_dotenv from the dotenv package at module load time (lines 5 and 10), but python-dotenv is not listed in requirements.txt. This will cause an ImportError when starting the backend, preventing the entire application from running.

Additional Locations (1)

Fix in Cursor Fix in Web

# I will use asyncio.to_thread for load_forecast but implement others that I DID add.

# Wait, I see I missed adding get_load_forecast_async in the previous step.
# I will use asyncio.to_thread for this specific route.
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Developer notes accidentally committed in production code

Extensive developer thinking notes and internal commentary were accidentally committed. The comments include phrases like "let's check", "I missed adding", "Wait, I see I missed", "I will use asyncio.to_thread for this specific route", and references to editing other files. These are clearly development notes rather than documentation and expose internal implementation decisions that could confuse future maintainers.

Fix in Cursor Fix in Web

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant