Giter VIP home page Giter VIP logo

coopcycle-web's Introduction

CoopCycle

Build Status

CoopCycle is a self-hosted platform to order meals in your neighborhood and get them delivered by bike couriers. The only difference with proprietary platforms as Deliveroo or UberEats is that this software is reserved to co-ops.

The main idea is to decentralize this kind of service and to allow couriers to own the platform they are working for. In each city, couriers are encouraged to organize into co-ops, and to run their very own version of the software.

The software is under active development. If you would like to contribute we will be happy to hear from you! All instructions are in the Contribute file.

Coopcycle-web is the main repo, containing the web API, the front-end for the website and the dispatch algorithm : Technical Overview. You can see it in action & test it here : https://demo.coopcycle.org

You can find a comprehensive list of our repos here : Our repos comprehensive list.

How to run a local instance

Please find below the steps to install the platform locally. You can find additional tips & configurations in the wiki.

Prerequisites

Install Docker and Docker Compose.

OSX

Use Docker for Mac which will provide you both docker and docker-compose.

Windows

Use Docker for Windows which will provide you both docker and docker-compose. Depending on your platform, Docker could be installed as Native or you have to install Docker toolbox which use VirtualBox instead of Hyper-V causing a lot a differences in implementations. If you have the luck to have a CPU that supports native Docker you can share your hard disk as a virtual volume for your appliances.

Docker doesn't work under Windows, you need to install linux in hypervisualization. Follow the recommendations here to activate the necessary features under windows 11 and make sure you have an administrator account https://docs.docker.com/desktop/troubleshoot/topics/

Download docker https://www.docker.com/products/docker-desktop/ Check in the BIOS that : -hypervisualization (HYPER-V) -Data Execution Prevention (DEP). You can also use the following procedure for DEP: Windows + r Search for sysdm.cpl Advanced system settings In Performance, select settings data execution prevention "enable for all except those I select...". click on apply

install, from your PowerShell WSL 2 terminal https://learn.microsoft.com/en-us/windows/wsl/install

configure your WSL 2 environment by creating a Linux administrator account. The password is not displayed (this is normal), so remember it. https://learn.microsoft.com/fr-fr/windows/wsl/setup/environment#file-storage

Linux

Follow the instructions for your distribution. docker-compose binary is to be installed independently. Make sure:

Setup OpenStreetMap geocoders (optional)

CoopCycle uses OpenStreetMap to geocode addresses and provide autocomplete features.

Address autocomplete

To configure address autocomplete, choose a provider below, grab the credentials, and configure environment variables accordingly.

LOCATIONIQ_ACCESS_TOKEN
GEOCODE_EARTH_API_KEY
  • For Geocode Earth, set COOPCYCLE_AUTOCOMPLETE_ADAPTER=geocode-earth
  • For LocationIQ, set COOPCYCLE_AUTOCOMPLETE_ADAPTER=locationiq
Geocoding

To configure geocoding, create an account on OpenCage, and configure the OPENCAGE_API_KEY environement variable.

Run the application

Pull the Docker containers (optional)

We have prebuilt some images and uploaded them to Docker Hub. To avoid building those images locally, you can pull them first.

docker-compose pull

Start the Docker containers

cp .env.dist .env
docker-compose up

At this step, the platform should be up & running, but the database is still empty. To create the schema & initialize the platform with demo data, run:

make install

Open the platform in your browser

open http://localhost

Testing

Create the test database

docker-compose run php bin/console doctrine:schema:create --env=test

Launch the PHPUnit tests

make phpunit

Launch the Behat tests

make behat

Launch the Jest tests

make jest

Launch the Cypress tests

Cypress is a JS program for end-to-end testing and integration testing of components. You will launch a server in the test environment and run cypress on your own machine.

npm install -g cypress @cypress/webpack-preprocessor @cypress/react18

Launch php container on his own in the test env:

docker compose run --service-ports -e APP_ENV=test php
docker compose up
# might need to reboot the PHP container here because the link with nginx is not good

