TradeFlow-API is the backend service layer for the TradeFlow protocol. It bridges the on-chain Soroban contracts with off-chain Real-World Asset (RWA) data.
The service performs three critical functions:
- Event Indexing: Listens to
TradeFlow-Corecontract events (Minting, Repayment) and indexes them into PostgreSQL. - Risk Engine: Processes PDF invoices and assigns risk scores (0-100) signed by our oracle key.
- Auth: Manages user sessions via wallet signatures (SIWE - Sign In With Ethereum/Stellar style).
We use Docker for a consistent development environment.
services:
api:
build: .
ports: ["3000:3000"]
db:
image: postgres:15
environment:
POSTGRES_DB: tradeflowThe API is configured with strict Cross-Origin Resource Sharing (CORS) policies to ensure secure communication:
- Allowed Origins:
http://localhost:3000(Local Development)https://tradeflow-web.vercel.app(Production)
- Allowed Methods:
GET,POST,PUT,PATCH
To verify the CORS configuration, ensure dependencies are installed and the server is running, then execute the test script:
# 1. Install dependencies
npm install
# 2. Start the server
npm run start
# 3. Run the CORS verification script (in a new terminal)
node test-cors.js