SafeTrust is a decentralized platform designed to revolutionize P2P transactions, providing secure deposits and payments powered by blockchain and trustless technologies. πβ¨ Experience transparency and reliability in every cryptocurrency transaction. πΈπ
| Tool | Version | Notes |
|---|---|---|
| Docker & Docker Compose | β₯ 24 | Required |
| Hasura CLI | β₯ 2.x | Required for migrations & seeds |
| curl | any | Used by health-check loop |
Windows users: Run
bin/dc_prepandbin/dc_consoleinside WSL (Ubuntu) or Git Bash, as they are Bash scripts targeting a Linux container environment.
bin/dc_prep is the single entry point to bootstrap the entire backend. It starts all containers, deploys Hasura metadata for every tenant, applies database migrations, and seeds initial data β in the correct order.
cp .env.example .env # fill in your values first
bin/dc_prep # boots everythingOnce it completes, open the Hasura console in a separate terminal:
bin/dc_console| Step | Action |
|---|---|
| 1 | Start postgres, graphql-engine, and webhook containers via Docker Compose |
| 2 | Poll GET /healthz until Hasura is ready (up to 3 min) |
| 3 | Build and deploy tenant metadata for all tenants (metadata/setup-tenant.sh) |
| 4 | Apply all database migrations (hasura migrate apply) per tenant |
| 5 | Reload Hasura metadata |
| 6 | Apply seed data (hasura seed apply) per tenant |
By default, bin/dc_prep deploys all tenants (safetrust and hotel_industry). You can pass tenant names as arguments to limit the scope:
# Deploy all tenants (default)
bin/dc_prep
# Deploy a single tenant
bin/dc_prep safetrust
# Deploy multiple specific tenants
bin/dc_prep safetrust hotel_industryCopy .env.example to .env and fill in the required values before running bin/dc_prep:
POSTGRES_PASSWORD=your_postgres_password
# Must be valid JSON with a minimum 32-character key for HS256
HASURA_GRAPHQL_JWT_SECRET={"type":"HS256","key":"replace-with-min-32-char-secret-here"}
HASURA_EVENT_SECRET=your_event_secret
β οΈ HASURA_GRAPHQL_JWT_SECRETmust be valid JSON and the key must be at least 32 characters for HS256. The script will fail at startup if this is malformed.
The metadata/ folder contains the Hasura GraphQL Engine configuration per tenant.
backend/
βββ metadata/
βββ base/
β βββ actions.graphql
β βββ actions.yaml
β βββ allow_list.yaml
β βββ api_limits.yaml
β βββ backend_configs.yaml
β βββ cron_triggers.yaml
β βββ graphql_schema_introspection.yaml
β βββ inherited_roles.yaml
β βββ metrics_config.yaml
β βββ network.yaml
β βββ opentelemetry.yaml
β βββ query_collections.yaml
β βββ remote_schemas.yaml
β βββ rest_endpoints.yaml
β βββ version.yaml
βββ build/
β βββ tenant_a/
β βββ tenant_b/
β βββ ...
βββ tenants/
β βββ safetrust/
β β βββ databases/
β β βββ tables/
β β βββ functions/
β β βββ databases.yaml
β βββ hotel_industry/
β βββ databases/
β βββ tables/
β βββ functions/
β βββ databases.yaml
βββ build-metadata.sh
βββ deploy-tenant.sh
βββ setup-tenant.sh
Folder guide:
base/β Hasura base configuration and GraphQL dependencies shared across all tenantsbuild/β Generated output: tenants merged with base dependencies, ready to deploytenants/β Tenant-specific database files, tables, functions, relations, and triggersbuild-metadata.shβ Prepares a tenant by merging it with base configurationsdeploy-tenant.shβ Deploys a built tenant to Hasura (tracks tables and relationships)setup-tenant.shβ Runs both steps above in one command β
Tip:
bin/dc_prephandles all of the following automatically. Use these only when targeting a specific step or tenant in isolation.
cd metadata
./setup-tenant.sh <tenant_name> [--admin-secret SECRET] [--endpoint URL]Example:
./setup-tenant.sh safetrust --endpoint http://localhost:8080Default values: --admin-secret myadminsecretkey Β· --endpoint http://localhost:8080
Or step by step:
# Step 1 β Build
./build-metadata.sh <tenant_name> --admin-secret myadminsecretkey --endpoint http://localhost:8080
# Step 2 β Verify build/ folder contains the correct tenant data
# Step 3 β Deploy
./deploy-tenant.sh <tenant_name> --admin-secret myadminsecretkey --endpoint http://localhost:8080From the project root:
hasura migrate apply \
--database-name safetrust \
--endpoint http://localhost:8080 \
--admin-secret myadminsecretkeyTo apply a single migration version:
hasura migrate apply \
--database-name safetrust \
--version <timestamp> \
--type up \
--endpoint http://localhost:8080 \
--admin-secret myadminsecretkeyhasura seed apply \
--database-name safetrust \
--endpoint http://localhost:8080 \
--admin-secret myadminsecretkeyThis project uses the Karate framework for API testing. Tests run in a Docker environment.
docker compose -f docker-compose-test.yml run --rm --build karateThis command will:
- Build the test container
- Start PostgreSQL and Hasura containers
- Run all Karate tests
- Show test results in the console
- Generate HTML reports in
target/karate-reports/
After running the tests, find the HTML reports at:
- Summary:
tests/results/karate-summary.html - Detailed:
tests/results/karate-tags.html
- Create new
.featurefiles intests/karate/features/ - Follow the Karate DSL syntax
- Tests are automatically picked up when running the test command
- Main config:
tests/karate/src/test/resources/karate-config.js - Database config:
docker-compose-test.yml - Test environment:
Dockerfile.test