(FIXME : it is a pitty to launch with two commands the containers, it is because docker compose up doesn't accept -e APP_ENV=test arg, you can also set APP_ENV=test in your .env file)

In the .env file you need to set GEOCODE_EARTH_API_KEY to a valid API key. You need also Stripe configured on the platform or in the .env file (STRIPE_PUBLISHABLE_KEY, STRIPE_SECRET_KEY, STRIPE_CONNECT_CLIENT_ID).

and then this command will lead you to Cypress GUI

cypress open

The Cypress tests will run automatically in Github CI on the master branch. You can get screenshots of the failed tests from the Upload images for failed test step (there is a link there to download the failed steps).

Debugging

1. Install and enable xdebug in the php container

make enable-xdebug

Note: If you've been working with this stack before you'll need to rebuild the php image for this command to work:

docker-compose build php
docker-compose restart php nginx

2. Enable php debug in VSCode

  1. Install a PHP Debug extension, this is tested with felixfbecker.php-debug extension.
  2. Add the following configuration in your .vscode/launch.json of your workspace:
{
	"configurations": [
    {
      "name": "Listen for XDebug",
      "type": "php",
      "request": "launch",
      "port": 9001,
      "pathMappings": {
          "/var/www/html": "${workspaceFolder}"
      },
      "xdebugSettings": {
          "max_data": 65535,
          "show_hidden": 1,
          "max_children": 100,
          "max_depth": 5
      }
    }
  ]
}
  1. If you're having issues connecting the debugger yo can restart nginx and php containers to reload the xdebug extension.
docker-compose restart php nginx

Running migrations

When pulling change from the remote, the database models may have changed. To apply the changes, you will need to run a database migration.

make migrations-migrate

License

The code is licensed under the Coopyleft License, meaning you can use this software provided:

  • You are matching with the social and common company’s criteria as define by their national law, or by the European Commission in its October 25th, 2011 communication, or by default by the Article 1 of the French law n°2014-856 of July 31st, 2014 “relative à l’économie sociale et solidaire”
  • You are using a cooperative model in which workers are employees

coopcycle-web's People

Contributors

552020 avatar aenario avatar agichim avatar alexsegura avatar andrewcunnin avatar aniacuapio avatar arnomasson avatar atala avatar awesomekuro avatar ccoreilly avatar dependabot-preview[bot] avatar flug avatar fnanndo avatar jfoclpf avatar ladias-elie avatar lucasferraro avatar maxi3390 avatar mcorreggiari avatar miguelpeixe avatar nadimhammami avatar orionalfa avatar pierre-lhoste avatar pierwmaria avatar r0xsh avatar sgobotta avatar thadah avatar trendspotter avatar vladimir-8 avatar vova1vova avatar weblate avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

coopcycle-web's Issues

Make Docker work

Should be easy, at least it needs:

  • a PostgreSQL container with PostGIS extension
  • a Redis container
  • a container to run Node

Fix deprecations in Node PostgreSQL

The following warning is emitted on Travis

(node:8284) DeprecationWarning: PG.connect is deprecated - please see the upgrade guide at https://node-postgres.com/guides/upgrading
(node:8284) DeprecationWarning: Using the automatically created return value from client.query as an event emitter is deprecated and will be removed in [email protected]. Please see the upgrade guide at https://node-postgres.com/guides/upgrading

Optimize Webpack build

Webpack build currently takes up to 4 minutes to complete.
This is way too long.

We need to find ways to reduce the build time.

[UX] Login by email

I think most people are used to login with their emails. Would that be possible to enable login by email and username OR only login with email?

Parameterize command to create demo data

The coopcycle:demo:init command should accept arguments to specify the number of items to create, for example:

php bin/console coopcycle:demo:init --restaurants=100 --couriers=50 --users=50

Miss an use in RestrictedDiet class

The annotation @ApiResource is used in the RestrictedDiet php class but without the call to the vendor's class : use ApiPlatform\Core\Annotation\ApiResource; it will crash

Permission error when restarting Docker

There is always this error when restarting Docker.

Warning: SessionHandler::read(): Session data file is not created by your uid

To fix it

rm -rf var/sessions/dev

We need to remove sessions folder on startup.

Stabilize Mocha tests

Sometimes the Travis build fails on Mocha tests. They are timing out.
Most of the time, clicking on "Restart build" solves the issue.

We need to make sure tests run correctly on each build.

capture d ecran 2017-08-20 a 19 04 59

How to manage registration through the API?

We need to manage registration through external websites & native apps.

As a first implementation, there is a register endpoint which automatically activates the user.
But this seems not really satisfying, at least it could lead to lots of spam.

How to manage email verification anyway?
Is there a better way with API Platform?

Have migrations start from an empty schema.

First migrations is here and suppose there are already some tables created in the DB (menu_item, restaurant, aso).

It is not very clean, the migration process should work from scratch, so we can use doctrine:migrations:migrate .

Reorganize project layout

I would suggest to move js/app to assets/js/components or assets/js/scripts and rename js/api to api , as it is not clear what does what in my opinion.

Use FOSUserBundle promote command

We shouldn't be interacting directly with the database here

$ bin/console fos:user:promote --help

Usage:
  fos:user:promote [options] [--] <username> [<role>]

Arguments:
  username              The username
  role                  The role

Clean README.md

  • Remove Vagrant install instructions
  • Move architecture description to the Wiki
  • Remove refs to 192.xxx (since docker for mac exists)
  • Add doc for demo command

Add "geofencing"

Allow dividing cities into districts with bounding boxes

This would allow to group restaurants for example, and also assign couriers to districts.

Ideally fences should be editable by an administrator via a web user interface.

Data in KML format looks easy to parse, example for Paris

Create a bot to simulate courier activity

It should be easy to create a bot that connects to the dispatch service, accepts orders and delivers them, using the Google Directions API to find the best route.

The GoogleDirectionsApi class must implement some methods

The GoogleDirectionsApi class implements the RoutingInterface so they need to implements this two methods :

    public function getRawResponse(GeoCoordinates $origin, GeoCoordinates $destination)
    {
        // TODO: Implement getRawResponse() method.
    }

    public function getDistance(GeoCoordinates $origin, GeoCoordinates $destination)
    {
        // TODO: Implement getDistance() method.
    }

Without theses 2 methods php will crash

The package-lock.json file is modified by Docker

It looks like the integrity key is modified from sha1 to sha512

git diff package-lock.json
diff --git a/package-lock.json b/package-lock.json
index 44ed3ff..5e32cf0 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -5781,7 +5781,7 @@
     "npmlog": {
       "version": "4.1.0",
       "resolved": "https://registry.npmjs.org/npmlog/-/npmlog-4.1.0.tgz",
-      "integrity": "sha1-3Fm+6F9k8A7UJO+yrweD3yXRwLU=",
+      "integrity": "sha512-ocolIkZYZt8UveuiDS0yAkkIjid1o7lPG8cYm05yNYzBn8ykQtaiPMEGp8fY9tKdDgm8okpdKzkvu1y9hUYugA==",
       "dev": true,
       "requires": {
         "are-we-there-yet": "1.1.4",
@@ -9259,7 +9259,7 @@
     "wide-align": {
       "version": "1.1.2",
       "resolved": "https://registry.npmjs.org/wide-align/-/wide-align-1.1.2.tgz",
-      "integrity": "sha1-Vx4PGwYEY268DfwhsDObvjE0FxA=",
+      "integrity": "sha512-ijDLlyQ7s6x1JgCLur53osjm/UXUYD9+0PbYKrBsYisYXzCxN+HC3mYDNy/dWdmf3AwqwU3CXwDCvsNgGK1S0w==",
       "dev": true,
       "requires": {
         "string-width": "1.0.2"

Se this issue npm/npm#17749

cc @Atala

Timestamp our models

All for our models should have the fields dateAdd and dateUpdated so we can keep track of modification and creation DB in our database.

Create a JS function to create users in DB

The JS tests use the PHP command to create users.

It means that JS tests depends on PHP. It is also an issue for #23 .

It implies that the JS model should map entirely the DB entry.

Would that cause any issue?

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.