Development

Prerequisites

You need the following libraries and/or programs:

Getting started

Developers can follow the following steps to set up the project on their local development machine.

Obtain source

You can retrieve the source code using the following command:

$ git clone git@github.com:VNG-realisatie/documenten-api.git drc

Note: You can also use the HTTPS syntax:

$ git clone https://github.com/VNG-realisatie/documenten-api.git drc

Setting up virtualenv

  1. Go to the project directory:

    $ cd drc
    
  2. Create the virtual environment:

    $ virtualenv -p /usr/bin/python3.x ./env
    
  3. Source the activate script in your virtual environment to enable it:

    $ source env/bin/activate
    
  4. Install all the required libraries:

    (env) $ pip install -r requirements/dev.txt
    

Installing the database

  1. The default settings for the database are:

    • name: drc
    • user: drc
    • password: drc

    You can customize these by setting (any of) the following environment variables:

    • DB_NAME
    • DB_USER
    • DB_PASSWORD
    • DB_HOST
    • DB_PORT
  2. Launch the migration process

    (env) $ python src/manage.py migrate
    

Note

You can put local, machine specific setting changes in src/drc/conf/local.py. These settings are NOT checked into version control.

Running server

  1. Create a superuser to access the management interface:

    (env) $ python src/manage.py createsuperuser
    
  2. You can now run your installation and point your browser to the address given by this command:

    (env) $ python src/manage.py runserver
    

Generate the API schema

  1. Install Javascript modules:

    $ npm install
    
  2. Launch the schema generation tool:

    generate-schema
    
  3. The resulting openapi.yaml and swagger2.0.json files can be visualized with Swagger

Update installation

When updating an existing installation:

  1. Activate the virtual environment:

    $ cd drc
    $ source env/bin/activate
    
  2. Update the code and libraries:

    (env) $ git pull
    (env) $ pip install -r requirements/dev.txt
    (env) $ npm install
    
  3. Update the database:

    (env) $ python src/manage.py migrate