From 23383af31548f62c8aeafdeed801d78b231fff8a Mon Sep 17 00:00:00 2001 From: rolodexter Date: Wed, 6 Nov 2024 03:39:32 +0800 Subject: [PATCH] Update DevelopmentEnvironment.md --- docs/DevelopmentEnvironment.md | 356 ++++++++++++++++++--------------- 1 file changed, 193 insertions(+), 163 deletions(-) diff --git a/docs/DevelopmentEnvironment.md b/docs/DevelopmentEnvironment.md index 6ca3e62..cc484de 100644 --- a/docs/DevelopmentEnvironment.md +++ b/docs/DevelopmentEnvironment.md @@ -1,117 +1,157 @@ -# LN1 Development Environment -Complete development environment setup for the DataHive LN1 Node, covering infrastructure, protocol, and AI components. For detailed system architecture, see [system-overview.md](./docs/architecture/system-overview.md). +# DataHive LN1 Node Development Environment + +This guide provides a complete development environment setup for the DataHive LN1 Node, covering infrastructure, protocol, AI components, and blockchain requirements. It includes details on system requirements, environment setup, dependency management, testing, and troubleshooting. For a deeper understanding of the system architecture, refer to the [ARCHITECTURE.md](./docs/architecture/system-overview.md) file. + +## Table of Contents + +1. [System Requirements](#system-requirements) +2. [Core Development Stack](#core-development-stack) +3. [Environment Setup](#environment-setup) +4. [Running the Development Environment](#running-the-development-environment) +5. [Testing and Quality Assurance](#testing-and-quality-assurance) +6. [Troubleshooting and Optimization](#troubleshooting-and-optimization) +7. [Contributing](#contributing) +8. [Additional Resources](#additional-resources) +9. [Support Channels](#support-channels) ## System Requirements ### Hardware Specifications -- CPU: 8+ cores recommended -- RAM: 32GB minimum (64GB recommended) -- Storage: 500GB NVMe SSD minimum -- GPU: NVIDIA GPU with 8GB+ VRAM for AI training (optional) -- Network: High-speed internet connection +- **CPU**: 8+ cores (recommended) +- **RAM**: 32GB minimum, 64GB recommended +- **Storage**: 500GB NVMe SSD minimum +- **GPU**: NVIDIA GPU with 8GB+ VRAM for AI model training (optional) +- **Network**: High-speed internet connection -### Operating System -- [Ubuntu 22.04 LTS](https://ubuntu.com/download/desktop) (primary recommended) -- [macOS 12+ Monterey or later](https://support.apple.com/macos) (supported) -- [Windows 11 with WSL2](https://learn.microsoft.com/en-us/windows/wsl/install) (supported) +### Supported Operating Systems +- **Ubuntu 22.04 LTS** (primary recommended) - [Installation Guide](https://ubuntu.com/tutorials/install-ubuntu-desktop) +- **macOS 12+ Monterey or later** (supported) - [Support](https://support.apple.com/macos) +- **Windows 11 with WSL2** (supported) - [WSL2 Setup Guide](https://learn.microsoft.com/en-us/windows/wsl/install) ## Core Development Stack -### Language Runtimes -```bash -# Python Environment -python3.11 -pip -virtualenv - -# Node.js Environment -nvm install 18 -npm install -g pnpm - -# Rust Toolchain -curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -rustup default stable -rustup component add rustfmt clippy - -# Go Installation -wget https://go.dev/dl/go1.21.1.linux-amd64.tar.gz -sudo tar -C /usr/local -xzf go1.21.1.linux-amd64.tar.gz -``` - -For detailed language-specific setup, see [LANGUAGES.md](./docs/architecture/setup/LANGUAGES.md) +### Language Runtimes and Package Managers + +1. **Python Environment**: + ```bash + python3.11 + pip + virtualenv + ``` + +2. **Node.js Environment**: + ```bash + nvm install 18 + npm install -g pnpm + ``` + +3. **Rust Toolchain**: + ```bash + curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh + rustup default stable + rustup component add rustfmt clippy + ``` + +4. **Go Installation**: + ```bash + wget https://go.dev/dl/go1.21.1.linux-amd64.tar.gz + sudo tar -C /usr/local -xzf go1.21.1.linux-amd64.tar.gz + ``` ### Blockchain Development Tools -```bash -# Layer 2 Development -npm install -g @eth-optimism/sdk -npm install -g @arbitrum/sdk -npm install -g @0glabs/0g-ts-sdk - -# Smart Contract Development -npm install -g hardhat -npm install -g truffle -cargo install foundry-rs - -# Testing Frameworks -npm install -g ganache -``` -For blockchain configuration details, see [BLOCKCHAIN.md](./docs/architecture/setup/BLOCKCHAIN.md) +- **Layer 2 Development**: + ```bash + npm install -g @eth-optimism/sdk @arbitrum/sdk @0glabs/0g-ts-sdk + ``` + +- **Smart Contract Development**: + ```bash + npm install -g hardhat truffle + cargo install foundry-rs + ``` + +- **Testing Frameworks**: + ```bash + npm install -g ganache + ``` + +### AI & Machine Learning Libraries -### AI & Machine Learning Stack ```bash -# Core ML Libraries -pip install torch torchvision torchaudio -pip install tensorflow -pip install transformers -pip install sentence-transformers - -# Legal AI Specific -pip install spacy +pip install torch torchvision torchaudio tensorflow transformers sentence-transformers spacy lexnlp python -m spacy download en_legal_ner -pip install lexnlp ``` -For AI model setup details, see [AI_SETUP.md](./docs/architecture/setup/AI_SETUP.md) +### Database & Storage Tools -### Storage & Database -```bash -# Core Database -sudo apt install postgresql postgresql-contrib -sudo apt install redis-server +- **PostgreSQL**: + ```bash + sudo apt install postgresql postgresql-contrib + ``` -# IPFS & Storage -wget https://dist.ipfs.tech/kubo/v0.20.0/kubo_v0.20.0_linux-amd64.tar.gz -tar -xvzf kubo_v0.20.0_linux-amd64.tar.gz +- **Redis**: + ```bash + sudo apt install redis-server + ``` -# 0G Storage Integration -npm install @0glabs/0g-storage-client -``` +- **IPFS**: + ```bash + wget https://dist.ipfs.tech/kubo/v0.20.0/kubo_v0.20.0_linux-amd64.tar.gz + tar -xvzf kubo_v0.20.0_linux-amd64.tar.gz + ``` + +--- -## Development Environment Setup +## Environment Setup + +### 1. Clone the Repository -### 1. Repository Setup ```bash git clone https://github.com/datahiv3/Legalese-Node-LN1.git cd Legalese-Node-LN1 ``` -### 2. Environment Configuration -```bash -# Create virtual environment -python -m venv venv -source venv/bin/activate +### 2. Configure Environment Variables -# Install dependencies -pip install -r requirements.txt -pip install -r requirements-dev.txt +1. Copy the `.env.example` file to `.env`: + ```bash + cp .env.example .env + ``` -# Install pre-commit hooks -pre-commit install -``` +2. Update `.env` with your local settings: + - **DATABASE_URL**: PostgreSQL database URL. + - **REDIS_URL**: Redis server URL. + - **IPFS_URL**: IPFS server URL. + - **BLOCKCHAIN_PROVIDER_URL**: URL for connecting to OP Sepolia testnet. + + Refer to [ENVIRONMENT.md](./docs/setup/ENVIRONMENT.md) for more detailed configurations. + +### 3. Install Dependencies + +1. **Python Dependencies**: + ```bash + python -m venv venv + source venv/bin/activate + pip install -r requirements.txt + pip install -r requirements-dev.txt + ``` + +2. **Node.js Dependencies**: + ```bash + pnpm install + ``` + +3. **Pre-Commit Hooks**: + ```bash + pre-commit install + ``` + +### 4. Docker Setup + +For containerized environments: -### 3. Docker Environment ```yaml version: '3.8' services: @@ -122,117 +162,107 @@ services: ports: - "3000:3000" - "8545:8545" - volumes: - - .:/app environment: - NODE_ENV=development - ENABLE_TESTNET=true - postgres: image: postgres:13 ports: - "5432:5432" - volumes: - - postgres_data:/var/lib/postgresql/data - redis: image: redis:alpine ports: - "6379:6379" - ipfs: image: ipfs/kubo:latest ports: - "4001:4001" - "8080:8080" - "5001:5001" - -volumes: - postgres_data: ``` -### 4. Network Configuration +--- -#### OP Sepolia Setup -```yaml -networks: - op_sepolia: - rpc_url: "https://sepolia-sequencer.optimism.io" - chain_id: 11155420 - explorer: "https://sepolia-optimism.etherscan.io" -``` +## Running the Development Environment -#### AltLayer Configuration -```yaml -networks: - altlayer: - rpc_url: "${ALTLAYER_RPC_URL}" - chain_id: "${ALTLAYER_CHAIN_ID}" +### Start Docker Environment + +```bash +docker-compose up -d ``` -### 5. IDE Configuration - -#### VS Code Setup -```json -{ - "editor.formatOnSave": true, - "python.linting.enabled": true, - "python.linting.pylintEnabled": true, - "rust-analyzer.checkOnSave.command": "clippy", - "[python]": { - "editor.defaultFormatter": "ms-python.black-formatter" - }, - "[rust]": { - "editor.defaultFormatter": "rust-lang.rust-analyzer" - } -} +### Run Development Server + +```bash +python manage.py runserver ``` -For detailed IDE setup, see [SETUP.md](./docs/guidelines/infrastructure/SETUP.md) +Access the API documentation at [http://localhost:3000/docs](http://localhost:3000/docs). -## Development Workflow +--- -### Local Development -```bash -# Start development environment -docker-compose up -d +## Testing and Quality Assurance -# Run development server -python manage.py runserver +### Run Tests -# Access API documentation -open http://localhost:3000/docs -``` +1. **Complete Test Suite**: + ```bash + pytest + ``` -### Testing -```bash -# Run test suite -pytest +2. **Specific Component Tests**: + ```bash + pytest tests/protocol/ + pytest tests/ai/ + pytest tests/storage/ + ``` -# Run specific components -pytest tests/protocol/ -pytest tests/ai/ -pytest tests/storage/ +3. **Generate Coverage Report**: + ```bash + pytest --cov=app --cov-report=html + ``` -# Generate coverage report -pytest --cov=app --cov-report=html -``` +### Linting and Code Formatting + +1. **Python Formatting**: + ```bash + black . + ``` + +2. **Rust Formatting**: + ```bash + cargo fmt + cargo clippy + ``` + +## Troubleshooting and Optimization + +- **Docker-WSL2 Performance**: + - Allocate more memory and CPU in Docker settings for better performance. + - Check integration with WSL2 if running on Windows. -## Documentation Resources +- **Database Connectivity**: + - Verify `.env` settings for `DATABASE_URL` and ensure PostgreSQL is running. + - Check Docker logs: + ```bash + docker-compose logs -f postgres + ``` + +- **Blockchain Testnet**: + - Ensure access to the OP Sepolia testnet and add any required API keys to the `.env`. + +## Contributing + +Please refer to the [CONTRIBUTING.md](./docs/CONTRIBUTING.md) file for guidelines on contributing to this project, including coding standards, commit message format, and code review process. + +## Additional Resources -### Core Documentation - [API Documentation](./docs/api/API.md) -- [Protocol Specification](./docs/api/SPEC.md) -- [Security Guidelines](./docs/guidelines/infrastructure/SECURITY.md) -- [Contributing Guide](./docs/guidelines/CONTRIBUTING.md) - -### Component Documentation -- [Core Protocol Architecture](./docs/architecture/DEVELOPMENT.md) -- [Legal Intelligence Model](./docs/components/CURATOR.md) -- [Storage System](./docs/0g/STORAGE.md) -- [Node Operations](./docs/deployment/NODE_OPERATIONS.md) - -## Support & Community -- [GitHub Issues](https://github.com/datahiv3/Legalese-Node-LN1/issues) -- [Development Discussions](https://github.com/datahiv3/Legalese-Node-LN1/discussions) -- [Technical Documentation](./docs/README.md) +- [Protocol Specification](./docs/protocol/SPEC.md) +- [Security Guidelines](./docs/security/SECURITY.md) + +## Support Channels + +- [GitHub Issues](https://github.com/datahiv3/Legalese-Node-LN1/issues) - Report bugs or request features +- [Development Discussions](https://github.com/datahiv3/Legalese-Node-LN1/discussions) - Community and technical discussions +- [Technical Documentation](./docs/README.md) - Complete development documentation