🚀 Setup & Deployment ​
IMPORTANT WARNING** ​
To run this complex project on local or cloud you need to read these docs to have a global overview:
- Google Secret Manager: https://docs.cloud.google.com/secret-manager/docs/reference/libraries#client-libraries-install-nodejs
- Convex Documentation: https://docs.convex.dev/home
- ZK Sandbox API: https://github.com/dao-solution-inc/zk_sandbox_api
- Convex Auth: https://labs.convex.dev/auth
This document provides comprehensive instructions for setting up, configuring, and deploying the MyPit platform across different environments.
🏗️ Development Environment Setup ​
Prerequisites ​
# Required Software
Node.js >= 18.17.0
npm >= 9.0.0
Git >= 2.34.0
Docker >= 24.0.0 (for sandbox environments)Initial Setup ​
1. Clone Repository ​
git clone https://github.com/dao-solution-inc/mypit_production.git
cd mypit_production2. Install Dependencies ​
# Install main dependencies
npm install
# If error, then Install with force dependencies
npm install --forceDeploy ZKP API ​
Before configuring Convex, deploy your ZKP (Zero-Knowledge Proof) API to any cloud service and obtain the public API URL. This URL will be used in the environment configuration.
ZKP API Details:
- Technology Stack: Node.js Express API
- Source Code: https://github.com/dao-solution-inc/zk_sandbox_api
- Deployment: Deploy this Node.js Express API to any cloud service (AWS, GCP, Azure, etc.)
- Required: Obtain the public API URL after deployment for environment configuration
3. Environment Configuration ​
Environment Variables Setup ​
Check the official docs on how to get the IDs and Keys for each environment.
All backend environment variables need to be set in Convex using the npx convex env set command. Set the following environment variables:
# Authentication Configuration
npx convex env set AUTH_GOOGLE_ID your_google_client_id
npx convex env set AUTH_GOOGLE_SECRET your_google_client_secret
npx convex env set AUTH_KAKAO_ID your_kakao_client_id
npx convex env set AUTH_KAKAO_SECRET your_kakao_client_secret
npx convex env set AUTH_RESEND_KEY your_resend_api_key
# Blockchain Configuration
npx convex env set CONTRACT_ADDRESS your_contract_address
npx convex env set INFURA_PROJECT_ID your_infura_project_id
npx convex env set INFURA_URL your_infura_url
npx convex env set PRIVATE_KEY your_private_key
# External Services
npx convex env set OPENAI_API_KEY your_openai_api_key
npx convex env set OPENAI_ORGANIZATION your_openai_organization
npx convex env set RESEND_API_KEY your_resend_api_key
# Application Configuration
npx convex env set SITE_URL your_site_url
npx convex env set zkpUrl your_zkp_api_url
# Google Services
npx convex env set GOOGLE_SERVICE_ACCOUNT your_google_service_account_jsonNote: The JWKS and JWT_PRIVATE_KEY environment variables will be automatically set during the Convex Auth initialization process.
Convex Authentication Setup ​
Set up Convex Auth for handling authentication:
# Set up Convex Auth
npx convex-dev/auth📚 Authentication Documentation:
- Convex Auth Setup Guide: https://labs.convex.dev/auth
- Main Convex Documentation: https://docs.convex.dev/home
Configure Authentication Providers ​
After setting up Convex Auth, configure the authentication providers:
# Start Convex in development mode and select cloud
npx convex dev
# When prompted, select "cloud"Google Authentication Configuration:
- Follow the Convex documentation for Google OAuth setup: https://docs.convex.dev/home
- Configure Google OAuth credentials in Google Cloud Console
- Set the AUTH_GOOGLE_ID and AUTH_GOOGLE_SECRET environment variables as shown above
Kakao Authentication Configuration:
- Follow the Convex documentation for Kakao OAuth setup: https://docs.convex.dev/home
- Configure Kakao OAuth credentials in Kakao Developers Console
- Set the AUTH_KAKAO_ID and AUTH_KAKAO_SECRET environment variables as shown above
OTP (One-Time Password) Configuration:
- Configure OTP settings as per Convex Auth documentation: https://labs.convex.dev/auth ETHEREUM_RPC_URL=https://mainnet.infura.io/v3/your-project-id ETHEREUM_PRIVATE_KEY=your-production-private-key CONTRACT_ADDRESS=0xProductionContractAddress
Production Infrastructure ​
GOOGLE_CLOUD_PROJECT_ID=mypit-production GOOGLE_CLOUD_REGION=us-central1 DOCKER_REGISTRY_URL=gcr.io/mypit-production
Production Monitoring ​
SENTRY_DSN=your-production-sentry-dsn NODE_ENV=production
4. Backend Setup (Convex) ​
The MyPit platform uses Convex as its Backend-as-a-Service (BaaS). Convex is an open-source platform that provides real-time database, serverless functions, and authentication.
📚 Required Reading:
- Convex Architecture Overview: https://docs.convex.dev/home
- Convex Auth Documentation: https://labs.convex.dev/auth
Before proceeding, familiarize yourself with Convex architecture and authentication patterns from the links above.
Initial Convex Setup ​
# Initialize Convex backend in development mode
npx convex dev
# When prompted, choose "cloud" to create a cloud development environment
# This creates a dev environment that will need to be deployed to production laterProduction Deployment ​
When ready to deploy to production:
# Deploy to production environment
npx convex deployđź“– Reference Documentation:
- Main Convex Documentation: https://docs.convex.dev/home
- Deployment Guide: Refer to the main Convex docs for detailed deployment instructions
System Initialization ​
After completing the Convex setup and authentication configuration, initialize the system:
go to https://dashboard.convex.dev/t/YOUR_ORG/YOUR_PROJECT/shocking-buzzard-196/functions?function=features%2Fsystem%3AsystemAdminInit
and call the systemAdminInit function by passing the params needed.
Note: This step is crucial for setting up the cryptographic infrastructure and ensuring secure key management across the platform.