Git Product home page Git Product logo

es-platform's Introduction

ES-Platform

This project is created to simulate how a user would calculate their electricity costs based on a couple of inputs

Some important choices I made can be found below

Choosing Vite over Create-React-App

Comming from Vue world I have worked with Vite over the past 4 years, I have enjoyed the flexibility but also the crazy speeds the HMR provides

Configuring prettier in combination with eslint

I personally dislike working on a project where individuals employ varying tab indices, quote styles, or, in general, different (suboptimal) formatting. This complexity makes code reviews more challenging and adds unnecessary bloat to the entire environment. When multiple people collaborate on the same project, it is essential that they adhere to consistent coding practices. It becomes simpler to implement and assimilate new rules when the codebase follows a similar syntax.

Choosing to use a day picker

From a UX perspective, it may seem counterintuitive for users to manually pick a specific date when calculating costs. A more logical approach might be, for instance, "I want to calculate the cost for this Sunday, so I'll select a date." However, providing users with numerous choices for selecting a time frame can be overwhelming and might divert them from their intended goal. Guiding users toward their desired result is often more effective. Calculating costs on a daily basis not only simplifies the user's understanding but also eliminates the need to navigate through a large calendar. This approach communicates that the cost fluctuates on a daily basis, providing a clearer indication compared to a weekly variation.

Not having a calculate button

Providing instant feedback is often optimal in user experience design. Why conceal information that is readily available? By eliminating the "calculate" button, users are encouraged to explore and experiment. This interactive approach increases the likelihood that users will discover insights such as, "If I use power for a longer duration, it becomes more cost-effective as I am no longer purchasing during peak hours." This design not only facilitates immediate user understanding but also lays the groundwork for future enhancements. Implementing live data updates through a WebSocket, for instance, could enable users to view real-time estimates of their costs, enhancing the overall user experience.

Not having interval calculations

Even though it's part of the assignment, I have purposefully left it out. I strongly believe that obtaining readings and maintaining them in the frontend will cause significant issues later on.

The problems can be broken apart like this:

The user will have to initiate a measurement session. Using a Single Page Application (SPA) or any tool without database access will require the user to keep their PC/browser running continuously to receive measurements.

What happens to past measurements? Wouldn't a user want to track their usage on a graph throughout the year? Establishing a connection using a websocket or stream to a gateway will add an extra layer of complexity and shared sources of truth between the frontend and backend.

To utilize the data for electricity companies, it would make more sense to save a copy of this data. Having a database allows the Energy Supplier Platform to target users for marketing campaigns and assist in reducing electricity usage.

It would make more sense for a user to access the data of all their measurements at any time. A simple database table with the following structure:

{
    id: /* ID of the device */,
    user_id: /* ID of the client */,
    timeStamp: /* Date of the measurement, potentially using a one-to-many relationship to a separate measurement table */,
    reading: /* Reading at that moment */
}

This allows us to gather more data for the user to make better-informed decisions. If data capacity is an issue, allowing the user to manually activate a measurement would already be helpful. However, storing readings in the browser or tracking them is far from ideal.

If this task were requested by the client, I would attempt to persuade them to consider a different option. Setting up this backend service is not overly difficult and will offload a significant amount of logic to the frontend. The frontend should be straightforward and perform simple tasks; that's where it excels.

Architecture

React + TypeScript + Vite

This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.

Material UI

This appeared to be the quickest approach as I have some experience with Material UI. Typically, I would opt for a similar library like Quasar for Vue or Styled Components for larger projects. I am not very familiar with Tailwind, as I have not adhered to the Bootstrap approach of utilizing classes for styling in most of my code. I prefer to directly observe what is causing shifts in my layout and styling, or at the other extreme, see nothing, as Material UI uses. Something in between is confusing to me, but this could also be due to a lack of experience using tools like this.

es-platform's People

Watchers

Haris Spahija avatar

es-platform's Issues

Init CICD pipeline using Netlify

DoD

  • Setup netlify PoC pipeline
  • Setup Github Actions to run the following on PR's
    • npm i
    • Eslint
    • Typescript check
    • run unit tests
    • npm build
    • publish to test env
    • github action to add test link to PR
  • Setup Github Actions to run the following on merges for Develop
    • npm i
    • Eslint
    • Typescript check
    • run unit tests
    • npm build
    • execute Cypress test
    • Make new tag for version management
    • publish to dev env

Cleanup any usage in typescript

Some events are using any, the rules are disabled for now as I am not familiar with the type interfaces used for React events. In Vue and Svelte they are often included in the typescript dist.

Any's that need to be removed are marked with a TODO

DoD

  • Remove any usage
  • Add strict typing on events for MouseEvent and HTMLInputEvents

Add instructions using React Joyride

DoD

To explain to a user how to use the application, you will be guided using Joyride.

  1. It should explain the idea of the app first
  2. It should explain the Date first
  3. It should explain the start time
  4. It should explain the duration
  5. It should explain the expected consumption in kW
  6. It should explain the timeout (every 15 minutes new data comes in)
  7. It should show the result
  8. It should explain the calculate button

Stylelint configured

DoD

As part of the development experience I want to make sure that my scss is linted and following BEM conventions.

  • Add Stylelint
  • Add stylelint config
  • Add BEM stylelint ruling

Init GraphQL Apollo

DoD

  • Init GraphQL Apollo
  • Init mock query for login
  • Init mock subscription to update the data for calculating the cost

Init project

DoD

  • Written in React
  • Typescript configured
  • SCSS configured
  • Vite configured
  • Eslint configured
  • #7 (out-of-scope)
  • Prettier configured
  • Rule set from template included

Add logic for calculating the cost of electricity

Energy Consumption Cost Estimation Portal

An Energy Supplier platform receives readings from metering points for all of its customers every day. For this assignment, we will assume that such metering points are measuring electricity usage and report a new reading value every 15 minutes. We can convert these readings to usage intervals for every 15 minutes by using the formula:

usage = reading(i+1) - reading(i)

Assignment Task

Your task in this assignment is to create a small self-service portal for customers to help estimate the cost of energy consumption. This should be a simple frontend application (no backend is required), where the user can input the following three pieces of information:

  • Start time and date of the consumption (with 15-minute accuracy)
  • Expected consumption (in kW)
  • Duration (with 15-minute accuracy) !IMPORTANT! Note that it will be 15 minutes, 30 minutes etc. This data comes from a backend API that is mocked using apollo

There are different prices for electricity based on the time. The application should use these prices to make an estimate of the cost for the user and show this. Based on the cost schema described in the table below:

Type 23:00 - 07:00 07:00 - 23:00
Elec Mo t/m Fr 0.18/kWh 0.20/kWh
Elec Weekend 0.18/kWh 0.18/kWh

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.