Coder Social home page Coder Social logo

brunolajoie / northapp-contrib Goto Github PK

View Code? Open in Web Editor NEW

This project forked from electricitymaps/bloom-contrib

0.0 1.0 0.0 2.03 MB

North automatically calculates the climate impact of your daily choices by connecting to apps and services you already use.

Home Page: https://www.north-app.com

License: MIT License

JavaScript 99.40% HTML 0.20% CSS 0.40%

northapp-contrib's Introduction

Image description

northapp-contrib Slack Status DroneCI

Welcome to the open-source repository of the North app!πŸ‘‹

What is the North app?

The North app automatically calculates your carbon footprint by connecting to other services and apps in your life and translating activities from these apps and activities to greenhouse gas emissions.

The app is private-by-design: data will stay on device, unless the user explicitly gives consent. This code is maintained by Tomorrow.

Feel free to watch the presentation our Founder Olivier gave to the CopenhagenJS meetup, explaining what a JavaScript developer can do to combat climate change. If you have any questions, want early access to the app or just want to hang out with people fighting climate change with code, join our Slack community.

Tomorrow is hiring!

The company behind the North app builds tech to empower organisations and individuals to understand and reduce their carbon footprint.

We're hiring great people to join our team in Copenhagen. Head over to our jobs page if you want to help out!

Structure of this repository

  • ./co2eq: carbon models
  • ./integrations: contains all integrations
  • ./integrations/img: contains all integration logos
  • ./playground: source code of the playground
  • ./definitions.js: constant definitions

How can I help?

You can help by:

  • Helping us find, add and improve integrations with 3rd party services
  • Helping us find, add and improve our Life Cycle Assesment / Carbon footprint data
  • Giving us ideas, feedback and reporting bugs

Integrating purchases and activities

We wrote a little article about what we believe makes a great integration. However, that shouldn't stop you from doing an integration which is interesting and useful to you! Our only requirement is that it can be quantified in greenhouse gas emissions.

Integrations can rely on an API or even on scrapers if necessary.

Suggesting an integration

Here is the list of current 3rd party integrations: Official integrations:

  • ✈️ Tripit (tracks most airlines!)
  • ⚑ Barry
  • πŸš— Tesla Cockpit

Community-supported integrations:

  • ✈️ Ryanair (contributor:lauvrenn)
  • ✈️ Wizzair (contributor:lauvrenn)
  • πŸš‚ Rejsekort
  • πŸš‚ Trainline (contributor:liamgarrison)
  • πŸš‚ Transport for London (contributor:liamgarrison)
  • ⚑ Sense (contributor:snarfed)
  • ⚑ Linky (contributor:bokub)
  • ⚑ Ørsted (contributor:felixdq)
  • πŸš— Renault ZoΓ©
  • πŸš— Uber (contributor:willtonkin)
  • πŸš— Automatic (contributor:lauvrenn)
  • πŸš— MinVolkswagen (contributor:folkev0gn)

You can suggest a new integration here.

Coding or debugging a new integration

If you don't have an idea on your own or prefer to debug an integration, you can find integration suggestions and bugs in the issues.

To make it easy for anyone to help out, a development playground is available:

First, run yarn to install dependencies at the root of the repository. Next from the playground folder, run yarn to install dependencies, then run yarn serve to start the playground and point your browser to localhost:3000 to get started.

How to make an integration work

An integration gathers activities from a 3rd party datasource. To this end, 3 async methods need to be exported:

async function connect(requestLogin, requestWebView) {
  const { username, password } = await requestLogin();
  // ...
  return newState;
}
async function collect(state = {}, logger) {
  // ...
  return { activities, state: newState };
}
async function disconnect() {
  // ...
  return newState;
}

The connect method is used to ask for user credentials (OAuth flows are also supported). The collect method is called periodically (typically every few hours) to fetch new activities. As the methods are pure, and to avoid re-asking the user for credentials everytime the collect method is called, a state object can be used to persist information (such as password, tokens..) across collects.

Activities require a certain formatting:

Transportation activity formatting
{
  id, // a string that uniquely represents this activity
  datetime, // a javascript Date object that represents the start of the activity
  durationHours, // a floating point that represents the duration of the activity in decimal hours
  distanceKilometers, // a floating point that represents the amount of kilometers traveled
  activityType: ACTIVITY_TYPE_TRANSPORTATION,
  transportationMode, // a variable (from definitions.js) that represents the transportation mode
  carrier, // (optional) a string that represents the transportation company
  departureAirportCode, // (for plane travel) a string that represents the departure airport, IATA code
  destinationAirportCode, // (for plane travel) a string that represents the final destination airport, IATA code
  departureStation, // (for other travel types) a string that represents the original starting point
  destinationStation, // (for other travel types) a string that represents the final destination
  participants, // (optional) the number of passengers (for car and motorbike travels)
}
Lodging activity formatting
{
  id, // a string that uniquely represents this activity
  datetime, // a javascript Date object that represents the start of the activity
  durationHours, // a floating point that represents the duration of the activity in decimal hours
  activityType: ACTIVITY_TYPE_LODGING,
  hotelClass, // a variable (from definitions.js) that represents the class of the hotel
  countryCodeISO2, // a string with the ISO2 country code that represents the country of the hotel
  participants, // (optional) the number of people sharing one hotel room
  hotelName, // (optional) a string that represents the name of the hotel
  locationLon, // (optional) the longitude of the location of the hotel
  locationLat, // (optional) the latitude of the location of the hotel
}
Electricity consumption activity formatting
{
  id, // a string that uniquely represents this activity
  datetime, // a javascript Date object that represents the start of the activity
  durationHours, // an integer that represents the duration of the activity
  activityType: ACTIVITY_TYPE_ELECTRICITY,
  energyWattHours, // a float that represents the total energy used
  hourlyEnergyWattHours, // (optional) an array of 24 floats that represent the hourly metering values
  locationLon, // (optional) the longitude of the location of the hotel
  locationLat, // (optional) the latitude of the location of the hotel
}
Transaction activity formatting
{
  id, // a string that uniquely represents this activity
  datetime, // a javascript Date object that represents the start of the activity
  label, // a string that represents the transaction
  merchantDisplayName, // (optional) a string that represents the merchant where the purchase was made
  purchaseCategory, // a string that represents the category of the purchase. Categories can be found here: https://github.com/tmrowco/northapp-contrib/blob/master/definitions.js
  costAmount, // a floating point that represents the amount of the purchase
  costCurrency, // a string that represents the currency in which the currency was made
  bankDisplayName, // (required for integrations with banks) a string that represents the banks' name
  bankIdentifier, // (required for integrations with banks) a string that uniquely represents the bank.
}

Adding or updating Life Cycle Assessment / Carbon Footprint of purchases and activities

Our current models and Life Cycle assessments are accessible here. If you know better sources, please contribute with your knowledge.

If you want to add individual items or ingredients, this is done here. Ideally, the studies used should be as global as possible and it's even better if they're systemic reviews (multiple studies in one!).

Giving ideas, features requests or bugs

Please add an issue here or directly in the app.

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.