taquiles / nuagesdr

Showcase using Python, Django, DjangoRestFramework and Vue over REST Api

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

This showcase implements a platform (or a feature subset) which allow to retrieve, from the backend, a Form so Insurance Careers may customize data to be collected per insurance.

Use Case

The Use case is depicted below.

Use Case

Architecture

The prerequisites included Python and Vue (ES6 flavor).

DjangoRestframework, a Django framework, was used for Rest Library and for the MVT pattern (Model-View-Template). Other option, with similar features, would be Flask.

System-Components

Database

The ER Diagram below includes two more tables to contextualize properly tables that were implemented

ERD

Requisites and Configuration

  1. To run this showcase, and for better compliance with tests done, verify if the following versions are installed:
  • Python and pip: 6.3.1
  • node : 6.10.3
  • virtualenv installed
  1. Edit settings.py to configure database access

    2.1. Configure the database name (DATABASES.NAME);

    2.2. Update user and password with right permissions (DATABASES.USER and DATABASES.PASSWORD);

    2.3. On postgresql create a database whose name is the same as in step 1:

     e.g.
     CREATE DATABASE otherdb;
    
     DATABASES = {
     	'default': {
     		'ENGINE': 'django.db.backends.postgresql',
     			'NAME': 'nuages',	        
     			'USER': 'postgres',
     			'PASSWORD': 'a',
     			'HOST': 'localhost',
     			'PORT': '5432',
     	}
     }
    
  2. After database access configuration, you may choose to run

     chmod -x install_all.sh
     ./install.sh
    

which will perfom all the remaining steps.

  1. Create Python Environment:

     cd <project_root> # that would be nuagesdr
     cd nuagedr
     virtualenv --python=python3.6 env
     source env/bin/activate
    
  2. Install backend python packages:

     cd <project_root> # that would be nuagesdr
     pip install -r requirements.txt
    
  3. Run the Migration that will create tables and load data:

     cd nuagesdr/nuagesdr
     python ./manage.py migrate
     python manage.py loaddata backend/fixtures/initial_data.json 
    
  4. Install frontend npm packages:

     cd <project_root> # that would be nuagesdr
     cd frontend
     npm install  
    

Startup the Application

Backend

  • Run the following to start the backend application:

      cd <project_root> # that would be nuagesdr
      cd nuagesdr
      python manage.py runserver
    

Frontend

  • Run the following to start the frontend application:

      cd <project_root> # that would be nuagesdr
      cd frontend
      npm run dev	
    

Run Test on RESP Api endpoint:

	cd nuagesdr/frontend
	npm test
  • The above performs the following tests:
  1. Site is up
  2. REST endpoint is up and returns a JSON file
  3. Retrieves a single record from REST API
  4. Retrieves all records from REST API.

About

Showcase using Python, Django, DjangoRestFramework and Vue over REST Api


Languages

Language:JavaScript 64.3%Language:Python 27.2%Language:HTML 4.0%Language:Shell 2.8%Language:Vue 1.2%Language:CSS 0.5%