Skip to content
For the complete documentation index, see llms.txt. This page is also available as Markdown.

Running the Composite Locally

Running the Composite locally.

The service is in composite/backend. It needs Python 3.11 or later (the image uses 3.12), openg2p-fastapi-common from develop (crypto, including PartnerMgmtKeyStore for partner keys from PM, is in openg2p_fastapi_common.crypto) and iam-core from the IAM develop line (the console's staff login).

cd composite/backend
python3.11 -m venv .venv && . .venv/bin/activate
pip install "git+https://github.com/openg2p/openg2p-fastapi-common@develop#subdirectory=openg2p-fastapi-common"
pip install "git+https://github.com/openg2p/iam@develop#subdirectory=iam-core"
pip install -e ".[test]"
pytest                                     # no network needed

openssl ecparam -name prime256v1 -genkey -noout -out /tmp/composite.pem   # a test signing key
export AGRI_COMPOSITE_USE_CASES_DIR=../use-cases
export AGRI_COMPOSITE_SIGNING_KEY_PEM_PATH=/tmp/composite.pem AGRI_COMPOSITE_SIGNING_KID=composite-local
export AGRI_COMPOSITE_PARTNER_MGMT_API_URL=http://localhost:9001          # a PM partner-api
export AGRI_COMPOSITE_REGISTRIES='{"farmer-registry":{"url":"http://localhost:9002/dci/registry/sync/search"},
                                  "crop-sown-registry":{"url":"http://localhost:9003/dci/registry/sync/search"}}'
python -m openg2p_agri_composite.main run  # http://localhost:8000/docs
  • The ports are examples: point PARTNER_MGMT_API_URL and REGISTRIES at a PM partner API and the registries' partner APIs you can reach, e.g. through kubectl port-forward.

  • The partner's and the Composite's public keys must be in that PM (PARTNER_BANK_A, PARTNER_AGRI_COMPOSITE; the Composite's from http://localhost:8000/.well-known/jwks.json), and the partner needs a policy there for the use case (loan-profile@1).

  • With the console off (the default outside the chart) the service has no database; startup only loads the use cases. The chart turns the console on, which needs a database, IAM and Redis (see Composite console).

  • The consent mode is exchange by default: set AGRI_COMPOSITE_CONSENT_EXCHANGE_CM_URL to a reachable CM partner API (the default is the in-cluster service), or AGRI_COMPOSITE_CONSENT_MODE=passthrough to skip the Exchange CM.

Then read it as a partner would:

A signed query needs a partner key in that PM: the test's signing functions show how to build one.

Building the image

The Dockerfile is composite/docker/agri-composite-api/Dockerfile. CI builds and publishes the image (openg2p/openg2p-agri-composite-api) and the chart only when something under composite/ changes, not on documentation-only pushes.

Last updated

Was this helpful?