Backend to manage different equipment of an FPSO (Floating Production, Storage and Offloading)
Table of Contents
- 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
Python 3
- Clone the repository:
git clone https://github.com/ThiagoKoster/FPSOEquipmentManager
- Setup virtual environment:
python -m venv venv .\venv\Scripts\activate pip install -r requirements.txt
python app.py
This will start the application at http://localhost:5000/api/v1
It's possible to do all requests with swagger!
- The swagger doc can be accessed at http://localhost:5000/api/v1/doc when the application is running.
- All models can be seen at the "Models" section.
- POST /vessels
- GET /vessels
- POST /vessels/[id]/equipments
- PATCH /vessels/[id]/equipments
- GET /vessels/[id]/equipments
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": []
}
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"
}
]
}
]
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"
}
]
Inactivate equipments of the vessel
Example: PATCH http://localhost:5000/api/v1/vessels/2/equipments
Request body:
[
{
"code": "GPS001"
}
]
Response: 204 No Content
Get all equipments of the vessel, can be filtered by status
- Return all ACTIVE equipments:
-
GET http://localhost:5000/api/v1/vessels/2/equipments?status=ACTIVE
Response: 200 OK
[ { "id": 2, "name": "GPS", "code": "GPS002", "location": "Brazil", "status": "ACTIVE" } ]
-
- Return all equipments of the vessel:
- GET http://localhost:5000/api/v1/vessels/2/equipments
[ { "id": 1, "name": "GPS", "code": "GPS001", "location": "Brazil", "status": "INACTIVE" }, { "id": 2, "name": "GPS", "code": "GPS002", "location": "Brazil", "status": "ACTIVE" } ]
- GET http://localhost:5000/api/v1/vessels/2/equipments
Thiago Koster Lago - thiagokoster@gmail.com