📍 Page Location
URL: /create-contract
📸 Visual Representation of the Page
Tangent Token
Tether USD
USD Coin
🎨 Detailed Visual Description
Form includes: PDF upload (optional auto-fill), product dropdown (Rice, Wheat, Corn, etc. or "Other"), quantity, unit, price per unit with market comparison, currency selection (TGT/USDT/USDC), counterparty email, deposit percentage, voyage time, and description. Price comparison shows market average and variance warning if >5%. After submission, buyer sees confirmation message.
Key Visual Elements:
- PDF contract upload with auto-extraction
- Product dropdown with "Other" option
- Real-time price comparison with exchanges
- Currency selection (TGT/USDT/USDC)
- Form validation
- Email notification to supplier
⚙️ Backend Process
API Endpoint: POST /api/contracts/create
Process Flow:
1. Validates all required fields
2. Checks counterparty exists in database
3. Calculates totalValue = quantity × price
4. Calculates depositAmount = totalValue × (depositPercent/100)
5. Creates contract in database.contracts Map
6. Sets status: "pending_supplier_confirmation"
7. Sends email notification to supplier email address
8. Email contains contract details and link to dashboard
9. Logs audit event: contract_created
10. Returns contract ID and full contract objectDatabase Operations:
- Table:
database.contracts - Action: Create new contract
- Fields: id, product, quantity, unit, pricePerUnit, totalValue, currency, buyerEmail, supplierEmail, depositPercent, depositAmount, status, createdAt
➡️ Next Action
Email sent to supplier. Contract appears in supplier dashboard waiting for confirmation. Contract also appears in buyer dashboard with status "Waiting for Supplier Confirmation".