maxime-pico / karma

Repository for the Karma Panda project
karma-panda.vercel.app
GNU Affero General Public License v3.0
4 stars 0 forks source link

Karma Panda

"Give to each individual the power to support companies that share their values"

We are a community of Pandas who want to change the world by helping people judge at a glance wether companies are good or bad according to their own values.

To learn more about Karma Panda please contact one of the contributors.

If you wish to see the current production state of this project, please head to beta.karma-panda.org

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites

You should have some things already installed on your machine:

During the rest of the installation instructions we will suppose that you have fullfilled the prerequisites and that you chose to install npm. If you went with npm please replace all later occurences of the command npm by yarn.

For instance

npm install

Should be replaced by

yarn install

If you need help with anything, prerequisits install or actual Install, please contact Green Dirt.

Installing

To install the development environment on your machine and start running the project locally please start by:

Cloning the github repository on your machine:

Open a terminal on your machine and cd to the folder where you want to clone the project. Note that the result of the cloning will be a directory as well with "karma" as the default name:

cd path-to/my-folder-containing-many-projects

From this directory, run the following command:

git clone https://github.com/Green-Dirt/karma

Wait until the cloning is over (this might take some time) and cd to the cloned directory:

cd karma

Installing the dependencies

From the karma directory, install the dependencies needed for the frontend part of the project (this might take some time as well):

cd frontend/
npm i

Then move to the server directory and install the dependencies needed for the backend part of the project (...aaaaand you guessed it, it might also take some time!):

cd ../server/
npm i

Creating the environment files

For security reasons, the environment variables are not commited to the github and should be installed individually on each machine. You'll need to create these files and paste inside some dummy variables for the project to work locally.

From the server directory, create a file named .env:

touch .env

Then paste inside the following content:

JWT_APP_SECRET="development-secret"
DATABASE_ENDPOINT="http://localhost:4466"
PRISMA_SCHEMA_FILENAME="prisma"
PRISMA_MANAGEMENT_API_SECRET="development-secret"
MYSQL_ROOT_PASSWORD="prisma"

We have to do the same with the database environment file. cd to the database directory inside the server directory:

cd database/

From there, create a file named .env:

touch .env

Paste inside the following content:

PRISMA_MANAGEMENT_API_SECRET=development-secret
MYSQL_ROOT_PASSWORD=prisma

Starting the containers, the backend server and deploying the Prisma service

Inside the database directory start the docker containers that will host the server and database:

docker-compose up -d

Now got back to the server directory and then start the backend server:

cd ..
npm start

Open a new terminal window and go back to the server directory (if needed):

cd path-to/my-folder-containing-many-projects/karma/server

From there globally install the prisma cli and deploy the prisma service taking into acount the environment variables:

npm install -g prisma
prisma deploy -e .env

Start the frontend server and celebrate

Go to the root directory of the frontend directory and start the frontend server:

cd ../frontend/
npm start

At that point, a window from your favorite browser should open at the following URI http://localhost:3000/ greeting you the companies that were seeded: Total, H&M and Mc Donalds.

If that's the case, celebrate, have a coffee and then get back to obviously saving the world!

Running the tests - TODO

Explain how to run the automated tests for this system

Break down into end to end tests

Explain what these tests test and why

Give an example

And coding style tests

Explain what these tests test and why

Give an example

Deployment

Front-end

Move to the frontend folder

cd frontend

Add the .env file with production values to the directory. Also add the now.json file. Then build the project

npm run build

Move to the build folder and deploy to now, this will copy an url to your clipboard with the build online.

now

Once you tested the build and you are satisfied with it, alias it to the production url

now alias [build_url] [prod_url]

Server

To update the servers, go to the server folder

cd server

Install the production now.json file. Deploy on now. This will copy a test url to your clipboard.

now

At the url, a graphql playground should appear. To test it and interact with it, you must first add a bearer token to the header. First generate the token by running the following prisma command

prisma token

Head back to the playground and copy the following inside the HTTP HEADERS tab at the bottom of the page

{
  "Authorization": "Bearer [generated_token]"
}

You can now test the server. When you are happy with it, alias it to the correct production url

now alias [test_url] [server_production_url]

Database

Move to the server folder

cd server

Provide yourself the .env.prod environment files and paste them inside the folder. Run the following command to update the prisma database.

prisma deploy -e .env.prod

If the docker container requires an update, please refer to the steps described here in this issue https://github.com/prisma/prisma-cloud-feedback/issues/202

Built With

For more info on the tech stack, the app/database architecture etc. please check the wiki

Contributing

Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.

Versioning

The workflow used is GitFlow. The different branches and their use is the following:

Authors

See also the list of contributors who participated in this project.

License

This project is licensed under the GNU AGPL v3.0 License - see the LICENSE file for details

Acknowledgments