Overview
IGTech turns readings from an Arduino installation into an electricity dashboard. A Next.js interface shows current measurements, historical charts, date-range reports, and estimated electricity costs.
Challenge
Bring measurements from a physical installation into a usable web application: validate incoming readings, show changes without a page refresh, and make historical data practical to explore.
Solution
An Arduino sends readings every three minutes to an Express API. The API checks authorization and validates the values before storing them in Firestore. Next.js reads that data for gauges, historical charts, statistics, and cost estimates; Firebase Authentication supports user accounts.
Engineering decisions
Validate at ingestion. The Express API checks the key in the request headers and validates measurement values before writing them to Firestore.
Reuse monthly calculations. Calculating cost by scanning a full month of readings is read-intensive. The first calculation stores a monthly result in another collection so subsequent views can reuse it. Incremental aggregation was identified as a further optimization, rather than described as an implemented feature.
Separate report generation. A dedicated Express service handles PDF generation, while the frontend requests and displays reports.
Architecture
The ingestion API uses the Firebase Admin SDK to write validated measurements to Firestore. The Next.js client reads and processes the stored data for display. A separate Express API generates PDF reports and returns them to the interface. In the original implementation, both Express services were hosted on Heroku.
My role
Architecture and full delivery
What it delivers
The application brings voltage, current, frequency, power, and energy readings into one interface. Users can explore a date range, review minimum and maximum values, estimate cost, and export statistics as PDF reports.
Constraints & tradeoffs
Readings arrive every three minutes, so the dashboard updates as new samples arrive rather than providing continuous sensor streaming. The monthly summary strategy also introduces a freshness concern when additional readings arrive; it is a tradeoff to account for when evolving the aggregation logic.
Tech stack
- Next.js
- TailwindCSS
- Firebase
- Express.js