Complete guide for setting up Brain-Storm locally from scratch.
| Tool | Version | Install |
|---|---|---|
| Node.js | v18+ | nodejs.org |
| npm | v9+ | Bundled with Node.js |
| Rust | v1.75+ | curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh |
| Stellar CLI | v21.5.0 | See below |
| PostgreSQL | v12+ | postgresql.org or Docker |
| Redis | v6+ | redis.io or Docker |
| Docker | Optional | docker.com |
curl -sSL https://github.com/stellar/stellar-cli/releases/download/v21.5.0/stellar-cli-21.5.0-x86_64-unknown-linux-gnu.tar.gz | tar xz
sudo mv stellar /usr/local/bin/
stellar --version # should print v21.5.0git clone https://github.com/your-org/brain-storm.git
cd brain-storm
cp .env.example .envEdit .env and fill in the required values:
| Variable | Example Value | Notes |
|---|---|---|
DATABASE_HOST |
localhost |
Use postgres inside Docker |
DATABASE_PORT |
5432 |
|
DATABASE_NAME |
brain-storm |
|
DATABASE_USERNAME |
postgres |
|
DATABASE_PASSWORD |
postgres |
|
REDIS_HOST |
localhost |
Use redis inside Docker |
REDIS_PORT |
6379 |
|
JWT_SECRET |
<random-32-char-string> |
openssl rand -hex 32 |
STELLAR_NETWORK |
testnet |
|
STELLAR_SECRET_KEY |
S... |
See Stellar testnet section below |
NEXT_PUBLIC_API_URL |
http://localhost:3000 |
docker compose up -d postgres redisPostgreSQL will be available at localhost:5432 and Redis at localhost:6379.
# PostgreSQL
createdb brain-storm
psql -c "CREATE USER postgres WITH PASSWORD 'postgres';"
psql -c "GRANT ALL PRIVILEGES ON DATABASE \"brain-storm\" TO postgres;"
# Redis — start the server
redis-server --daemonize yes-
Generate a new keypair:
stellar keys generate --network testnet dev-account stellar keys address dev-account # prints your public key stellar keys show dev-account # prints your secret key (starts with S)
-
Fund the account via Friendbot:
curl "https://friendbot.stellar.org?addr=$(stellar keys address dev-account)"Or use Stellar Laboratory.
-
Copy the secret key into
STELLAR_SECRET_KEYin your.env.
Testnet accounts are reset periodically. To re-fund the account configured in .env:
./scripts/fund-testnet.shThe script reads STELLAR_SECRET_KEY from .env, derives the public key, and calls Friendbot automatically.
When STELLAR_NETWORK=testnet, the backend exposes a funding endpoint:
POST /v1/stellar/fund-testnet
Content-Type: application/json
{ "publicKey": "G..." }
This is disabled (returns 400) when STELLAR_NETWORK=mainnet.
On the profile page, a Fund Testnet Account button appears in the wallet section whenever NEXT_PUBLIC_STELLAR_NETWORK=testnet. Clicking it calls the endpoint above for the linked wallet address.
# Install all Node.js dependencies (root + workspaces)
npm install
# Add Wasm compilation target
rustup target add wasm32-unknown-unknown
# Build all Soroban contracts
./scripts/build.sh./scripts/deploy.sh testnet analytics
./scripts/deploy.sh testnet token
./scripts/deploy.sh testnet certificateContract addresses are saved to scripts/deployed-contracts.json. Copy the relevant addresses into your .env.
# Terminal 1 — Backend (http://localhost:3000)
npm run dev:backend
# Terminal 2 — Frontend (http://localhost:3001)
npm run dev:frontendSwagger docs: http://localhost:3000/api/docs
make setup # install deps + build contracts
make dev # start backend & frontend concurrently
make test # run all tests
make build # production build
make lint # lint all workspaces
make clean # remove build artifactsFor a fully automated first-time setup:
./scripts/setup.shThis script checks prerequisites, copies .env, installs dependencies, builds contracts, and starts Docker services.
- Check PostgreSQL is running:
docker psorpg_isready - Verify
DATABASE_HOST,DATABASE_PORT,DATABASE_USERNAME,DATABASE_PASSWORDin.env - If using Docker:
docker compose up -d postgres
- Check Redis is running:
docker psorredis-cli ping - If using Docker:
docker compose up -d redis - Verify
REDIS_HOSTandREDIS_PORTin.env
- Your testnet account needs funding. Run:
curl "https://friendbot.stellar.org?addr=<YOUR_PUBLIC_KEY>"
- Run:
rustup target add wasm32-unknown-unknown
- Find and kill the process:
lsof -ti:3000 | xargs kill -9 - Or change
PORTin.env
- Run
npm installfrom the repo root first. - Or use:
npx nest start --watchinsideapps/backend
- Ensure
.envexists and containsJWT_SECRET. - Generate one:
openssl rand -hex 32
- Re-fund your testnet account via Friendbot (see step 3 above).
- Run
cargo updateto refreshCargo.lock, then re-run.