diff --git a/README.md b/README.md index 76befc2..e105ea0 100644 --- a/README.md +++ b/README.md @@ -120,7 +120,7 @@ src/ ### Prerequisites - **Node.js ≥ 18** -- The [Octraban backend](https://github.com/octraban/octraban_backend) running locally (provides the indexer API the UI reads from), or a reachable indexer URL +- The **[octraban_backend](https://github.com/pharuq411/octraban_backend)** indexer running locally on `:3001` (provides all `/api/*` data the UI reads from). Clone and start it first — the frontend will show a prominent banner until the backend is reachable. - A [Freighter](https://www.freighter.app/) wallet for signing (optional, for write flows) ### Installation @@ -165,18 +165,121 @@ The defaults point at **Stellar testnet**, so a fresh checkout talks to the live Octraban is split across three repositories: - **octraban_frontend** _(this repo)_ — the explorer & developer workspace UI. -- **[octraban_backend](https://github.com/octraban/octraban_backend)** — the API + indexer that ingests on-chain data and serves it to the UI (`:3001`). +- **[octraban_backend](https://github.com/pharuq411/octraban_backend)** — the API + indexer that ingests on-chain data and serves it to the UI (`:3001`). - **[octraban_contract](https://github.com/octraban/octraban_contract)** — the Soroban smart contracts (explorer registry + ticket), deployed to testnet. +### Port topology + +| Service | Default port | Notes | +| -------------------------------- | ------------ | -------------------------------------------------- | +| **octraban_frontend** (Vite dev) | `:5173` | `npm run dev`; production build served on `:3000` (nginx / Docker) | +| **octraban_backend** (indexer) | `:3001` | All `/api/*` traffic is proxied here | +| **Soroban RPC** | n/a | `VITE_SOROBAN_RPC_URL` (testnet default) | + ``` -Freighter ─┐ - ▼ - octraban_frontend ──▶ octraban_backend (indexer :3001) ──▶ Soroban RPC / testnet - (this repo) ▲ - │ - octraban_contract (deployed testnet contracts) +Browser (user) + │ + ▼ +octraban_frontend :5173 dev / :3000 prod + │ all /api/* requests + ▼ +octraban_backend (indexer) :3001 ◀─── start this first + │ + ▼ +Soroban RPC / Stellar testnet + ▲ + │ +octraban_contract (deployed testnet contracts) ``` +In development, Vite proxies every `/api/*` request to `http://localhost:3001` (configured in `vite.config.ts`). The production Docker image uses nginx for the same proxy. **The frontend will display a banner and all data views will fail if the backend is not running.** + +--- + +## 🔌 Backend API contract + +> All endpoints are served by the [octraban_backend](https://github.com/pharuq411/octraban_backend) indexer on port **3001**. +> In development the Vite proxy (`server.proxy` in `vite.config.ts`) forwards `/api → http://localhost:3001` so the frontend always uses relative `/api/*` paths. + +### Health + +| Method | Path | Description | +| ------ | ------------ | ------------------------------------------------ | +| GET | `/api/health` | Liveness check — 200 OK when the indexer is up. Used by `BackendStatusBanner` on startup. | + +### Explorer — read endpoints + +| Method | Path | Description | +| ------ | ---- | ----------- | +| GET | `/api/events` | Paginated event list (`?contract=&fn=&page=&type=`) | +| GET | `/api/events/:seq` | Single decoded event | +| GET | `/api/events/:seq/zk-costs` | CAP-0080 ZK host-function telemetry for an event | +| GET | `/api/search` | Universal search (`?q=&limit=`) — contracts, events, wallets | +| GET | `/api/contracts/:id` | Contract metadata + ABI | +| GET | `/api/contracts/:id/abi` | Download ABI as JSON blob | +| GET | `/api/contracts/:id/spec-full` | Full contract spec (functions + custom types) | +| GET | `/api/contracts/:id/migration-status` | SEP-49 migration state | +| GET | `/api/contracts/:id/roles` | Privileged role addresses | +| GET | `/api/contracts/:id/network-comparison` | State across networks | +| GET | `/api/contracts/:id/address-graph` | Address relationship graph data | +| GET | `/api/contracts/:id/circuit-breaker` | Circuit-breaker pause status | +| GET | `/api/contracts/:id/rwa-metadata` | Real-world asset token metadata | +| GET | `/api/contracts/:id/source-verifications` | Multi-sig source verifications (`?wasm_hash=`) | +| GET | `/api/contracts/:id/ttl` | Live TTL for instance + code entries | +| GET | `/api/contracts/:id/state-diffs` | Storage state-diff timeline (`?key=`) | +| GET | `/api/contracts/:id/quorum-freeze` | CAP-0077 quorum-freeze status | +| GET | `/api/burn-alerts` | Burn-rate alerts (`?contract=`) | +| GET | `/api/wallet/:address` | Events for a wallet address | +| GET | `/api/contract-graph` | Global contract dependency graph (`?limit=`) | +| GET | `/api/v1/contracts/:id/events-deep` | Events where contract appears directly or as sub-invocation (`?page=`) | + +### Transactions & sub-invocations + +| Method | Path | Description | +| ------ | ---- | ----------- | +| GET | `/api/transactions/:txHash/sub-invocations` | Sub-invocation tree for a transaction | +| GET | `/api/transactions/:txHash/status` | Transaction status (polling) | +| GET | `/api/transactions/:txHash/status/stream` | Live status via Server-Sent Events | +| GET | `/api/transactions/:txHash/call-path-metrics` | Analytical call-path metrics | +| GET | `/api/transactions/compare` | Cross-transaction tree diff (`?a=&b=`) | +| GET | `/api/sub-invocations/search` | Filtered sub-invocation search (8+ filter params) | +| GET | `/api/sub-invocations/analytics` | Aggregate analytics across all sub-invocations | +| GET | `/api/sub-invocations/stream` | SSE feed of live sub-invocations (`?contract=&function=`) | + +### Write & simulation + +| Method | Path | Description | +| ------ | ---- | ----------- | +| POST | `/api/contracts/:id/source-verifications` | Submit a source verification signature | +| POST | `/api/simulate` | Simulate a single contract invocation | +| POST | `/api/batch/simulate` | Batch multi-call simulation | +| POST | `/api/batch/estimate-gas` | Batch gas estimation | +| POST | `/api/batch/optimize` | Batch call-order optimisation | +| POST | `/api/batch/validate` | Batch call validation | + +### Sandbox persistence + +| Method | Path | Description | +| ------ | ---- | ----------- | +| POST | `/api/sandbox` | Save a sandbox session | +| GET | `/api/sandbox/:id` | Load a sandbox session | +| DELETE | `/api/sandbox/:id` | Delete a sandbox session | +| GET | `/api/sandboxes` | List sandbox sessions (`?limit=&offset=`) | + +### Operations & admin + +| Method | Path | Description | +| ------ | ---- | ----------- | +| GET | `/api/rpc-metrics` | RPC layer latency, throughput, and circuit-breaker state | +| GET | `/api/admin/analytics/rate-limit-hits` | Rate-limit hit counts (`?minutes=60`) | +| GET | `/api/admin/analytics/top-users` | Top rate-limit offenders (`?window=`) | +| GET | `/api/admin/analytics/violation-heatmap` | Rate-limit heatmap | +| GET | `/api/admin/analytics/upgrade-recommendations` | Upgrade advisories | +| GET | `/api/setup/doctor` | Backend diagnostic / health check | +| POST | `/api/setup/test-db` | Test database connection | +| POST | `/api/setup/save-config` | Persist backend configuration | +| POST | `/api/setup/db-init` | Initialise the database | + --- ## 🤝 Contributing diff --git a/src/App.tsx b/src/App.tsx index ef05549..ef67906 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -2,6 +2,7 @@ import { lazy, Suspense } from "react"; import { Routes, Route } from "react-router-dom"; import Nav from "./components/Nav"; import ErrorBoundary from "./components/ErrorBoundary"; +import BackendStatusBanner from "./components/BackendStatusBanner"; const Home = lazy(() => import("./pages/Home")); const ContractPage = lazy(() => import("./pages/ContractPage")); @@ -31,6 +32,7 @@ function Fallback() { export default function App() { return ( +