/kamu

You favorite book library

Primary LanguageJavaScriptMIT LicenseMIT

Kamu

"Some books leave us free and some books make us free." – Ralph Waldo Emerson

Build Status Test Coverage Maintainability Open Source Helpers

Join the Matrix.org contributors chat at https://matrix.to/#/#kamu:matrix.org

Kamu is an application that focus on managing a physical library where you can add books, borrow and return them.

In the main page you can see the libraries shared between users. The libraries can be different unities, cities or name of friends that wants to share books. In the Screenshoot bellow, you can see an example of multiple libraries.

Screenshoot for Kamu's multiple libraries

Requirements

  • Python 3.6+ for Django backend
  • Node.js 8+ for frontend assets

Installation / Getting started

Here is a quick step-by-step minimal setup, to get the app up and running in your local workstation:

MacOS specific

To install Node.js and npm you can either download it from the node.js homepage or install it using homebrew:

brew install node

Platform independent

Create Python virtual enviroment:

python3 -m venv venv

Activate virtual enviroment (this command can change based on OS):

source venv/bin/activate

Install backend dependencies using pip:

pip install -r requirements.txt

Install frontend dependencies using npm:

npm install

Create database tables:

python manage.py migrate

Create a super user:

python manage.py createsuperuser

You will use this super user to login as administrator in your local Kamu application.

Seed the database with initial dump data:

python manage.py loaddata dump_data/*.json

Start your local server:

npm start

Now just go to http://localhost:8000 in your browser :)

For local setup with Okta authentication: Use the OKTA_METADATA_URL and OKTA_ENTITY_ID environment variables, concatenating it with the usual commands. Examples:

  OKTA_METADATA_URL='url-of-okta-saml' OKTA_ENTITY_ID='url-of-okta-login' npm start
  OKTA_METADATA_URL='url-of-okta-saml' OKTA_ENTITY_ID='url-of-okta-login' python manage.py migrate

Another way is to export the var and then execute the commands:

  export OKTA_METADATA_URL='url-of-okta-saml' OKTA_ENTITY_ID='url-of-okta-login'
  npm start
  python manage.py migrate

If you wish to disable Okta authentication again, execute:

  unset OKTA_METADATA_URL OKTA_ENTITY_ID

Using Docker for local development

Remember to create a .env file with all the environment variables you need for spining up the environment.

For building the image:

  make docker-build

If you're not planning to use a heroku like build or touch docker files, you can also pull from Dockerhub:

  make docker-pull

Create database tables:

  make docker-migrate

Create a super user (for non Okta based usage):

  make docker-createsuperuser

You will use this super user to login as administrator in your local Kamu application.

Seed the database with initial dump data:

  make docker-loaddata

Start your local server:

  make docker-dev

Now just go to http://localhost:8000 in your browser :)

For simulating a Heroku like environment (recommended to make build first):

  make docker-heroku

Access your local Heroku in the same link http://localhost:8000

Stop your environment:

  make docker-down

Deployment

We have out of the box support for Heroku 🐉, Dokku 🐳 and Docker 🐳.

For deployment, create a new Python app and set the remote origin from Dokku or Heroku, push it and enable the Postgres plugin.

The buildpacks should configure all the necessary libraries for you.

Now, we need the following environment variables before running Kamu for the first time:

SECRET_KEY="django-secret-key" # https://duckduckgo.com/?q=django+secret+key+generator
DEBUG=true # Or false, depending if is a testing or production app
DJANGO_SETTINGS_MODULE="core.settings.prod" # If you plan to run a testing version
DATABASE_URL=postgres://dbhost/dbname # This variable should be automatically configured by the postgres extension.
ALLOWED_HOSTS="kamu.example.com, kamu.heroku.etc"
OKTA_METADATA_URL="SECRET-OKTA-STUFF" # On the case of Okta Authentication support
OKTA_ENTITY_ID="http://kamu.example.com/okta-login/acs/" # On the case of Okta Authentication support, the URL to the acs login route
ANALYTICS_ACCOUNT_ID="UA-123456789-1" # Only if you want to enable Google Analytics, otherwise don't set it
SENTRY_DSN="SECRET-SENTRY-DSN" # Only if you want to enable Sentry, otherwise don't set it
SSL=false # Enabled by default in production like deployments

See Dokku environment variables or Heroku Config Vars for more details.

On non Okta based deployments, you should run either dokku run kamu /bin/bash or heroku run /bin/bash -a kamu (On this case, kamu is app name)

python manage.py createsuperuser

See #74

Thanks!