Development Setup
Complete guide for setting up the NorChain development environment.
Prerequisites
- Node.js >= 18.0.0
- npm >= 9.0.0
- PostgreSQL >= 14 (or Supabase account)
- Redis (optional, for caching)
- Git
Initial Setup
1. Clone Repository
git clone https://github.com/nor-chain/norchain-monorepo
cd norchain-monorepo2. Install Dependencies
npm installThis installs dependencies for all workspace packages.
3. Environment Configuration
Explorer API
Create apps/explorer-api/.env:
PORT=3000
NODE_ENV=development
DATABASE_URL=postgresql://user:password@localhost:5432/norchain
JWT_SECRET=your-secret-key
RPC_URL=https://rpc.norchain.org
CHAIN_ID=65001Explorer App
Create apps/explorer/.env.local:
NEXT_PUBLIC_API_URL=http://localhost:3000/api/v1
NEXT_PUBLIC_RPC_URL=https://rpc.norchain.org
NEXT_PUBLIC_CHAIN_ID=65001Landing Page
Create apps/landing/.env.local:
NEXT_PUBLIC_API_URL=http://localhost:3000/api/v1NEX Exchange
Create apps/nex-exchange/.env.local:
NEXT_PUBLIC_EXPLORER_API_URL=http://localhost:3000
NEXT_PUBLIC_RPC_URL=https://rpc.norchain.org
NEXT_PUBLIC_CHAIN_ID=65001Database Setup
PostgreSQL
# Create database
createdb norchain
# Run migrations (if available)
cd apps/explorer-api
npm run migration:runSupabase
- Create a new Supabase project
- Copy the connection string to
DATABASE_URL - Run migrations if available
Running Services
Start All Services
npm run devThis starts all services in parallel.
Start Individual Services
# Explorer API
npm run explorer:dev
# Explorer App
cd apps/explorer && npm run dev
# Landing Page
cd apps/landing && npm run dev
# NEX Exchange
npm run nex:dev
# Documentation
npm run docs:devService Ports
| Service | Port | URL |
|---|---|---|
| Explorer API | 3000 | http://localhost:3000 |
| Explorer App | 3002 | http://localhost:3002 |
| Landing Page | 3010 | http://localhost:3010 |
| NEX Exchange | 3001 | http://localhost:3001 |
| Documentation | 3011 | http://localhost:3011 |
Development Workflow
Making Changes
-
Create a feature branch
git checkout -b feature/your-feature -
Make your changes
- Write code
- Add tests
- Update documentation
-
Test locally
npm run lint npm run build -
Commit changes
git add . git commit -m "feat: your feature description" -
Push and create PR
git push origin feature/your-feature
Code Style
- Use TypeScript strict mode
- Follow ESLint rules
- Use Prettier for formatting
- Write tests for new features
Testing
# Run all tests
npm run test
# Run tests for specific app
cd apps/explorer-api && npm run testTroubleshooting
Port Already in Use
# Find process using port
lsof -i :3000
# Kill process
kill -9 <PID>Database Connection Issues
- Check PostgreSQL is running
- Verify connection string
- Check firewall settings
API Connection Issues
- Verify Explorer API is running
- Check environment variables
- Verify CORS settings
IDE Setup
VS Code
Recommended extensions:
- ESLint
- Prettier
- TypeScript
- Tailwind CSS IntelliSense
Settings
Create .vscode/settings.json:
{
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode",
"typescript.tsdk": "node_modules/typescript/lib"
}Next Steps
- Read Architecture guide
- Explore API Documentation
- Check Environment Variables