This guide covers how to ship BlockProof from local dev to production, including the backend (Node/Express), frontend (React/Vite), optional blockchain setup, and Gemini AI configuration.
- Node.js 18+ recommended (backend requires >=16; Vercel/Netlify default to 18).
- npm 8+.
- GitHub repo access for CI/CD connects.
- Accounts: Railway (backend), Vercel (frontend). Optional: MetaMask with testnet MATIC for blockchain, Google AI key for Gemini.
Configure these before deployment. Values without secrets are safe defaults; secrets must be stored in your host's secret manager.
| Variable | Required? | Description |
|---|---|---|
| PORT | Optional | Backend port (default 5000). Usually set by platform. |
| NODE_ENV | Yes | production in hosted envs. |
| FRONTEND_URL | Yes | Full https URL of deployed frontend for CORS (e.g., https://app.example.com). |
| BLOCKCHAIN_RPC_URL | Optional | RPC endpoint (e.g., https://rpc-mumbai.maticvigil.com/). Leave empty for simulation mode. |
| CONTRACT_ADDRESS | Optional | Deployed CertificateRegistry address. Empty = simulation mode. |
| PRIVATE_KEY | Optional | Issuer wallet private key (use a throwaway or env secret). Needed only when CONTRACT_ADDRESS is set. |
| GEMINI_API_KEY | Optional | Google Gemini API key for AI analysis. Empty = AI simulation mode. |
| ALCHEMY_API_KEY / INFURA_PROJECT_ID | Optional | Premium RPC keys if you prefer. |
| VITE_API_URL | Frontend | Base API URL exposed to the browser, e.g., https://api.example.com/api. Set in frontend hosting env vars. |
- Install Railway CLI:
npm install -g @railway/cli. - From repo root:
cd backend. - Log in and init:
railway loginthenrailway init(orrailway linkif project exists). - Push code:
railway up(builds and deploys from current directory). - In Railway dashboard, add env vars from section 2. Set
FRONTEND_URLto your final frontend domain. - Note the public backend URL (e.g., https://blockproof-production.up.railway.app). Use it for
VITE_API_URLon the frontend. - Verify: open
https://<backend>/api/healthandhttps://<backend>/api/status.
- Build steps:
npm installinside backend. - Start command:
node server.js(ornpm start). - Expose port from
PORTenv (platform usually injects it). - Apply the same env vars; ensure CORS
FRONTEND_URLmatches the deployed frontend origin.
- From repo root:
cd frontend. - Connect the repo in Vercel dashboard or run
vercelCLI. - Build command:
npm run build. Output directory:dist. - Env vars: set
VITE_API_URLto your deployed backend base (include/api, e.g., https://api.example.com/api). - Redeploy. After deploy, open the site and ensure API calls succeed.
- Build:
npm install && npm run buildinfrontend. - Publish folder:
dist. - Add
VITE_API_URLas a build-time env var.
- Get testnet MATIC from https://faucet.polygon.technology/ to a throwaway MetaMask wallet.
- Deploy
backend/contracts/CertificateRegistry.solusing Hardhat or your preferred tool (target Polygon Mumbai). Keep the deployed address. - Set env vars:
BLOCKCHAIN_RPC_URL,CONTRACT_ADDRESS,PRIVATE_KEY(for the issuer wallet). Do this in the backend host. - Redeploy backend so it initializes the contract (check
/api/healthto confirmblockchain.initializedandhasContract).
- Create a Gemini API key at https://ai.google.dev/.
- Set
GEMINI_API_KEYin backend env vars. - Redeploy backend.
/api/statusshould show AI features enabled.
- Backend health: curl
https://<backend>/api/health. - Issue a cert: POST
https://<backend>/api/certificates/issuewith sample payload; note returnedcertificateId. - Verify a cert: POST
https://<backend>/api/certificates/verifywith the ID and confirm verdict. - Frontend sanity: load the deployed site, run Issue/Verify flows, and ensure images upload/verify.
- CORS: if calls fail, confirm
FRONTEND_URLmatches the deployed frontend origin exactly (protocol + domain + port if any).
- API 404s from frontend: check
VITE_API_URLincludes/apiand points to the live backend. - CORS blocked: update backend
FRONTEND_URLto the exact frontend origin and redeploy backend. - Blockchain errors: confirm RPC URL is reachable and
CONTRACT_ADDRESSmatches the deployed network; ensure the wallet has gas. - Gemini unavailable: verify
GEMINI_API_KEYis set and not rate-limited; otherwise the service falls back to simulation mode.
You are ready to ship. For local dev, use QUICKSTART.md; for security practices, see SECURITY.md and backend/.env.example.