Giter Site home page Giter Site logo

synctext / taarifatraders Goto Github PK

View Code? Open in Web Editor NEW

This project forked from taarifa/taarifatraders

0.0 2.0 0.0 2.94 MB

Charter for Cross-Border Trade in Goods and Services

Home Page: http://crossbordertrade.org

License: Other

JavaScript 8.03% HTML 18.97% CoffeeScript 20.19% Python 41.07% CSS 1.64% Shell 0.23% Roff 9.88%

taarifatraders's Introduction

Taarifa Traders

Background Waterpoints Prequisites Linux Windows Installation Installation using a virtual machine Usage Deployment to Heroku Contribute

Background

Taarifa is an open source platform for the crowd sourced reporting and triaging of infrastructure related issues. Think of it as a bug tracker for the real world which helps to engage citizens with their local government.

The Taarifa platform is built around the Taarifa API, a RESTful service offering that clients can interact with to create and triage 'bugreports' relating to public infrastructure (e.g., the public toilet is broken).

For information on how to get inovoled, scroll to the Contributing section at the bottom of the page.

Traders

This repository contains an example application around Cross-Border Traders built on top of the core API.

There is also an angularjs web application that illustrates how a user can interact with the API and data through a browser.

Prerequisites

Note

You may choose to install into a virtual machine as described further down.

Taarifa requires Python, pip, nodejs, npm and MongoDB to be available on the system.

Note

pip >= 1.5 is required. if you have an older version you can upgrade (may require sudo) with

pip install -U pip

Linux

If you are running Ubuntu you can simply execute the install.sh script

./install.sh

Some of the commands are executed with sudo and require sudo permission for the currently logged in user.

On other distributions, use the package manager to install the packages corresponding to those listed in install.sh.

Windows

Windows can be used as the platform to run Taarifa - the main caveat here however is that as you install the dependencies, these are not added to the $PATH variable - this needs to be added manually.

Details for the following steps are the same as for MacOS/Linux (except for the actual package installation):

  1. Install Python.

  2. Install pip.

  3. Install nodejs and npm (these need to be added to the $PATH variable!)

  4. Install and run MongoDB, which does not automagically come with a service, so it needs to be started manually. Open a command prompt and run:

    "c:\Program Files\MongoDB 2.6 Standard\bin\mongod.exe" --dbpath c:\mongo_databases\taarifa\
    

Installation

Note

The following steps are part of the bootstrap.sh script, so you may choose to execute that instead.

Requires Python, pip and the Taarifa API to be installed and MongoDB to be running.

To ease development and debugging we suggest you use virtualenv. Install virtualenv and virtualenvwrapper (you might need admin rights for this):

pip install virtualenv virtualenvwrapper

For windows only, install virtualenvwrapper-win using pip:

pip install virtualenvwrapper-win

Set up virtualenvwrapper according to your shell and create a virtualenv:

mkvirtualenv TaarifaAPI

If you already created the virtualenv for the Taarifa API, activate it:

workon TaarifaAPI

Clone the repository

git clone https://github.com/taarifa/TaarifaTraders

Change into directory and install the requirements

cd TaarifaTraders
pip install -r requirements/dev.txt

Ensure you have node.js and npm installed. Then, from the TaarifaTraders directory, install the npm dependencies:

npm install

Install the Grunt and Bower command line interface (may require Adminstrator permission):

npm install -g grunt-cli
npm install -g bower

Finally, install the frontend dependencies using Bower:

bower install

Continue with the usage section.

Installation using a virtual machine

Instead of following the installation instructions above you may choose to set up a virtual machine with all dependencies installed. This process is fully automated using Vagrant and the provided Vagrantfile. Note that the Vagrantfile is included in the repository and needs not be downloaded.

Install VirtualBox and Vagrant for your platform.

Clone the repositories into the same root folder. This is required since these local folders are mounted in the VM such that you can edit files either on the host or in the VM.

git clone https://github.com/taarifa/TaarifaAPI
git clone https://github.com/taarifa/TaarifaTraders
cd TaarifaTraders

