Monorepo Structure Guide
Overview
The CR8 project is organized as a monorepo with three separate packages, each serving a distinct purpose and requiring different hosting strategies.
Project Structure
CR8/
├── packages/
│ ├── contracts/ # Smart contracts (Hardhat project)
│ ├── dapp/ # DApp - Blockchain interaction UI (Next.js)
│ └── website/ # Website - Landing & docs (Next.js static)
├── docs/ # Project documentation
└── package.json # Root workspace configurationPackage Details
@cr8/contracts
Purpose: Smart contracts for the CR8 platform
Location: packages/contracts/
Technology: Hardhat, Solidity
Hosting: Not applicable (deployed to blockchain networks)
Deployment:
- Deploy to testnet:
npm run deploy:sepolia --workspace=packages/contracts - Deploy to mainnet: Configure and deploy via Hardhat scripts
Key Files:
contracts/- Solidity contractsscripts/- Deployment scriptstest/- Contract testshardhat.config.js- Hardhat configuration
@cr8/dapp
Purpose: Blockchain interaction interface for users
Location: packages/dapp/
Technology: Next.js, React, TypeScript, Wagmi, RainbowKit
Hosting: Vercel (recommended) or any Node.js hosting
Deployment:
- Connect GitHub repo to Vercel
- Set root directory to
packages/dapp - Configure environment variables:
NEXT_PUBLIC_CHAIN_IDNEXT_PUBLIC_WALLETCONNECT_PROJECT_ID
- Deploy
Vercel Configuration: Already configured in packages/dapp/vercel.json
Key Features:
- Agent Registry & Registration
- CR8 Token Staking
- Portfolio Management
- Agent Detail Pages
- Liquidity Provision
- Reward Claiming
@cr8/website
Purpose: Landing page, documentation, and marketing
Location: packages/website/
Technology: Next.js (static export), React, TypeScript, Tailwind CSS
Hosting: Any static hosting (Vercel, Netlify, GitHub Pages, Cloudflare Pages)
Deployment:
- Build:
npm run build --workspace=packages/website - Deploy the
out/directory to static hosting - Or connect to Vercel/Netlify for automatic deployments
Vercel Configuration: Already configured in packages/website/vercel.json
Key Features:
- Landing page
- Documentation
- Marketing content
- Static site generation
Development Workflow
Install Dependencies
# Install all packages
npm install
# Or install specific package
cd packages/contracts && npm install
cd packages/dapp && npm install
cd packages/website && npm installDevelopment
# Contracts
npm run contracts:compile
npm run contracts:test
# DApp (runs on port 3000)
npm run dapp:dev
# Website (runs on port 3001)
npm run website:devBuilding
# Build all
npm run contracts:compile
npm run dapp:build
npm run website:build
# Or build individually
cd packages/dapp && npm run build
cd packages/website && npm run buildDeployment Strategy
Separate Hosting
Each package can be deployed independently:
- Contracts: Deploy to blockchain networks (Sepolia, Mainnet)
- DApp: Deploy to Vercel (or similar Node.js hosting)
- Website: Deploy to static hosting (Vercel, Netlify, etc.)
Vercel Setup
For DApp:
- Go to Vercel dashboard
- Import project from GitHub
- Set root directory:
packages/dapp - Configure environment variables
- Deploy
For Website:
- Create a separate Vercel project
- Set root directory:
packages/website - Configure as static site
- Deploy
Environment Variables
DApp (.env.local in packages/dapp/):
NEXT_PUBLIC_CHAIN_ID=11155111
NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID=your_project_idContracts (.env in packages/contracts/):
PRIVATE_KEY=your_private_key
SEPOLIA_RPC_URL=your_rpc_url
ETHERSCAN_API_KEY=your_api_keyBenefits of This Structure
- Separation of Concerns: Each package has a clear purpose
- Independent Deployment: Deploy packages separately as needed
- Different Hosting: Use appropriate hosting for each package type
- Code Sharing: Shared utilities can be added as separate packages
- Version Management: Each package can be versioned independently
- Team Collaboration: Different teams can work on different packages
Future Additions
Potential additional packages:
@cr8/shared- Shared utilities and types@cr8/sdk- JavaScript SDK for interacting with contracts@cr8/mobile- Mobile app (React Native)
Troubleshooting
Workspace Issues
If npm workspaces aren't working:
rm -rf node_modules package-lock.json
rm -rf packages/*/node_modules packages/*/package-lock.json
npm installBuild Issues
If builds fail, ensure you're in the correct directory:
# For contracts
cd packages/contracts && npm run compile
# For dapp
cd packages/dapp && npm run build
# For website
cd packages/website && npm run build