# IV Інструкція
## Auth Module
Для аутентифікації користувачів використвуємо номер телефону на який приходить OTP, після цього вводиться пароль.
## Collection Module
Колекції - це надбудова надо NFT, оскільки Flow не дає можливості нормально створювати колекції, то вони створені на бекенді.
## Exel Module
Для генерації звітів.
## External Module
Модуль зовнішнього API у нього є свій свагер і свій токен який генерується для кожної компанії.
## NFT Module
Відповідальний за дії з NFT.
Життєвий цикл NFT:
1) Mint NFT виключно на бекенді, без створення його в блокчейні.
2) Transfer NFT певному юзеру, в цей момент ми створюємо NFT напряму на гаманець юзера, оскільки Flow погано працює з трансферами і постійно ламається.
3) Burn Nft. При запиті до певної NFT формується JWT token і передається на фронт -> афіліат його сканує -> через вебсокет до користувача відправляється повідомлення де він може підтвердити, що він хоче скористатись цим NFT.
## Notification Module
Відповідальний за відправку повідомлень користувачу. Працює через Firebase і вебсокети.
## Requests Module
Відповідальний за запити до користувача.
Типи запитів:
1) burn - чи хоче користувач використати свою NFT.
2) transfer - чи хоче користувач отримувати NFT від певної компанії.
## Transactions Module
Відповідальний за зберігання всіх транзакцій у блокчейні. При завершенні транзакції з Flow Api приходить callback на з параметром JobId(внутрішні параметр блокчейна)
## Transfers Module
Відповідальний за передачу NFT докористувача(за створення на гаманці)
## Users Module
Відповідаж за маніпуляції з користувачем.
Ролі користувача:
1) Publisher - компанія, яка створю NFT і передає їх користувачу(може все в рамках свого бренду), має доступ до адмінки
2) Affiliate - менеджер, який може сканувати NFT користувача
3) User - не може нічого крім використання NFT.
Ролі записуються в базу як массив([publisher, affiliate, user]). У паблішера є такі самі можливості як у affiliate і user.
## Wallets module
Відповідає за створення гаманців, гаманці створюються при реєстрації користувача. Коли гаманець створений стає ``active``.
-----------------------------
# IV Instruction
## AuthModule
To authenticate users, we use the phone number to which the OTP arrives, after which the password is entered.
## Collection Module
Collections are an add-on to NFT, since Flow does not allow you to create collections normally, they are created on the backend.
## Excel Module
To generate reports.
## External Module
The external API module has its own swagger and its own token, which is generated for each company.
## NFT Module
Responsible for actions with NFT.
NFT life cycle:
1) Mint NFT exclusively on the backend, without creating it in the blockchain.
2) Transfer NFT to a certain user, at this moment we create NFT directly to the user's wallet, because Flow does not work well with transfers and constantly crashes.
3) Burn Nft. When requesting a certain NFT, a JWT token is generated and sent to the front -> the affiliate scans it -> a message is sent to the user via websocket where he can confirm that he wants to use this NFT.
## Notification Module
Responsible for sending messages to the user. Works through Firebase and websockets.
## Requests Module
Responsible for user requests.
Request types:
1) burn - does the user want to use his NFT.
2) transfer - does the user want to receive NFT from a certain company.
## Transactions Module
Responsible for storing all transactions in the blockchain. When the transaction is completed with the Flow Api, a callback with the JobId parameter (an internal parameter of the blockchain) arrives
## Transfers Module
Responsible for the transfer of NFT to the user (for creation on the wallet)
## Users Module
Responsibility for manipulations with the user.
User roles:
1) Publisher - the company that will create NFT and transfer them to the user (maybe everything within the framework of its brand), has access to the admin
2) Affiliate - a manager who can scan a user's NFT
3) User - can do nothing but use NFT.
Roles are recorded in the database as an array ([publisher, affiliate, user]). The publisher has the same opportunities as the affiliate and user.
## Wallets module
Responsible for creating wallets, wallets are created upon user registration. When the wallet is created it becomes ``active``.