Start the VM. This may take quite a while the very first time as the VM image needs to be downloaded (~360MB) and the VM provisioned with all dependencies. On every subsequent use these steps are skipped.

vagrant up

In case provisioning fails due to e.g. loss of network connection, run the provisioning scripts again until successful:

vagrant provision

Connect to the virtual machine and change into the TaarifaTraders folder:

vagrant ssh
cd TaarifaTraders

You can then continue with the usage section below. The ports are automatically forwarded so you can access the API and frontend from your host browser. Note that both the TaarifaAPI and the TaarifaTraders folders in the VM are mounted from the host i.e. changes made on the host are immediately reflected in the VM and vice versa. This allows you to work on the code either on the host or in the VM according to your preference.

Usage

Note

When using a virtual machine, run the following commands in the VM.

Make sure the virtualenv is active:

workon TaarifaAPI

From the TaarifaTraders directory run the following commands to create the trader schemas:

python manage.py create_facility
python manage.py create_service

Start the application from the TaarifaTraders directory by running:

python manage.py runserver -r -d

By default the API server is only accessible from the local machine. If access from the outside is required (e.g. when running from inside a VM), run:

python manage.py runserver -h 0.0.0.0 -r -d

The flags -r and -d cause the server to run in debug mode and reload automatically when files are changed.

To verify things are working, open a browser (on the host when using the VM) and navigate to:

http://localhost:5000/api/traders

This should show a list of all the trader resources currently in the database.

To work on the frontend web application start the grunt server (with the API server running on port 5000) using:

grunt serve --watch

Then navigate to (on the host when using the VM):

http://localhost:9000

Grunt watches the app folder for changes and automatically reloads the frontend in your browser as soon as you make changes.

To build the frontend (which is automatically done on deployment), use:

grunt build

This creates a distribution in the dist folder, which is served via the Flask development server running on port 5000. The build step needs to be run again whenever the frontend in the app folder changes. Running grunt serve is not required in this case.

Requirements

Taarifa uses pip to install and manage python dependencies.

Conventionally this uses requirements.txt, but Heroku automatically installs from there. Therefore a requirements folder is used as following:

  • Dev and deploy requirements in requirements/base.txt
  • Development only in requirements/dev.txt
  • Deployment only in requirements/deploy.txt

Deployment to Heroku

To deploy to Heroku, make sure the Heroku tool belt is installed. From the TaarifaTraders root folder, create a new app:

heroku app:create <name>

This will add a new Git remote heroku, which is used to deploy the app. Run git remote -v to check. To add the remote manually, do:

git remote add heroku [email protected]:<name>.git

Since Taarifa uses Python for the API and Node.js to build the frontend, Heroku build packs for both stacks are required. heroku-buildpack-multi enables the use of multiple build packs, configured via the .buildpacks file. Before deploying for the first time, the app needs to be configured to use it:

heroku config:set BUILDPACK_URL=https://github.com/ddollar/heroku-buildpack-multi.git

Add the MongoLab Sandbox to provide the MongoDB database

heroku addons:add mongolab

To be able to import the data into the MongoLab database, copy down the heroku configuration to a .env file you can use with foreman:

heroku config:pull

Make sure the virtualenv is active:

workon TaarifaAPI

Extract host, database, user and password from the MONGOLAB_URI Heroku configuration variable:

heroku config:get MONGOLAB_URI

Once finished you are ready to deploy:

git push heroku master

To set up a custom domain for the deployed app, register with heroku:

heroku domains:add <domain>

and add a DNS record for it:

<domain>.     10800   IN      CNAME   <appname>.herokuapp.com.

Contribute

There is still much left do do and Taarifa is currently undergoing rapid development. We aspire to be a very friendly and welcoming community to all skill levels.

To get started send a message to the taarifa-dev mailinglist introducing yourself and your interest in Taarifa. With some luck you should also be able to find somebody on our IRC channel.

If you are comfortable you can also take a look at the github issues and comment/fix to you heart's content.

We use the github pull request model for all contributions. Refer to the contributing guidelines for further details.

taarifatraders's People

Contributors

fayazv avatar kynan avatar

Watchers

 avatar  avatar

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.