Code Monkey home page Code Monkey logo

developer-joyofenergy-csharp's Introduction

Welcome to PowerDale

PowerDale is a small town with around 100 residents. Most houses have a smart meter installed that can save and send information about how much energy a house has used.

There are three major providers of energy in town that charge different amounts for the power they supply.

  • Dr Evil's Dark Energy
  • The Green Eco
  • Power for Everyone

Introducing JOI Energy

JOI Energy is a new start-up in the energy industry. Rather than selling energy they want to differentiate themselves from the market by recording their customers' energy usage from their smart meters and recommending the best supplier to meet their needs.

You have been placed into their development team, whose current goal is to produce an API which their customers and smart meters will interact with.

Unfortunately, two members of the team are on annual leave, and another one has called in sick! You are left with another ThoughtWorker to progress with the current user stories on the story wall. This is your chance to make an impact on the business, improve the code base and deliver value.

Story Wall

At JOI energy the development team use a story wall or Kanban board to keep track of features or "stories" as they are worked on.

The wall you will be working from today has 7 columns:

  • Backlog
  • Ready for Dev
  • In Dev
  • Ready for Testing
  • In Testing
  • Ready for sign off
  • Done

Examples can be found here https://leankit.com/learn/kanban/kanban-board/

Users

To trial the new JOI software 5 people from the JOI accounts team have agreed to test the service and share their energy data.

User Smart Meter ID Power Supplier
Sarah smart-meter-0 Dr Evil's Dark Energy
Peter smart-meter-1 The Green Eco
Charlie smart-meter-2 Dr Evil's Dark Energy
Andrea smart-meter-3 Power for Everyone
Alex smart-meter-4 The Green Eco

These values are used in the code and in the following examples too.

Overview

JOI Energy is a new energy company that uses data to ensure customers are able to be on the best price plan for their energy consumption.

API

Below is a list of API endpoints with their respective input and output. Please note that the application needs to be running. For more information about how to run the application, please refer to run the application section below.

Store Readings

Endpoint

POST /readings/store

Example of body

{
    "smartMeterId": <smartMeterId>,
    "electricityReadings": [
        { "time": <time>, "reading": <reading> },
        { "time": <time>, "reading": <reading> },
        ...
    ]
}

Parameters

Parameter Description
smartMeterId One of the smart meters' id listed above
time The time when the delta is measured
reading The delta reading since the last reading

Example readings

Date (GMT) Reading (kW)
2020-11-11T08:00:00.0000000+00:00 0.0503
2020-11-12T08:00:00.0000000+00:00 0.0213

In the above example, 0.0213 kW where consumed between 2020-11-11 8:00 and 2020-11-12 8:00.

Posting readings using CURL

$ curl \
  -X POST \
  -H "Content-Type: application/json" \
  "http://localhost:5000/readings/store" \
  -d '{"smartMeterId":"smart-meter-0","electricityReadings":[{"time":"2020-11-11T08:00:00.0000000+00:00","reading":0.0503},{"time":"2020-11-12T08:00:00.0000000+00:00","reading":0.0213}]}'

The above command returns 200 OK and {}.

Get Stored Readings

Endpoint

GET /readings/read/<smartMeterId>

Parameters

Parameter Description
smartMeterId One of the smart meters' id listed above

Retrieving readings using CURL

$ curl "http://localhost:5000/readings/read/smart-meter-0"

Example output

[
  { "time": "2020-11-11T08:00:00.000000Z", "reading": 0.0503 },
  { "time": "2020-11-12T08:00:00.000000Z", "reading": 0.0213 },
  ...
]

View Current Price Plan and Compare Usage Cost Against all Price Plans

Endpoint

GET /price-plans/compare-all/<smartMeterId>

Parameters

Parameter Description
smartMeterId One of the smart meters' id listed above

Retrieving readings using CURL

$ curl "http://localhost:5000/price-plans/compare-all/smart-meter-0"

Example output

{
  "DrEvilsDarkEnergy": 94.87181867550794,
  "TheGreenEco": 18.974363735101587,
  "PowerForEveryone": 9.487181867550794
}

View Recommended Price Plans for Usage

Endpoint

GET /price-plans/recommend/<smartMeterId>[?limit=<limit>]

Parameters

Parameter Description
smartMeterId One of the smart meters' id listed above
limit (Optional) limit the number of plans to be displayed

Retrieving readings using CURL

$ curl "http://localhost:5000/price-plans/recommend/smart-meter-0?limit=2"

Example output

[
  {
    "key": "PowerForEveryone",
    "value": 9.487181867550794
  },
  {
    "key": "TheGreenEco",
    "value": 18.974363735101587
  }
]

Requirements

The project requires .NET 8.0.

Compatible IDEs

Tested on:

  • Visual Studio 2022 (17.1)
  • Visual Studio Code (1.64)
  • JetBrains Rider 2023.2.3

Useful commands

From the terminal/shell/command line tool, use the following commands to build, test and run the API.

Build the project

$ dotnet build

Run the tests

$ dotnet test JOIEnergy.Tests

Run the application

Run the application which will be listening on port 5000.

$ dotnet run --project JOIEnergy

developer-joyofenergy-csharp's People

Contributors

damned avatar dmooretw avatar albertattard avatar hectortosa avatar artwks avatar gabrielmccallin-tw avatar dependabot[bot] avatar

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.