New here? Start with the Developer Onboarding Guide — it takes you from clone to a running local environment and explains the architecture in detail.
- Development Environment Setup
- Branch Naming Conventions
- Commit Message Format
- Pull Request Process
- Definition of Done
- Review Process & SLAs
- Code Style Guidelines
- Project Structure
- Type Coverage
- Dependency License Compliance
- Security & Audits
- Getting Help
- Code of Conduct
📘 Comprehensive Local Setup Guide: For a consolidated guide covering Rust, Soroban CLI, database setup, and troubleshooting RPC errors, see
docs/local-dev-setup.md.
- Node.js ≥ 20 and npm
- Git
- A Stellar wallet (Freighter or Lobstr) on Mainnet for manual testing
# 1. Fork and clone
git clone https://github.com/your-username/stellar-spend.git
cd stellar-spend
# 2. Install dependencies
npm install
# 3. Configure environment
cp .env.example .env.local
# Fill in .env.local — see docs/environment-variables.md
# 4. Start the dev server
npm run dev
# Open http://localhost:3001npm run lint # ESLint
npm run format:check # Prettier
npx tsc --noEmit # TypeScript (zero errors required)
npm test # Unit + integration tests
npm run type:coverage # Type coverage ≥ 95% (see § Type Coverage below)
npm run license:check # Dependency-license compliance (see § Licenses below)If you modify files in the contracts/ directory, you must:
- Fix Clippy warnings – ensure no linting issues:
cd contracts
cargo clippy --workspace -- -D warnings- Audit Rust dependencies for security vulnerabilities:
# Option 1: Use the provided audit script
./scripts/audit-contracts.sh
# Option 2: Run cargo-audit directly on a specific contract
cd contracts/fee-manager
cargo audit --deny warningsPrerequisites for contract development:
- Rust toolchain (install from https://rustup.rs/)
cargo-clippy(included with rustup)cargo-auditfor vulnerability scanning (install withcargo install cargo-audit)
Set up local pre-commit hooks (optional but recommended):
The project supports two pre-commit hook systems. Either one will lint and format the files you stage before each commit, so violations are caught locally instead of in review.
Option A — pre-commit framework (Python):
pip install pre-commit
pre-commit installOption B — Husky (native Git hooks):
npm installnpm install runs the prepare script, which installs Husky and registers the hooks automatically. You do not need to run npx husky install or add the hook by hand.
The Husky pre-commit hook runs:
- gitleaks — blocks the commit if secrets are detected in the working tree.
- lint-staged — runs ESLint (
--fix) and Prettier (--write) on staged files only, then re-stages the fixes.
Staged-file rules are declared under "lint-staged" in package.json:
*.{js,jsx,ts,tsx,mjs,cjs}—eslint --fix, thenprettier --write*.{json,md,css,scss,yml,yaml,html}—prettier --write
Because lint-staged only touches staged files, commits stay fast even in large working trees. Unstaged changes are never modified.
What the hook does not run:
Type-checking (npm run type:check) and the full snapshot validation are not part of the pre-commit hook, since they operate on the whole project rather than on staged files; CI enforces them on every push.
Bypassing pre-commit hooks:
To skip hooks for a specific commit (e.g., emergency fix, WIP commit), use the --no-verify flag:
git commit --no-verify -m "WIP: temporary change"Warning:
--no-verifybypasses all pre-commit checks. CI will still enforce lint, type-check, and format on every push. Use this flag sparingly and never for code that will be merged without review.
Common workflows before pushing contract changes:
- Format code:
cargo fmt --workspace(auto-fix) — style is enforced by CI - Check formatting:
cargo fmt --workspace --check(read-only, matches CI check) - Run clippy:
cargo clippy --workspace -- -D warnings - Audit for vulnerabilities:
./scripts/audit-contracts.sh - Check for RUSTSEC advisories:
cargo audit --json(for CI/CD integration) - Update vulnerable dependencies:
cargo update
All Soroban contract code is formatted with rustfmt using the rules in
contracts/rustfmt.toml. Key settings:
| Rule | Value |
|---|---|
| Edition | 2021 |
| Max line width | 100 |
| Indent | 4 spaces (no hard tabs) |
| Import grouping | StdExternalCrate |
| Trailing commas | Vertical (multi-line) |
| Newline style | Unix |
CI runs cargo fmt --workspace --check on every push that touches contracts/.
A formatting diff will fail the build. Run cargo fmt --workspace locally
before pushing to keep the check green.
We use Storybook for isolated component development:
npm run storybookWhen creating or updating a UI component, add a .stories.tsx file covering:
- Different variants and states (loading, disabled, error)
- Edge cases for input data
- Accessibility checks via the integrated
axeaddon
After deleting or renaming a component, run the orphan checker to confirm no story files are left pointing to a missing component:
npm run storybook:check-orphansIf orphaned stories are found, remove them automatically with:
npm run storybook:fix-orphansRun npm run storybook:check-orphans before opening a PR whenever you remove or rename a component. The check exits 0 when no orphans are found and exits 1 otherwise, making it suitable for CI.
Use descriptive branch names with these prefixes:
| Prefix | Purpose |
|---|---|
feat/ |
New features |
fix/ |
Bug fixes |
docs/ |
Documentation updates |
style/ |
Formatting / whitespace only |
refactor/ |
Refactoring without behavior change |
test/ |
Adding or updating tests |
chore/ |
Maintenance, dependency updates |
ci/ |
CI/CD changes |
contract/ |
Soroban smart contract changes |
Examples:
feat/add-kes-corridorfix/paycrest-webhook-hmacdocs/update-adr-escrowtest/bridge-adapter-unit-tests
Include the issue number when relevant: feat/issue-42-add-kes-corridor.
We use Conventional Commits:
<type>[optional scope]: <description>
[optional body]
[optional footer(s)]
| Type | When to use |
|---|---|
feat |
New feature |
fix |
Bug fix |
docs |
Documentation only |
style |
Formatting, whitespace |
refactor |
Code restructuring, no behavior change |
test |
Adding or updating tests |
chore |
Maintenance, dependency bumps |
ci |
CI/CD configuration |
perf |
Performance improvement |
contract |
Soroban contract change |
Use a scope to identify the affected subsystem:
feat(bridge): …, fix(paycrest): …, test(wallet): …, docs(adr): …
feat(corridor): add KES fiat corridor via Paycrest
fix(webhook): validate HMAC signature before processing payload
docs(adr): add ADR-007 for feature flag approach
test(quote): add boundary tests for fee calculation
chore(deps): bump @stellar/stellar-sdk from 14.5.0 to 14.6.0
Add BREAKING CHANGE: in the footer:
feat(api)!: rename /api/offramp/rate to /api/offramp/fx-rate
BREAKING CHANGE: The old endpoint path is removed. Update all clients.
-
Make sure your branch is up to date with
main:git fetch origin git rebase origin/main
-
Run the full check suite:
npm run lint && npm run format:check && npx tsc --noEmit && npm test
-
If you changed UI flows, run E2E tests:
npm run test:e2e
- Use the PR template (
.github/PULL_REQUEST_TEMPLATE.md) — fill every section - Title must follow the commit message format:
feat(scope): short description - Reference the issue:
Closes #<n>in the summary - Add screenshots or recordings for any UI changes
- Keep PRs focused — one concern per PR; split large changes
Rebase (do not merge) to stay current with main. Force-push to your branch is acceptable during review.
PRs are merged by a maintainer using squash and merge once all checks pass and approval is received. Do not merge your own PRs.
A contribution is done when all of the following are true:
- Implements the acceptance criteria from the linked issue
- No regressions introduced (all existing tests still pass)
- No TypeScript errors:
npx tsc --noEmitexits 0 - No lint errors:
npm run lintexits 0 - No Prettier violations:
npm run format:checkexits 0 - No
anytypes without a comment explaining why - No secrets, PII, or credentials in the diff
- New logic has unit tests covering the happy path and primary error paths
- Changed API routes have integration tests
- UI changes have component tests (render states + key interactions)
- Mutation score for touched modules is not degraded (target ≥ 70%)
- All CI test jobs pass (lint, type-check, unit, build, E2E)
- New interactive elements have accessible names
- Focus management is correct (modals trap focus, focus restores on close)
- Keyboard navigation works without a mouse
- Color contrast ≥ 4.5:1 for text (WCAG AA)
-
docs/updated if architecture, API behavior, or configuration changed - If the architecture changed (new service, new external dependency, data-flow change): update
docs/diagrams/source files and run the diagram check (bash scripts/check-diagrams.sh) - New environment variables are added to
.env.examplewith descriptions - New ADRs created for significant architectural decisions (see
docs/adr/, e.g. ADR-013) - In-code comments are accurate and not stale
- No
NEXT_PUBLIC_prefix on server-side secrets - All user input is validated and sanitized
- New dependencies are from well-known, actively maintained packages
- New API endpoints enforce appropriate rate limits and authentication
- Maintainers (
@Lex-Studios/maintainers) review all PRs - Domain reviewers: tag the relevant area owner for complex changes (see
CODEOWNERSwhen present)
| PR size | First review | Follow-up response |
|---|---|---|
| Small (< 100 lines changed) | 2 business days | 1 business day |
| Medium (100–500 lines) | 3 business days | 2 business days |
| Large (> 500 lines) | 5 business days | 2 business days |
| Security fix / hotfix | Same day (tag urgent) |
4 hours |
SLAs are for the first substantive review. Trivial approvals (docs typo) may be faster.
- Correctness — Does it solve the stated problem? Are edge cases handled?
- Tests — Are the tests meaningful? Do they cover failure paths?
- Security — Are there any injection, auth bypass, or secret-exposure risks?
- Performance — Any N+1 queries, unnecessary re-renders, or bundle bloat?
- Accessibility — Are ARIA labels and keyboard flows correct?
- Definition of done — All checklist items satisfied?
- Address all reviewer comments or explain why you disagree
- Mark conversations as resolved only after the fix is pushed
- Request a re-review once all comments are addressed
- Maintainers resolve conversations they opened
- 1 approval from a maintainer is required to merge
- Security-sensitive changes (auth, encryption, smart contracts) require 2 approvals
- Use TypeScript for all new code
- Define explicit types and interfaces; avoid
any - Prefer
unknownoveranywhen the type is genuinely unknown - Use branded types (
UserId,TransactionId) for domain IDs (seesrc/lib/types/branded-types.ts)
- Functional components with hooks only
- Follow the state management architecture defined in ADR-013 (State Management Architecture): use React Context strictly for low-frequency global UI state (
src/contexts/), custom hooks for domain workflows (src/hooks/), and local state for component-level UI interactions - Use
'use client'directive only where client-side state/effects are needed - Implement error boundaries around complex component trees
- Always provide loading and error states for async operations
- Use
src/lib/env.tsfor all environment access - Never import server-side variables in
'use client'components - Add new variables to
.env.examplewith a description comment
- Never inline a magic number or repeated string literal. Define it as a named constant instead.
- Application-wide constants (timeouts, polling intervals, cache TTLs, Stellar
parameters) live in
src/lib/constants.ts, which re-exports everything fromsrc/lib/config/. Import from there:import { BRIDGE_POLLING_INTERVAL_MS, CACHE_CURRENCY_TTL_MS } from '@/lib/constants';
- Fee percentages and basis-point values live in
@stellar-spend/shared(packages/shared/src/fee-constants.ts). - Per-route rate-limit configs live in
src/lib/rateLimiter.ts(RATE_LIMIT_REGISTRY). - Currency, stablecoin, and corridor configs live in their respective files
(
currencies.ts,stablecoins.ts,corridor-config.ts). - If you add a new global constant, add it to
src/lib/constants.tsand add a corresponding test insrc/lib/constants.test.ts.
All error handling must follow these rules (enforced by ESLint — violations fail CI):
-
No floating promises. Every
asynccall must beawaited or explicitly discarded withvoid:// ❌ Floating — rejection is silently lost fetchData(); // ✅ Awaited await fetchData(); // ✅ Intentionally fire-and-forget void fetchData();
Rule:
@typescript-eslint/no-floating-promises: error -
No empty catch blocks. At minimum, log the error or rethrow it. If you genuinely want to ignore an error, prefix the parameter with
_and add a comment:// ❌ Swallowed — no trace of what went wrong try { ... } catch (e) {} // ✅ Logged try { ... } catch (e) { logger.warn('context', { error: e }); } // ✅ Intentionally ignored (use sparingly) try { ... } catch (_e) { // Safe to ignore: optional cache warm-up — the main path continues without it }
Rule:
no-empty: ['error', { allowEmptyCatch: false }] -
Use the shared
ErrorHandlerfor all API route errors. Seedocs/api/ERROR_RESPONSES.mdfor the full reference.
- Prettier is enforced; run
npm run formatto auto-fix - Single quotes for strings
- 100-character line limit
- Trailing commas in multi-line structures
- Components:
PascalCase - Functions and variables:
camelCase - Constants:
SCREAMING_SNAKE_CASE - Files:
kebab-case.ts/PascalCase.tsxfor components
src/
├── app/ # Next.js App Router pages and API routes
│ ├── api/ # REST API route handlers
│ └── history/ # /history page
├── components/ # Reusable React components
│ ├── design-system/ # Base design tokens (Button, Card, Badge, Alert)
│ ├── skeletons/ # Loading skeleton variants
│ └── ui/ # Primitive form components
├── hooks/ # Custom React hooks
├── lib/ # Core business logic and utilities
│ ├── i18n/ # Internationalisation
│ ├── offramp/ # Offramp-specific logic and adapters
│ ├── security/ # Encryption, sanitization, headers
│ ├── stellar/ # Stellar / Soroban wallet adapters
│ └── wallets/ # Multi-wallet manager
├── test/ # Unit and integration test files
│ ├── integration/ # Route-level integration tests
│ └── mocks/ # MSW handlers and shared test fixtures
└── types/ # Global TypeScript type definitions
e2e/ # Playwright end-to-end tests
contracts/ # Soroban smart contracts (Rust)
├── escrow/
├── fee-manager/
└── treasury/
docs/
├── adr/ # Architecture Decision Records
└── *.md # Reference documentation
.github/
├── ISSUE_TEMPLATE/ # Bug, feature, and contract issue templates
└── PULL_REQUEST_TEMPLATE.md
TypeScript type coverage is measured with type-coverage and must stay at or above 95%.
npm run type:coverage # check (matches CI)
npm run type:coverage:detail # show all uncovered identifiersConfiguration lives in .type-coverage at the project root.
| Score | Meaning |
|---|---|
| ≥ 95% | ✅ Green — CI passes |
| < 95% | ❌ Red — CI fails; you must improve coverage before merging |
If you genuinely cannot type something (e.g., a third-party response with no TS definitions), add a comment directly above the line:
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- no types available for XYZ SDK response
const result = sdk.call() as any;The comment must name why any is unavoidable. Unexplained any usages
will be flagged in code review.
Stellar-Spend uses a two-tier dependency versioning strategy to balance security with automation.
The following packages must use exact version strings (no ^ or ~) in package.json:
| Package | Reason |
|---|---|
react |
Major/minor bumps require coordinated changes; silent upgrades cause hydration mismatches |
react-dom |
Must always match react exactly |
typescript |
Compiler version is a build contract — drift between developer and CI compiler versions causes false-positive type errors |
If you need to update a hard-pinned dependency, open a dedicated PR with a changelog entry explaining the reason and test coverage for any API changes.
All other dependencies may use caret ranges (^). Renovate automatically opens pull requests for each version bump. The PR must pass CI before merging.
The Renovate configuration lives at .github/renovate.json. If you add a new dependency category that needs special handling (e.g. pinned major version), add a packageRules entry there.
# List all range-versioned dependencies
node -e "
const p = require('./package.json');
const all = {...p.dependencies, ...p.devDependencies};
Object.entries(all)
.filter(([,v]) => v.startsWith('^') || v.startsWith('~'))
.forEach(([k,v]) => console.log(k, v));
"All npm dependencies must carry a license from the approved list below. Run the compliance check before opening a PR:
npm run license:check # exits 0 if all clear, 1 on violation
npm run license:report # same but also prints every approved package| License | Notes |
|---|---|
| MIT, MIT-0 | Permissive |
| ISC | Permissive |
| Apache-2.0 | Permissive |
| BSD-2-Clause, BSD-3-Clause | Permissive |
| CC0-1.0, 0BSD | Effectively public domain |
| BlueOak-1.0.0 | Permissive |
| MPL-2.0 | Weak copyleft — changes to MPL files must be open-sourced |
| Unlicense, Public Domain | Permissive |
Several transitive dependencies (via @allbridge/bridge-core-sdk) carry
LGPL-3.0 or GPL-3.0 licenses. These are documented with a written rationale in
scripts/check-licenses.js under ACCEPTED_EXCEPTIONS. The key point: these
packages are used as libraries with no source modification — the LGPL
dynamic-linking exemption applies and the MIT application code is not infected.
Review these exceptions every time the affected packages are upgraded.
- Check whether a compatible alternative exists — prefer it.
- If unavoidable, add an entry to
ACCEPTED_EXCEPTIONSinscripts/check-licenses.jswith:- The exact
package@versionkey - A one-sentence rationale (why it is safe, what the linking model is)
- The exact
- Re-run
npm run license:checkto confirm the check still passes. - Note the exception in your PR description.
- Search existing issues first
- Open a new issue using the appropriate template
- Join community discussions
- Review the docs/ directory for architecture and API references
This project follows a Code of Conduct. By participating you agree to its terms.
Thank you for contributing to Stellar-Spend! 🚀