Thanks for your interest in contributing! This guide covers everything you need to get up and running.
- Getting Started
- Project Structure
- Development Setup
- Running Tests
- Coding Standards
- Security Considerations
- Troubleshooting
- Submitting a Pull Request
-
Fork the repository and clone your fork:
git clone https://github.com/YOUR_USERNAME/Stellar-Solar-Grid.git cd Stellar-Solar-Grid -
Add the upstream remote:
git remote add upstream https://github.com/ORIGINAL_OWNER/Stellar-Solar-Grid.git
-
Create a feature branch off
mainusing the following branch naming conventions:feat/for new features (e.g.feat/add-payment-flow)fix/for bug fixes (e.g.fix/meter-validation)refactor/for code restructuring (e.g.refactor/api-routes)docs/for documentation updates (e.g.docs/api-guide)infra/for build scripts, Docker, or CI/CD updates (e.g.infra/docker-setup)
git checkout -b feat/your-feature-name
Stellar-Solar-Grid/
├── contracts/ # Soroban smart contracts (Rust)
├── frontend/ # React + TypeScript dashboards (Vite)
└── backend/ # Node.js API + IoT MQTT bridge (Express + tsx)
Make sure you have the following installed on your local machine:
- Node.js: version 20
- Rust: stable version (via rustup)
- wasm32-unknown-unknown target: installed via
rustup target add wasm32-unknown-unknown - Stellar CLI: latest version (for deploying and invoking contracts)
- Docker & Docker Compose: for running containerized infrastructure (MQTT, checks, etc.)
We use make for common development workflows. You can run these commands from the project root or the contracts directory:
- Build the contract:
make build
- Run all contract tests:
make test - Deploy the contract to testnet:
make deploy
- Navigate to the
frontenddirectory:cd frontend - Copy the example environment file and configure it:
cp .env.example .env.local
- Install dependencies and start the Vite dev server:
npm install npm run dev
- Navigate to the
backenddirectory:cd backend - Copy the example environment file and configure it:
cp .env.example .env
- Install dependencies and start the Express server:
npm install npm run dev
You can spin up the full stack using docker compose:
docker compose up --buildRun the complete test suite:
cd contracts
cargo testRun specific test modules:
cargo test test_register_and_payment
cargo test --test integration_testscd frontend
npm run test # Run Jest tests
npm run test:watch # Run tests in watch mode
npm run test:coverage # Generate coverage reportcd backend
npm run test # Run test suite
npm run test:watch # Run tests in watch mode-
Start all services:
docker-compose up -d
-
Deploy contract to testnet:
cd contracts stellar contract deploy \ --wasm target/wasm32-unknown-unknown/release/solar_grid.wasm \ --network testnet -
Update environment files with deployed contract ID
-
Test the complete flow through the frontend dashboard
- Use TypeScript strict mode — no
anyunless absolutely necessary. - Prefer
constoverlet; avoidvar. - Name files in
kebab-case, components inPascalCase. - Keep functions small and single-purpose.
- Run
tsc --noEmitbefore committing to catch type errors.
- Follow standard Rust formatting:
cargo fmtbefore every commit. - Run
cargo clippy -- -D warningsand fix all warnings. - Document public functions with
///doc comments. - Avoid
unwrap()in contract code — handle errors explicitly.
-
No commented-out dead code in PRs.
-
Keep commits atomic and write meaningful commit messages using the Conventional Commits format:
feat(...): A new feature (e.g.,feat(infra): add docker-compose validation)fix(...): A bug fix (e.g.,fix(api): handle connection timeout)docs(...): Documentation changesstyle(...): Formatting, semi-colons, etc.refactor(...): Restructuring code without changing behaviortest(...): Adding or modifying testsinfra(...)/chore(...): Infrastructure or dependency updates
Example commit messages:
feat: add weekly payment plan support fix: correct meter access check logic docs: update contract deployment steps
- Never commit
.envfiles or expose secret keys - Use
.env.exampleas a template with placeholder values - Rotate keys regularly in production environments
- Use different keys for testnet and mainnet
- All contract functions validate inputs and handle errors explicitly
- Payment amounts are checked for overflow/underflow
- Access control is enforced through allowlists and ownership checks
- Test edge cases thoroughly, especially around balance calculations
- All endpoints validate request schemas using Zod
- Rate limiting is implemented for payment endpoints
- Webhook signatures are verified before processing
- CORS is configured appropriately for the frontend domain
Contract deployment fails:
- Ensure you have testnet XLM in your account
- Check that the WASM file was built successfully
- Verify network configuration in Stellar CLI
Backend fails to start:
- Check that all required environment variables are set
- Ensure MQTT broker is running (via Docker Compose)
- Verify Stellar RPC endpoint is accessible
Frontend build errors:
- Clear node_modules and reinstall:
rm -rf node_modules package-lock.json && npm install - Check that environment variables match the deployed contract
- Ensure Freighter wallet is installed and connected to testnet
Tests failing:
- For contract tests: ensure
wasm32-unknown-unknowntarget is installed - For frontend tests: check that test environment variables are set
- For integration tests: ensure all services are running
- Check existing Issues for similar problems
- Open a Discussion for questions
- Review the API documentation for endpoint details
-
Sync with upstream before opening a PR:
git fetch upstream git rebase upstream/main
-
Make sure the project builds cleanly:
# Contracts cargo build --target wasm32-unknown-unknown --release # Frontend cd frontend && npm run build # Backend cd backend && npm run build
-
Push your branch and open a PR against
main. -
Fill out the pull request template completely.
-
A maintainer will review your PR. Please respond to feedback promptly and keep the branch up to date.
- Build passes (contracts, frontend, backend)
- Lint passes successfully without warnings
- Tests are added or updated for new changes
- README is updated if any new environment variables or setup steps are introduced
For questions, open a Discussion or drop a comment on the relevant issue.