server workspace runs the Express API for market data, CoverFi AI, health checks, legal/privacy notices, status endpoints, partner APIs, protected invoices, webhooks, optional KYC/KYB hooks, and compatibility routes. Username ownership, username payment execution, protection creation, settlement, payout claims, principal withdrawal, payment resolution, and receipt anchoring are contract/client flows.
The backend is not an authoritative product database. Private profile, payment, receipt, draft, and AI records live in wallet-unlocked encrypted browser storage. Protocol state lives on Stellar/Soroban.
Security controls
Current controls:- JSON body size limit of
32kb. - Structured request logs with request IDs.
- Wallet addresses and transaction hashes redacted from standard request paths.
- Wallet identifiers in logs and rate limits are HMAC pseudonyms.
- Route-specific rate limits.
- Schema validation for wallets, receipts, legal notices, account compatibility routes, and AI prompts.
- Wallet-signed challenge/session authentication for private wallet resources.
- Session issuer, audience, terms version, token ID, expiry, timing-safe HMAC validation, and in-memory revocation.
- Local CORS support for the main app, preview app, and protocol monitor.
AUTH_SESSION_SECRET, a stable PRIVACY_HMAC_SECRET, shared session revocation storage, and distributed rate limits. Local development may use process-local fallback secrets, but that invalidates sessions on restart.
Private route authentication
Private routes require:POST /api/auth/challenge- Wallet signs the returned challenge message.
POST /api/auth/session
Storage boundary
The following compatibility endpoints do not persist product records server-side:POST /api/legal/acceptGET /api/account/:walletAddressPUT /api/account/:walletAddressPOST /api/payments/saveGET /api/payments/:usernamePOST /api/receipts/saveGET /api/privacy/export/:walletAddressDELETE /api/privacy/:walletAddressGET /api/ai/chat/:walletAddress
Health checks
GET /api/health returns:
okaiConfiguredaccountStoragereceiptStorageanalyticsWalletStoragebackendProductDatabasetermsVersion
Protocol status endpoints
The backend exposes read-only status routes for public monitoring:GET /api/status/contractsGET /api/status/oracleGET /api/status/reserveGET /api/status/atlassianGET /api/status/proof-of-reserve
/api/status/proof-of-reserve is intentionally testnet-only. It returns not_configured until a separate deployment-held Ed25519 signer is set through TESTNET_RESERVE_ATTESTATION_SECRET (and optionally its matching public key through TESTNET_RESERVE_ATTESTATION_PUBLIC_KEY). The secret is never returned; a configured endpoint returns a canonical payload, signer public key, and signature. This is an operational testnet attestation, not an audit or a guarantee of payout.
Protocol monitor
Thecoverfi-monitor workspace is a read-only Vite app for local operations. It reads:
GET /api/healthGET /api/legal/statusGET /api/pricesGET /api/portfolio/markets- Backend oracle and reserve status endpoints.
- Soroban contract getters for engine config, reserve pool state, oracle observations, and V2 quote checks.
Environment variables
Keep these server-side only:AUTH_SESSION_SECRETPRIVACY_HMAC_SECRETAZURE_OPENAI_API_KEYAZURE_OPENAI_ENDPOINTUPSTASH_REDIS_REST_TOKENSTATUSPAGE_API_KEYDATABASE_URLDIDIT_API_KEYDIDIT_WEBHOOK_SECRETPARTNER_API_KEY_PEPPER
VITE_API_BASE_URL- Stellar public contract IDs.
- Public asset contract IDs and issuer IDs.
- Public status/monitor URLs.
Deployment checklist
- Set stable auth and privacy HMAC secrets.
- Configure trusted proxy hops for the deployment platform.
- Configure contract IDs and public source account for read-only status calls.
- Configure Azure OpenAI only if AI support should be enabled.
- Configure Upstash or another distributed rate-limit backend for production scale.
- Run
npm run check,npm test, and frontend builds. - Verify
/api/health,/api/status/oracle, and/api/status/reserve. - Verify the monitor can read contract and backend state.
Partner API versions
The backend currently contains two partner API surfaces.
New technical reviewers should evaluate the modern
/api/partner/v1/* API first. Production work should align scopes, idempotency, webhook validation, and rate limits across the surviving API surface before mainnet scale.