Giter VIP home page Giter VIP logo

carb-emissions-est-for-electricity's Introduction

Description

React-based web-application which renders your estimated carbon emissions based on your input for country and electricity usage for a week.

How to use

Please visit the application here.

Development

Clone the repo:

git clone [email protected]:HansKre/carb-emissions-est-for-electricity.git

Run development server:

cd carb-emissions-est-for-electricity
npm run dev
# or
yarn dev

Open http://localhost:3000 with your browser to see the result.

Testing

Tests are implemented using cypress.io, an End to End Testing Framework. Run npm test to receive a test-report or npm run test:open to run tests interactively.

Bring your own API-Key

Since the free-tier of https://www.carboninterface.com-API is limited to 200 requests per month, following precautions are implemented:

  • all non-production-api-calls are mocked
  • all api-calls made by tests are mocked
  • all production-api-calls are cached server-side

If you want to use your own API-Key locally, please make sure to:

  • rename .env.example file to .env
  • inside the .env, add your API-Key to CARBONINTERFACE_API_KEY property
  • run with npm run prod

Test your API-Key

Following curl command should return a valid API-response:

Example-Request

export CARBONINTERFACE_API_KEY=<yourkeystring>

curl "https://www.carboninterface.com/api/v1/estimates" \
  -H "Authorization: Bearer \"${CARBONINTERFACE_API_KEY}\"" \
  -H "Content-Type: application/json" \
  -X POST \
  -d '{"type": "electricity","electricity_unit": "mwh","electricity_value": 17,"country": "us","state": "fl"}' | jq .

Example-Response

{
  "data": {
    "id": "e940c8a9-7297-4560-8944-66834de107b1",
    "type": "estimate",
    "attributes": {
      "country": "us",
      "state": "fl",
      "electricity_unit": "mwh",
      "electricity_value": 17,
      "estimated_at": "2021-08-06T14:27:59.751Z",
      "carbon_g": 6763764,
      "carbon_lb": 14911.55,
      "carbon_kg": 6763.76,
      "carbon_mt": 6.76
    }
  }
}

Deployment

Netlify is set up to deploy from github. On a push to github, Netlify runs the build script on their servers and deploys the result (if successful).

Contributions

Highly welcome. Please submit a PR.

Compatibility

  • KeyboardTimePicker needs MuiPickersUtilsProvider which uses DateFnsUtils from @date-io/date-fns package. For compatibility reasons, version 1.3.x is required. Install it with npm install @date-io/[email protected].
  • JSS fix for SSR: fixes 'Warning: Prop className did not match.' issue when reloading page during development while running npm run dev.

Backlog

  • setup project
  • sign up at carboninterface for API-Key
  • setup hosting at netlify
  • add tests
    • for desktop
    • for mobile
  • final review of review
    • how to install
    • how to test
    • how to use
    • where to put own API-Key
  • Add state-selection for USA & Canada
  • For small mobile screens, change sliders orientation to horizontal
  • Make Icons-onClick open Select and Datepicker in CountryForm

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.