Backend Service

The Backend Service is the core serving component of an OpenScan.AI deployment. It owns the database schema, executes queries against indexed data, and exposes the REST API that the frontend and external developers consume.


Responsibilities

  • REST API v2 — endpoints for blocks, transactions, addresses, tokens, NFTs, contracts, logs, and chain statistics. The same API shape as the production deployment documented at xdcscan.io/api-docs.
  • Schema ownership — database migrations ship with the backend and are applied during upgrades (see Explorer v2.1 Upgrade).
  • Read optimization — query paths are tuned for explorer access patterns: latest-first lists, address histories, token holder queries.
  • AI summary support — assembles the indexed context that AI insights summarize on transaction and contract pages.

How It Handles Load

  • Most responses are served from indexed tables — no chain-node round trips on the hot path.
  • List endpoints use cursor pagination (next_page_params) to keep response sizes bounded.
  • The service is stateless; run multiple replicas behind a load balancer for high-traffic deployments.

Configuration

Key environment variables:

Terminal window
DATABASE_URL=postgresql://explorer:****@postgres:5432/explorer_db
CHAIN_ID=50
API_RATE_LIMIT_PER_MINUTE=600
PUBLIC_API_BASE_URL=https://api.explorer.yourchain.example

See Branding & Configuration for the full reference.

Health and Verification

The backend exposes a health endpoint used by load balancers and your monitoring:

Terminal window
curl http://localhost:4000/api/v2/blocks

A JSON response containing recent blocks means the service and its database connection are healthy. Full checklist: Explorer Verification.

Upgrade Notes

  • Apply database migrations before starting new backend replicas.
  • Run rolling restarts when scaled horizontally — old and new replicas tolerate the same schema within a release.