YDI-YOI Backend
Upload new QR codes into DataBase
In this case we are going to connect to the Database and run a AQL file using ‘psql’.
Before doing the following steps, please upload the SQL file into the 'db_scripts' directory.
Step 1: Connect to PostgreSQL
psql postgres
Step 2: Connect to the specified database before executing the SQL script. (YDIYOI)
\c 'database_name'
Step 3: Execute the SQL file with the ' \i ' command.
\i \path\TO\file_name.sql
QR scanning use case
The buyer of an MTB bottle scans the QR code on the bottle.
The QR code value is of the URL type with the format www.WebAppUrl.com/QR_id (OpenVino - You Drink It, You Own It!
The web App takes the QR id parameter and validates it.
Invoke API /qrstatus/{qr id}
The API returns: status id and if that wine can be claimed.
{id: 5, allowClaim : false } allowClaim=false: the wine has already been claimed or does not exist.
{id: 1 , allowClaim : true } allowClaim=true: the wine can be claimed.
If the QR id is NOT valid, it comes out explaining the Error.
If the QR id is valid and has not been previously claimed, continue.
If the user is already registered on the platform and his password stored, he goes directly to the Experience Register.
If the user is already registered on the platform and his password is NOT stored, he goes to the Login screen.
If the user is NOT registered on the platform, they go to the User Registration screen.
After registration, the user remains in "PendiaValidation" state, waiting for an admin to validate their data and request additional information if necessary, after completing the information, it goes to "Active" status.
After login or registration:
If you arrive from the scan of a new valid QR, go to the Experience Registration form.
If it does NOT arrive from the scanning of a new QR, by default it shows experience history, experience status and tokens per experience.
Balance of tokens by status: Pending and validated.
Option to go to Experience Registration.
Experience Record
If it arrives from the scan of a new valid QR:
Show Experience Registration form:
Photo Upload: Filename + date + User id.
Experience Log: Experience id.
Date.
Location.
PhotoFile Name.
User id.
Survey Record:
Find active questions to answer:
First Question.
First Answer.
Second Question.
Second Answer.
Third Question.
Third Answer.
Experience Id previously obtained.
If it does NOT arrive from the scan of a new QR.
Request QR upload and validate QR id:
Open camera to scan QR.
Take only the QR _id from the QR value.
Invoke API /qrstatus/(qr_id):
The API returns: status id and if that wine can be claimed.
{ id : 5 , allowClaim : false } allowClaim=false: the wine has already been claimed or does not exist.
{ id : 1 , allowClaim : true } allowClaim=true: the wine can be claimed.
Show Experience Registration form:
Photo Upload: Filename + date + User id.
Experience Record: Experience id.
Date.
Location.
PhotoFile Name.
User id.
Survey record:
Find active questions to answer:
First Question.
First Answer.
Second Question.
Second Answer.
Third Question.
Third Answer.
Experience Id previously obtained.
The new experience has been Registered:
User receives confirmation of registration and can see the new Experience uploaded in the Experience History.
After validating the experience by the admin, it changes to "pending validation" "assigned", or indicates that the tokens have been credited to the user.
QR code Initial Generation
Table Wine The token ratio is now 1 to 1. 1 wine = 1 NFT token.
BOTTLE_NO: Sequential number of bottles, from 1 to 16384.
QR_ID: Wine + bottle number + 5-digit random alphanumeric code
The ur of the QR would be as follows: https://nft.openvino.org/M1818.00006
Experience: QR_ID: add qr_id to Experience, and after inserting experience, update Wine. ExperienceId with the new id generated for that qe_id. The initial status of a new experience is accredited, no more pending validation.
NOTE: If no path is specified, then PSQL will use the directory that was last accessed before connecting to PostgreSQL in order to execute the SQL file.
Relationship Entity Diagram