Contributing
Development Setup
Set up a local development environment for Burning Ash Protocol.
Development Setup
This guide covers setting up a local development environment for BAP.
Prerequisites
| Tool | Version | Purpose |
|---|---|---|
| Go | 1.21+ | Backend development |
| Node.js | 18+ | Frontend development |
| Docker | 24.0+ | Containerization |
| Git | 2.0+ | Version control |
| PostgreSQL (opt) | 17+ | Production testing |
Repository Setup
Clone
git clone https://github.com/baprotocol/bap.git
cd bapStructure
bap/
├── api/ # Go backend
│ ├── cmd/api/ # Entry point
│ ├── internal/ # Packages
│ └── migrations/ # DB migrations
├── web/ # Next.js frontend
│ ├── src/
│ └── ...
├── docs/ # Documentation
├── docker-compose.yml # Orchestration
└── .env.example # Env templateBackend Setup
Go Installation
# Install Go (Linux/macOS)
curl -sL https://go.dev/dl/go1.21.linux-amd64.tar.gz | sudo tar -C /usr/local -xz
# Verify
go versionDependencies
cd api
go mod downloadDatabase
SQLite (Default)
# Create data directory
mkdir -p data
# Database created automaticallyPostgreSQL (Optional)
# Using Docker
docker run -d \
--name bap-postgres \
-e POSTGRES_DB=bap \
-e POSTGRES_USER=bap \
-e POSTGRES_PASSWORD=dev \
-p 5432:5432 \
postgres:17-alpine
# Set environment
export DATABASE_URL=postgresql://bap:dev@localhost:5432/bap?sslmode=disableConfiguration
# Copy environment template
cp .env.example .env
# Edit .env
JWT_SECRET=development-secret-at-least-32-characters-long
MASTER_KEY=$(openssl rand -hex 32)
DB_TYPE=sqlite
DATABASE_PATH=./data/bap.dbRun Backend
cd api
go run ./cmd/apiAPI runs at http://localhost:8080
Frontend Setup
Node.js
# Using nvm (recommended)
nvm install 18
nvm use 18
# Verify
node --versionDependencies
cd web
npm installConfiguration
# Create .env.local
NEXT_PUBLIC_API_URL=http://localhost:8080/apiRun Frontend
# Development
npm run dev
# Production build
npm run build
npm startFrontend runs at http://localhost:3000
Docker Development
Quick Start
# Start all services
docker-compose up -d
# View logs
docker-compose logs -f
# Stop
docker-compose downHot Reload
Backend and frontend support hot reload:
- Backend:
go runwatches for changes - Frontend: Next.js dev server
Database Tools
Migration
# Run migrations
cd api
go run ./cmd/api migrate
# Create new migration
go run ./cmd/api migrate create add_new_tableCLI
# SQLite CLI
sqlite3 data/bap.db
# PostgreSQL CLI
docker exec -it bap-postgres-1 psql -U bap -d bapTesting
Backend Tests
cd api
go test ./...Frontend Tests
cd web
npm testIntegration Tests
# Using Docker
docker-compose -f docker-compose.test.yml upCode Quality
Linting
# Go
cd api
go fmt ./...
go vet ./...
# Frontend
cd web
npm run lintPre-commit Hooks
# Install pre-commit
pip install pre-commit
# Enable
cd api
pre-commit installCommon Issues
Port Already in Use
# Find process
lsof -i :8080
# Kill
kill <PID>Database Locked
# Remove SQLite journal
rm data/bap.db-journalModule Errors
# Clean and re-download
cd api
go clean -modcache
go mod downloadNext Steps
- Code Style — Coding conventions
- Pull Requests — Contribution workflow
- Security Reporting — Vulnerability reporting