Royalty splitting for Nigeria's creative economy, powered by Stellar and Soroban.
SplitNaira is in active development. This repo currently contains:
contracts/Soroban smart contract and testsfrontend/Next.js + Tailwind scaffoldbackend/Express API scaffolddemo/Static HTML flow prototype
- Frontend: Next.js (App Router), TailwindCSS, TypeScript
- Backend: Node.js, Express, TypeScript
- Smart contracts: Soroban (Rust)
- Blockchain: Stellar (testnet + mainnet)
# Copy the environment template
cp .env.compose.example .env.local
# Start the entire stack (Postgres + Backend + Frontend)
docker compose up
# Access the services:
# - Frontend: http://localhost:3000
# - Backend API: http://localhost:3001
# - API Docs: http://localhost:3001/api/docs# Install all dependencies
npm run setup
# Development (all services)
npm run dev
# Build all projects
npm run build
# Run tests
npm run testPrerequisites:
- Node.js >= 18
- Rust (latest stable)
- Docker (optional, but recommended for compose setup)
Use npm scripts from the root to run commands across all projects:
| Command | Description |
|---|---|
npm run setup |
Install all dependencies for frontend, backend, and contracts |
npm run dev |
Start frontend and backend development servers |
npm run dev:frontend |
Start only frontend dev server |
npm run dev:backend |
Start only backend dev server |
npm run build |
Build all projects (frontend, backend, contracts) |
npm run build:frontend |
Build frontend |
npm run build:backend |
Build backend |
npm run build:contracts |
Build smart contracts |
npm run test |
Run all tests |
npm run test:frontend |
Run frontend tests |
npm run test:backend |
Run backend tests |
npm run test:contracts |
Run contract tests |
npm run lint |
Lint all projects |
npm run clean |
Clean build artifacts |
The docker-compose.yml provides a complete local stack for development and smoke testing:
Services:
- Postgres (
postgres:16-alpine): Database with automatic initialization - Backend (Express + TypeScript): API server with health checks
- Frontend (Next.js): Web application
Features:
- Postgres volume persistence
- Service health checks with ordered startup
- Environment variable templating via
.env.compose.example - Bridge networking for inter-service communication
- Production-ready multi-stage Docker builds
Quick Commands:
# Start the stack
docker compose up
# Start in background
docker compose up -d
# View logs
docker compose logs -f backend # Backend logs
docker compose logs -f frontend # Frontend logs
docker compose logs -f postgres # Database logs
# Stop services
docker compose down
# Reset database (remove volumes)
docker compose down -v
# Rebuild images
docker compose up --buildEnvironment Configuration:
Copy .env.compose.example to customize the stack:
cp .env.compose.example .env.local
# Edit .env.local as needed
docker compose --env-file .env.local upAccessing Services:
- Frontend: http://localhost:3000
- Backend API: http://localhost:3001
- API Documentation: http://localhost:3001/api/docs
- Database: localhost:5432 (user:
splitnaira, password:splitnaira)
For production wallet and payment operations, configure PAYMENTS_ADMIN_API_KEY on the backend before exposing /splits/admin/*. If payout-impacting admin actions need to be frozen during an incident or rollback, set PAYMENTS_ADMIN_WRITE_ENABLED=false and redeploy or restart the backend with the updated environment.
cd frontend
npm install
npm run devcd backend
npm install
npm run devcd contracts
cargo test --locked
rustup target add wasm32v1-none
cargo build --release --target wasm32v1-none --lockedsplitNaira/
├── backend/ # Express API
├── contracts/ # Soroban smart contracts
├── frontend/ # Next.js application
└── demo/ # Static prototype
| Endpoint | Purpose |
|---|---|
| /health/live | Liveness Probe |
| /health/ready | Readiness Probe |
| /health/startup | Startup Probe |
Used for Kubernetes, Docker Swarm and cloud deployment monitoring.
GET /metrics
All requests include:
X-Correlation-Id
Structured JSON logs are emitted for production monitoring.
Endpoint:
GET /ops/mainnet-readiness
Purpose:
- Deployment validation
- Launch verification
- Configuration auditing
- Mainnet configuration and readiness audit before traffic cutover
This endpoint performs a lightweight operational check that includes:
- environment configuration validation
- database connectivity verification
- cache and runtime capacity metrics
- production secret audit and contract ID consistency check
Use it as a pre-deploy gate during release and rollback planning.
npm install npm run verify:env npm run dev
npm run lint npm run test
npm run analyze
- Deployment Runbook
- Operational Runbooks (contracts, CI/CD, ops, frontend)
- Contributing Guide
- Contract Setup
- Contract Release & Upgrade
- Backend CD
- API Docs
- Mainnet Launch Runbook
- User Onboarding Runbook
- API Evolution Runbook
- Changelog
SplitNaira uses v0.x.y git tags for release traceability. A tag identifies the exact source state for backend, frontend, and smart contract code.
- Draft GitHub Releases are created automatically when a
v0.x.ytag is pushed, using the release notes fromCHANGELOG.md. - The contract WASM built from the tagged commit is the versioned smart contract artifact. The canonical build output is:
contracts/target/wasm32v1-none/release/splitnaira_contract.wasmcontracts/target/wasm32v1-none/release/release-info.json
CONTRACT_IDis the deployed contract address for the target network; it is recorded separately from the repo release tag.- Keep
CHANGELOG.mdup to date before tagging a release so GitHub Releases reflect the correct notes.
The release tag maps source, artifact, and deployment metadata together. When deploying a tagged release, ensure the contract WASM and the runtime environment are built from the same tag.
npm run verify:data-integrity # contract interface + generated types in sync| Workflow | Trigger | Purpose |
|---|---|---|
ci.yml |
push/PR to main |
Full suite: data-integrity, frontend, backend, contracts, security audit |
backend-deploy.yml |
CI success on main / manual |
Deploy backend to staging or production via Render |
mainnet-deploy.yml |
Manual only | Production mainnet deploy with pre-flight validation gate |
user-onboarding-ci.yml |
push/PR touching onboarding files | Validate register/login/profile routes end-to-end |
frontend-ci.yml |
push/PR to main/develop |
Frontend lint, test, build |
frontend-quality.yml |
PR | Frontend quality gate (lint, test, build) |
contract-testnet-deploy.yml |
push to main (contracts path) |
Deploy Soroban contract to testnet |
smoke-testnet.yml |
Manual | Post-deploy smoke test on testnet |
dependency-audit.yml |
Weekly / manual | npm audit for high-severity vulnerabilities |
mainnet-deploy.ymlenforces a strict gate sequence: secret validation → backend verification → readiness gate → deploy → smoke test → rollback instructions on failure.cancel-in-progress: falseensures an in-flight mainnet deploy is never cancelled by a concurrent run.backend-deploy.ymlvalidates production deploy configuration and required secrets before triggering Render.user-onboarding-ci.ymlvalidates the full register → login → profile lifecycle on every onboarding-related change.- CI pipelines use concurrency groups to cancel stale runs and keep mainline validation fast.
- Operational rollback guidance is documented in
docs/runbooks/mainnet-launch.md,docs/runbooks/user-onboarding.md, anddocs/runbooks/api-evolution.md.
The ApiClient (frontend/src/lib/api-client.ts) provides:
ApiError— typed error class withisNotFound,isUnauthorized,isServerError,isClientErrorhelpers and a machine-readablecodefield.- Smart retry — 4xx client errors are not retried (fail fast); 5xx and network errors retry up to 3 times with back-off.
- Enriched Sentry tags —
httpStatusanderrorCodeon every capturedApiError. - Response mapping —
mapProjectToCamelCasehandles both camelCase and snake_case backend responses for safe field-naming migrations.
See API Evolution Runbook for change procedures.
backend-deploy.ymlnow validates production deploy configuration, data integrity, and backend build/test before triggering Render.mainnet-deploy.ymlnow runs an explicit manual production release gate with deploy config validation, data integrity, backend lint, build, and tests.- A new CI/CD incident management runbook documents incident triage, smoke-check failure handling, rollback, and recovery.
- CI pipelines use concurrency groups to cancel stale runs and keep mainline validation fast.
- Operational rollback guidance is documented in
docs/runbooks/ci-data-integrity.md,docs/runbooks/incident-management.md, anddocs/deployment.md.
MIT