🔤 Unfamiliar with Soroban, XDR, instance storage, or persistent storage? See the Glossary.
This document gives contributors a quick map of the Trivela system, the trust boundaries, and how data moves across contracts, backend, and frontend.
flowchart LR
U[User Wallet / Browser] --> F[Frontend React + Vite]
F -->|REST /api/v1| B[Backend Express API]
F -->|Soroban RPC calls| R[(Soroban RPC)]
B -->|Health + config checks| R
R --> C1[Rewards Contract]
R --> C2[Campaign Contract]
B --> D[(Campaign DB / in-memory store)]
-
frontend/- Renders campaigns, wallet UX, and claim/register actions.
- Handles client-side loading/error states and route-level rendering recovery.
- Reads API and contract configuration from
VITE_*env values.
-
backend/- Serves campaign CRUD endpoints under
/api/v1. - Exposes health/config/metrics endpoints for operations and integrations.
- Applies request logging, optional API-key auth for writes, and rate limiting.
- Serves campaign CRUD endpoints under
-
contracts/rewards- Tracks user points, credit events, and claims.
- Enforces contract-level authorization and reward accounting.
-
contracts/campaign- Tracks campaign lifecycle and participant registration.
- Stores campaign-level constraints enforced on-chain.
- User wallet signatures are the source of truth for user-authorized contract actions.
- Smart contracts are authoritative for on-chain balances, claims, and campaign participation.
- Backend API is authoritative for off-chain campaign metadata served to the UI.
- Frontend is untrusted for business logic enforcement; it should only orchestrate and display state.
- Frontend calls
GET /api/v1/campaigns. - Backend reads from campaign store and returns paginated data.
- Frontend renders cards/details with loading and retry behavior.
- User connects wallet in frontend.
- Frontend constructs/registers transaction via Soroban RPC.
- Campaign contract validates rules and persists participant state.
- Frontend reads wallet points from rewards contract.
- User submits claim action.
- Rewards contract validates and updates on-chain balances/events.
- Health checks:
/health,/health/rpc. - Metrics scrape:
/metrics(request totals, errors, route hit counters, uptime gauge).
- Keep contract IDs stable while evolving logic by using Soroban Wasm upgrades plus explicit schema migrations.
- Move toward a deployer/governance-controlled upgrade authority instead of relying on a single long-lived admin key.
- Maintain a repeatable rollout sequence: install Wasm -> upgrade -> migrate -> verify
schema_version. - Full migration details and runbook: see
docs/upgradeability.md.