Skip to content

Backend to manage different equipment of an FPSO (Floating Production, Storage and Offloading)

Notifications You must be signed in to change notification settings

thiagokoster/FPSOEquipmentManager

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FPSOEquipmentManager

Backend to manage different equipment of an FPSO (Floating Production, Storage and Offloading)

Table of Contents
  1. About The Project
  2. Set Up
  3. Usage
  4. Contact

About The Project

Built With

  • Flask - Micro web framework.
  • flask-restx - Adds decorators to describe the API and expose its documentation properly using Swagger.
  • marshmallow - Creates schemas for validation and serialize/deserialize data.
  • SQLAlchemy - ORM (Object Relational mapper) for database access.
  • SQLite - Data persistence and in memory database for unit tests.
  • Github Actions - Created a workflow to execute automate tests when a Pull Request is done
  • Waitress - Production server
  • Paste - Paste.Translogger to log traffic request on the console

Set up

Prerequisites

Python 3

Installation

  1. Clone the repository:
    git clone https://github.com/ThiagoKoster/FPSOEquipmentManager
  2. Setup virtual environment:
    python -m venv venv
    .\venv\Scripts\activate
    pip install -r requirements.txt

Usage

Run the application

 python app.py

This will start the application at http://localhost:5000/api/v1

Test the application

It's possible to do all requests with swagger!

API Resources

POST /vessels

Registers a new vessel with an unique code in the database

Example: POST http://localhost:5000/api/v1/vessels

Request body:

{
    "code": "BR-RJ002"
}

Response: 201 CREATED

{
    "id": 2,
    "code": "BR-RJ002",
    "equipments": []
}

GET /vessels

Returns all vessels in the database

Example: GET http://localhost:5000/api/v1/vessels

Response: 200 OK

[
    {
        "id": 1,
        "code": "BR-RJ001",
        "equipments": []
    },
    {
        "id": 2,
        "code": "BR-RJ002",
        "equipments": [
            {
                "id": 1,
                "name": "GPS",
                "code": "GPS001",
                "location": "Brazil",
                "status": "ACTIVE"
            },
            {
                "id": 2,
                "name": "GPS",
                "code": "GPS002",
                "location": "Brazil",
                "status": "ACTIVE"
            }
        ]
    }
]

POST /vessels/[id]/equipments

Registers new equipment for the vessel

Example: POST http://localhost:5000/api/v1/vessels/2/equipments

Request body:

[
    {
    "name": "GPS",
    "code": "GPS001",
    "location": "Brazil"
    },
    {
    "name": "GPS",
    "code": "GPS002",
    "location": "Brazil"
    }
]

Response: 201 CREATED

[
    {
        "id": 1,
        "name": "GPS",
        "code": "GPS001",
        "location": "Brazil",
        "status": "ACTIVE"
    },
    {
        "id": 2,
        "name": "GPS",
        "code": "GPS002",
        "location": "Brazil",
        "status": "ACTIVE"
    }
]

PATCH /vessels/[id]/equipments

Inactivate equipments of the vessel

Example: PATCH http://localhost:5000/api/v1/vessels/2/equipments

Request body:

[
  {
    "code": "GPS001"
  }
]

Response: 204 No Content

GET /vessels/[id]/equipments

Get all equipments of the vessel, can be filtered by status

Contact

Thiago Koster Lago - thiagokoster@gmail.com

About

Backend to manage different equipment of an FPSO (Floating Production, Storage and Offloading)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages