Development Process Documentation

Solar Energy Visualization Dashboard with APsystems API Integration

Nate's Thoughts

Project Overview

This solar energy dashboard was built to visualize hourly energy production data from an APsystems ECU in a heat map format inspired by a friend's system display. The project demonstrates full-stack development with Claude Code, including API authentication, database caching, security hardening, and interactive data visualization.

10
Days of Data
240
Heat Map Cells
~1,470
Lines of Code
12
Total Files

AI Agent Used

This project was developed entirely using Claude Sonnet 4.5 (model ID: claude-sonnet-4-5-20250929) through the Claude Code CLI interface. The AI agent handled:

Token Usage

Development of this project consumed approximately 30k-35k tokens from the Claude Code session, including all conversations, code generation, testing iterations, and documentation creation. This represents roughly 15-18% of the 200k token budget.

~30k
Tokens Used
15-18%
Budget Consumed
~170k
Tokens Remaining

Source Data & APIs

APsystems OpenAPI

Base URL: https://api.apsystemsema.com

Authentication: HmacSHA256 signature-based

Rate Limit: 1,000 requests per day (system uses ~24/day)

Documentation: APsystems OpenAPI User Manual

API Endpoints Used

Hardware Source

Local Data Storage

Technical Architecture

Frontend: HTML5, CSS3, Vanilla JavaScript
Backend: PHP 7.4+
Database: SQLite with PDO
API Auth: HmacSHA256 signatures
Security: Apache .htaccess
Server: Apache with mod_rewrite

Process Documentation

Development Process

Phase 1: Requirements & Planning
Started with a description of the desired visualization and a reference screenshot from Ashley's system. Claude acted as product owner to ask clarifying questions about data sources, API access, security requirements, and performance expectations.
Phase 2: PRD Creation
Generated a comprehensive 413-line Product Requirements Document covering functional requirements, technical architecture, security measures, database schema, API integration, and 11 acceptance criteria. This document served as the blueprint for implementation.
Phase 3: Security Setup
First priority was securing sensitive credentials. Created .htaccess rules to protect secrets.php, the database file, and initialization scripts from direct web access. Implemented server-side API authentication to prevent credential exposure.
Phase 4: Backend Development
Built the PHP API layer with:
  • HmacSHA256 signature generation for APsystems authentication
  • SQLite database with three tables for data caching
  • Rate limiting logic (max 1 API call per hour)
  • Smart caching to minimize API usage
  • JSON endpoint for frontend data retrieval
Phase 5: Frontend Development
Created interactive visualization with:
  • 10-day x 24-hour heat map grid (240 cells)
  • Blue gradient color scheme (11 levels based on production)
  • Hover tooltips showing exact kWh and timestamp
  • Daily totals column on the right
  • Daily summary bar chart below heat map
  • Dynamic color legend
  • Loading states and error handling
Phase 6: Testing & Debugging
Encountered API authentication issues (error code 4000). Through iterative debugging, discovered the signature calculation required using only the last path segment, not the full URL path. Fixed signature generation and successfully retrieved real solar production data.
Phase 7: Documentation
Created comprehensive documentation including README.md, SETUP.md, PROJECT_SUMMARY.md, and this agents.html file to document the development process and help others learn from the project.

Feedback Mechanisms

Interactive User Feedback

  • Hover Tooltips: Real-time feedback showing exact kWh and timestamp for any hour
  • Color Gradients: Visual feedback on production levels (darker = less, brighter = more)
  • Daily Totals: Instant summary of total daily production
  • Update Timestamp: Shows when data was last refreshed
  • Loading Indicators: Spinner and status message during data fetch
  • Error Messages: User-friendly error display if data fetch fails

Technical Feedback Loops

Key Technical Challenges Solved

Challenge 1: API Signature Authentication

Problem: Initial API calls returned error 4000 (Request parameter exception)

Solution: Discovered that APsystems API requires the signature to use only the last segment of the request path, not the full path. Updated signature generation logic to:

timestamp + '/' + nonce + '/' + appId + '/' + lastPathSegment + '/' + method + '/' + signatureMethod

Learning: Always read API documentation carefully, especially for signature-based authentication. The exact format matters.

Challenge 2: Rate Limiting & Caching

Problem: APsystems limits to 1000 API calls per day. Without caching, the dashboard would quickly exceed this limit with frequent page loads.

Solution: Implemented three-tier caching strategy:

  • Historical data cached permanently once retrieved
  • Current hour data refreshed only if last API call was >1 hour ago
  • API call tracking in database prevents rapid-fire requests

Result: Typical usage: ~24 API calls/day (well within 1000 limit)

Challenge 3: Security Configuration

Problem: API credentials must be kept secure and not exposed to the internet

Solution: Multi-layer security approach:

  • .htaccess rules deny direct access to secrets.php and database file
  • All API calls go through PHP backend (never from frontend)
  • Credentials never appear in JavaScript or HTML source
  • Database file permissions restricted to web server user

What Worked Well

Learning Outcomes

For Future Projects

Test API Authentication Early: Don't wait until full implementation to test API calls. Create a minimal test script first to verify authentication works correctly.
Read Signature Documentation Carefully: Signature-based authentication is finicky. The exact string format, encoding, and hash algorithm must match documentation precisely.
Design Caching Strategy Upfront: For rate-limited APIs, plan your caching architecture before writing code. Consider what needs frequent updates vs. what can be cached permanently.
Security From Day One: Don't add security as an afterthought. Protect credentials and sensitive files from the start of development.
Use Reference Examples: Having a visual reference (Ashley's screenshot) made requirements concrete and eliminated ambiguity about desired appearance.
Document As You Go: Creating PRD and feedback files during development (not after) makes final documentation much easier and more accurate.

Project Statistics

7
Core Files
5
Documentation Files
11/11
Acceptance Criteria Met
2
Feedback Iterations

File Breakdown

Performance Metrics

<500ms
Cached Data Fetch
<100ms
Heat Map Render
24/day
API Calls (max)
2.4%
Rate Limit Usage

Live Example Data

Real solar production data retrieved from the APsystems ECU:

Key Takeaways

Final Thoughts

This project demonstrates the power of AI-assisted full-stack development when combined with clear requirements, visual references, and systematic problem-solving. The dashboard successfully replicates Ashley's visualization while adding interactive features like hover tooltips and daily charts.

The smart caching architecture ensures the system stays well within API rate limits while providing near-instant data retrieval for users. Security measures protect sensitive credentials without complicating the user experience.

From initial concept to production-ready application, the entire development process was completed efficiently through collaboration with Claude Code, resulting in a robust, secure, and performant solar energy dashboard.

View Solar Energy Dashboard