This guide provides comprehensive information for setting up and developing the One Universal Identity (OUI) system.
Important: This project requires Node.js 22.10.0 or later for Hardhat compatibility.
- Current requirement: Node.js ≥ 22.10.0
- Recommended: Use nvm (Node Version Manager) for easy version management
-
Install Node.js 22+:
# Using nvm (recommended) curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash nvm install 22 nvm use 22
-
Install dependencies:
npm install
-
Environment Setup:
cp .env.example .env # Edit .env with your configuration
# Build TypeScript to JavaScript
npm run build
# Compile smart contracts
npm run compile
# Development mode with auto-reload
npm run dev# Run all tests (Jest + Hardhat)
npm run test:all
# Run only Jest tests (backend/frontend)
npm run test:jest
# Run only Hardhat tests (smart contracts)
npm run test
# Run comprehensive test suite
npx ts-node test/test-runner.ts# Lint code
npm run lint
# Fix linting issues automatically
npm run lint:fix# Deploy smart contracts to local network
npm run deploy
# Start local Hardhat node
npm run node├── contracts/ # Smart contracts
├── src/
│ ├── backend/ # API routes and business logic
│ ├── frontend/ # React components
│ ├── utils/ # Utility functions
│ ├── types/ # TypeScript type definitions
│ └── server.ts # Main server file
├── test/ # Test files
├── scripts/ # Deployment scripts
└── docs/ # Documentation
Copy .env.example to .env and configure:
NODE_ENV: Environment (development/production)PORT: Server port (default: 3001)ETHEREUM_RPC_URL: Blockchain RPC URLPRIVATE_KEY: Deployer private key
- Database configuration
- JWT secrets
- API keys (Etherscan, etc.)
# Start all services
docker-compose up -d
# Start only development services
docker-compose --profile dev up -d
# View logs
docker-compose logs -f backend
# Stop all services
docker-compose down# Mount source code for live reloading
docker-compose -f docker-compose.dev.yml up# Start local Hardhat node
npm run node
# Deploy contracts to local network
npm run deploy
# Test contracts
npm run test- Configure network in
hardhat.config.ts - Set deployment parameters in
scripts/deploy.ts - Run deployment:
npm run deploy
- Routes:
src/backend/- Express.js route handlers - Utils:
src/utils/- Blockchain and database utilities - Types:
src/types/- TypeScript definitions
- Create route file in
src/backend/ - Add route to
src/server.ts - Add tests in
test/backend/
- Test individual functions and components
- Mock external dependencies
- Fast execution
- Test API endpoints
- Test database operations
- Test blockchain interactions
- Load testing with concurrent users
- Gas usage optimization
- Throughput measurement
- ESLint for TypeScript/JavaScript
- Prettier for code formatting
- Pre-commit hooks (recommended)
- Strict TypeScript configuration
- Interface definitions for all data structures
- Type checking in CI/CD
# Build production assets
npm run build
# Run database migrations
npm run migrate
# Start production server
npm start- Environment variables configured
- Database migrations run
- Contracts deployed and verified
- Tests passing
- Monitoring configured
-
Node.js Version Issues
# Check Node.js version node --version # Should be ≥ 22.10.0 nvm install 22 nvm use 22
-
Hardhat Compilation Issues
# Clear cache and reinstall rm -rf node_modules package-lock.json npm install npm run compile -
TypeScript Errors
# Check TypeScript compilation npx tsc --noEmit # Build project npm run build
-
Test Failures
# Run specific test file npx jest test/backend/identity-api.test.ts # Debug mode npx jest --verbose
- Follow TypeScript and ESLint guidelines
- Write tests for new features
- Update documentation
- Test on multiple Node.js versions
For issues and questions:
- Check existing documentation in
docs/ - Review test files for examples
- Check GitHub issues for similar problems