by Laura Zailac


What is OCP?

Open Cycle Project is an application where companies hoping to both hold themselves accountable for and be more transparent with the carbon footprints of their products can come to register their products and calculate their carbon and transparency scores. They can also set goals for the future of their carbon output. The transparency scores grow as a company registers more products. This can be seen by the consumers and incentivizes companies to dive deep into their product offering and reflect on what they are willing to share. Consumers can come to the site to look up a company or a product and educate themselves on the impact of the goods they purchase.

Open Cycle Project was inspired by my background in consumer goods, my passion for nature and keeping the planet healthy, as well as many inspiring green initiatives gaining traction now more than ever. Specifically, I have taken inspiration from the brand All Birds, who has created an open-source carbon calculator.

Please check out my wikis for more info and enjoy! 🌱

Installation

  1. Install dependencies

    pipenv install --dev -r dev-requirements.txt && pipenv install -r requirements.txt
  2. Create a .env file based on the example with proper settings for your development environment

  3. Setup your PostgreSQL user, password and database and make sure it matches your .env file CREATE USER ocp_user WITH CREATEDB PASSWORD 'password'; CREATE DATABASE ocp_db WITH OWNER ocp_user;

  4. Get into your pipenv, migrate your database, seed your database, and run your flask app

    pipenv shell
    flask db upgrade
    flask seed all
    flask run
  5. To run the React App in development, checkout the README inside the react-app directory.

Deploy to Heroku


IMPORTANT! If you add any python dependencies to your pipfiles, you'll need to regenerate your requirements.txt before deployment. You can do this by running:

pipenv lock -r > requirements.txt

ALSO IMPORTANT! psycopg2-binary MUST remain a dev dependency because you can't install it on apline-linux. There is a layer in the Dockerfile that will install psycopg2 (not binary) for us.


  1. Run npm run build in React App

  2. Create a new project on Heroku

  3. Under Resources click "Find more add-ons" and add the add on called "Heroku Postgres"

  4. Install the Heroku CLI

  5. Run

    heroku login
  6. Login to the heroku container registry

    heroku container:login
  7. Update the REACT_APP_BASE_URL variable in the Dockerfile. This should be the full URL of your Heroku app: i.e. "https://flask-react-aa.herokuapp.com"

  8. Push your docker container to heroku from the root directory of your project. This will build the dockerfile and push the image to your heroku container registry

    heroku container:push web -a open-cycle-project
  9. Release your docker container to heroku

    heroku container:release web -a open-cycle-project
  10. set up your database:

    heroku run -a open-cycle-project flask db upgrade
    heroku run -a open-cycle-project flask seed all
  11. Under Settings find "Config Vars" and add any additional/secret .env variables.