Bagtrekkin is a full-stack application involving both hardware and software.
This project takes place in a Lean Startup course at the University Federal of Pernambuco.
Install Bagtrekkin Django Application
By following those steps, you'll install the application development environment
- Clone Git repository:
$ git clone email@example.com:goujonpa/bagtrekkin.git
- Create a
virtualenvto host the application: You may need
# install virtualenv tool manager via pip $ [sudo] pip install virtualenv # create a new virtualenv folder called venv $ virtualenv venv # activate your virtualenv! $ source venv/bin/activate
- Install application dependencies via pip:
/!\ Be sure to have your virtualenv activated /!\
This is stipulated by
(venv)in front of your terminal prompt.
(venv) $ pip install -r requirements.txt (venv) $ pip install -r requirements-dev.txt
Currently both Tastypie and PyJade are installed from master development branch. When both package will be released in pip. Requirements must be edited.
- Install postgres database server On Debian based distributions, install from package manager:
$ apt-get install postgresql-9.4
On Mac OS X, install from Homebrew, MacPorts or use Postgres.app:
$ brew install postgresql
Initiate a fresh database granted for current user:
$ initdb -D /usr/local/var/postgres
$ pg_ctl -D /usr/local/var/postgres start
Create a new user named bagtrekkin with a password prompted:
$ createuser -W bagtrekkin
Create a dedicated database for bagtrakkin user:
$ createdb -O bagtrekkin -E UTF8 bagtrekkin
We can now try a connection to be sure all is properly setup:
$ psql -U bagtrekkin bagtrekkin
- Setup your local environment variables
- Create a
.envfile in the same folder as
cat >> .env <<EOF WEB_CONCURRENCY=2 DEBUG=TRUE ALLOWED_HOSTS=localhost DATABASE_URL=postgres://bagtrekkin:<your_db_password>@localhost:5432/bagtrekkin SECRET_KEY=<your_secret_key> EOF
<your_secret_key>with one generated, for instance, using MiniWebTool.
<your_db_password>with the password you setup for postgres bagtrekkin user.
- Run Migrations to create and feed your database:
(venv) $ python manage.py migrate
- Test if everything runs well:
(venv) $ python manage.py runserver
You are now fully operational to join the developer team :)
/!\ Please read carefully How to Contribute /!\
In order to get closer to production environment, you can run python server the same way as Heroku actually do: using
Simply install globally Ruby foreman
$ gem install -g foreman
And run server:
$ foreman start
Create your Employee Account (i.e. User)
The first thing you need to do is create a new user using
Sign Up form. It is also an
Employee. Once your account is created, you basically want to be a superuser in order to access django admin interface.
Enter in python shell
(venv) $ python manage.py shell
Import the corresponding module
>>> from django.contrib.auth.models import User
Get your user instance from the models
>>> foo = User.objects.get(username = '<your_username>')
is_staff property to
>>> foo.is_staff = True
is_superuser property to
>>> foo.is_superuser = True
Save your changes
Verification : load again your user instance from the models
>>> foo = User.objects.get(username = '<your_username')
Check that your changes are applied (next instruction should return
Doing the same on heroku
You will have to do the same to be superuser on heroku. Repeat the procedure above.
You can know update your local environment variables by adding:
cat >> .env <<EOF API_URL=bagtrekkin.herokuapp.com API_USER=<your_username> API_KEY=<your_api_key> EOF
<your_api_key>with the one generated by the application when you'll create your account.
<your_username>with the one used when you'll create your account.
This configuration is used by
Understand application structure
arduinofolder contains hardware code currently not being used by application server-side (i.e. Hosted on Heroku)
bagtrekkinfolder contains the server-side application.
staticfolder contains all static resources (i.e. js, css, fonts and img files used by the application).
documentationfolder contains documentation about the project