Energy consumption simulation · CASE STUDY

Consumo de Energia

Electricity consumption and cost simulator with appliance comparisons.

The challenge

Estimate the impact of appliances on electricity bills.

The solution

Appliance and tariff registration, consumption and cost projections, with per-user data.

Main features

  • Device registration, power, usage duration and tariff.
  • Estimated monthly consumption, cost and annual projection.
  • Consumption classification and persistence of one scenario per user.

Architecture

JavaScript web interface and Express API with PostgreSQL persistence.

  1. JavaScript interface
  2. Express API
  3. PostgreSQL

Technical decisions and limitations

Values are estimates and exclude some components of real electricity bills. The README reports temporary unavailability of demo credentials.

Project status

Public source code.

Availability

Source code
Public
Demo
App online, no demo account
Case study
Available
Status
Published

Context and problem

An evolution of an academic energy-use project. Users enter appliances and tariff, and the system estimates consumption, cost and an annual projection.

How it works

  1. Appliances and tariff
  2. kWh calculation
  3. Monthly and annual cost
  4. Top consumer

Business rules

  • Monthly kWh from power, hours and days of use.
  • One scenario per account, saved per user, with optimistic versioning.
  • The administrator lists accounts and activates or deactivates them, with no access to the simulation.

Technical challenges and solutions

  • Challenge: Preventing two tabs from overwriting the scenario. Solution: Optimistic versioning on the backend, covered by tests.
  • Challenge: Storing passwords safely. Solution: scrypt hashes with random salt and constant-time comparison.

Security and privacy

  • JWT sessions in HttpOnly, Secure, SameSite cookies, restricted CORS and parameterized queries.
  • Permanent account deletion from the interface.

Tests and evidence

  • CI runs frontend calculation tests and, on the backend with PostgreSQL 16, security, rate limiter, password change and optimistic versioning tests.

Lessons learned

  • Pure, testable calculation keeps the interface thin.

Current status

Academic project evolved. Hosting as documented in the repository: frontend on Firebase Hosting, backend on Vercel and PostgreSQL on Neon. The repository documentation states that the demo account is temporarily unavailable.

Documented evidence

Documentation describes calculation, security and concurrency-control tests.

Existing documented interface.