Skip to content

Commit fce1fe0

Browse files
author
omkar007-lab
committed
project com
0 parents  commit fce1fe0

File tree

273 files changed

+71105
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

273 files changed

+71105
-0
lines changed

.github/workflows/ci.yml

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ main, develop ]
6+
pull_request:
7+
branches: [ main, develop ]
8+
9+
jobs:
10+
# Test Smart Contracts
11+
test-contracts:
12+
runs-on: ubuntu-latest
13+
defaults:
14+
run:
15+
working-directory: ./smart-contracts
16+
17+
steps:
18+
- uses: actions/checkout@v4
19+
20+
- name: Setup Node.js
21+
uses: actions/setup-node@v4
22+
with:
23+
node-version: '18'
24+
cache: 'npm'
25+
cache-dependency-path: ./smart-contracts/package-lock.json
26+
27+
- name: Install dependencies
28+
run: npm ci
29+
30+
- name: Compile contracts
31+
run: npm run compile
32+
33+
- name: Run tests
34+
run: npm test
35+
36+
# Test Backend
37+
test-backend:
38+
runs-on: ubuntu-latest
39+
defaults:
40+
run:
41+
working-directory: ./backend
42+
43+
steps:
44+
- uses: actions/checkout@v4
45+
46+
- name: Setup Node.js
47+
uses: actions/setup-node@v4
48+
with:
49+
node-version: '18'
50+
cache: 'npm'
51+
cache-dependency-path: ./backend/package-lock.json
52+
53+
- name: Install dependencies
54+
run: npm ci
55+
56+
- name: Run tests
57+
run: npm test
58+
env:
59+
SUPABASE_URL: ${{ secrets.SUPABASE_URL || 'https://test.supabase.co' }}
60+
SUPABASE_KEY: ${{ secrets.SUPABASE_KEY || 'test-key' }}
61+
FLARE_RPC: ${{ secrets.FLARE_RPC || 'https://test-rpc.flare.network' }}
62+
63+
# Lint Frontend
64+
lint-frontend:
65+
runs-on: ubuntu-latest
66+
defaults:
67+
run:
68+
working-directory: ./frontend
69+
70+
steps:
71+
- uses: actions/checkout@v4
72+
73+
- name: Setup Node.js
74+
uses: actions/setup-node@v4
75+
with:
76+
node-version: '18'
77+
cache: 'npm'
78+
cache-dependency-path: ./frontend/package-lock.json
79+
80+
- name: Install dependencies
81+
run: npm ci
82+
83+
- name: Run linter
84+
run: npm run lint || echo "Linter not configured, skipping..."
85+

.gitignore

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
# Dependencies
2+
node_modules/
3+
*/node_modules/
4+
5+
# Environment variables
6+
.env
7+
.env.local
8+
.env.development.local
9+
.env.test.local
10+
.env.production.local
11+
12+
# Build outputs
13+
dist/
14+
build/
15+
*/dist/
16+
*/build/
17+
18+
19+
# IDE and Editor files
20+
.vscode/
21+
.idea/
22+
*.swp
23+
*.swo
24+
*~
25+
26+
# OS files
27+
.DS_Store
28+
Thumbs.db
29+
30+
# Logs
31+
*.log
32+
npm-debug.log*
33+
yarn-debug.log*
34+
yarn-error.log*
35+
36+
# Runtime data
37+
pids
38+
*.pid
39+
*.seed
40+
*.pid.lock
41+
42+
# Coverage directory used by tools like istanbul
43+
coverage/
44+
*.lcov
45+
46+
# nyc test coverage
47+
.nyc_output
48+
49+
# Dependency directories
50+
jspm_packages/
51+
52+
# Optional npm cache directory
53+
.npm
54+
55+
# Optional eslint cache
56+
.eslintcache
57+
58+
# Yarn Integrity file
59+
.yarn-integrity
60+
61+
# parcel-bundler cache
62+
.cache
63+
.parcel-cache
64+
65+
# Next.js build output
66+
.next
67+
68+
# Nuxt.js build / generate output
69+
.nuxt
70+
71+
# Gatsby files
72+
.cache/
73+
public
74+
75+
# Storybook build outputs
76+
.out
77+
.storybook-out
78+
79+
# Temporary folders
80+
tmp/
81+
temp/

DEPLOYMENT_GUIDE_V2.md

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
# Deployment Guide
2+
3+
This guide covers how to deploy the **ChainMatrix** application.
4+
- **Frontend**: Vercel
5+
- **Backend**: Vercel (Recommended) or Render
6+
7+
## Option 1: Full Deployment on Vercel (Recommended)
8+
9+
Since the backend includes a `vercel.json` configuration, you can deploy both the frontend and backend to Vercel. This is often the easiest path.
10+
11+
### 1. Backend Deployment (Vercel)
12+
13+
1. Push your code to a GitHub repository.
14+
2. Go to [Vercel Dashboard](https://vercel.com/dashboard) and click **Add New > Project**.
15+
3. Import your GitHub repository.
16+
4. **Framework Preset**: Select **Other**.
17+
5. **Root Directory**: Click "Edit" and select `backend`.
18+
6. **Environment Variables**: Add the following variables from your `.env`:
19+
- `FLARE_RPC`
20+
- `FTSO_ADDRESS` (use `0x3d893C53D9e8056135C26C8c638B76C8b60Df726`)
21+
- `SUPABASE_URL`
22+
- `SUPABASE_KEY`
23+
- `SPONSOR_WALLET_PRIVATE_KEY` (if using smart accounts)
24+
7. Click **Deploy**.
25+
8. **Note the URL**: You will get a URL like `https://your-backend.vercel.app`.
26+
27+
### 2. Frontend Deployment (Vercel)
28+
29+
1. Go to [Vercel Dashboard](https://vercel.com/dashboard) and click **Add New > Project**.
30+
2. Import the **SAME** GitHub repository.
31+
3. **Framework Preset**: Vercel should auto-detect **Vite**.
32+
4. **Root Directory**: Click "Edit" and select `frontend`.
33+
5. **Environment Variables**:
34+
- `VITE_API_URL`: Set this to your **Backend URL** from the previous step (e.g., `https://your-backend.vercel.app`).
35+
- `VITE_CLERK_PUBLISHABLE_KEY`: Your Clerk Key.
36+
- `VITE_PRIVY_APP_ID`: Your Privy App ID.
37+
- `VITE_MAPBOX_API`: Your Mapbox token.
38+
- Other `VITE_` variables from your `.env`.
39+
6. Click **Deploy**.
40+
41+
---
42+
43+
## Option 2: Frontend on Vercel, Backend on Render
44+
45+
If you prefer Render for the backend (e.g., for persistent background jobs), follow these steps.
46+
47+
### 1. Backend Deployment (Render)
48+
49+
1. Push your code to GitHub.
50+
2. Go to [Render Dashboard](https://dashboard.render.com/) and click **New > Web Service**.
51+
3. Connect your GitHub repository.
52+
4. **Root Directory**: `backend`
53+
5. **Build Command**: `npm install`
54+
6. **Start Command**: `node server.js`
55+
7. **Environment Variables**: Add all variables from your backend `.env`.
56+
8. Click **Create Web Service**.
57+
9. **Note the URL**: Copty the provided Render URL.
58+
59+
### 2. Frontend Deployment (Vercel)
60+
61+
Follow the same steps as **Option 1 (Frontend)**, but set `VITE_API_URL` to your **Render Backend URL**.
62+
63+
---
64+
65+
## Important Configurations
66+
67+
### 1. CORS
68+
Ensure your backend allows requests from your frontend domain. In `backend/server.js`, you might need to update CORS if it's too restrictive, but `app.use(cors())` usually allows all origins by default, which is fine for initial testing.
69+
70+
### 2. FTSO Optimization
71+
The backend currently connects to the **Coston2 Testnet**. Ensure your frontend wallet (MetaMask) is also connected to Coston2 if you are interacting with smart contracts there.
72+
73+
74+
---
75+
76+
## Smart Contracts (Important!)
77+
78+
You do **NOT** host smart contracts like a website. Instead, you **deploy** them to the blockchain once. They then live there correctly forever.
79+
80+
### 1. Deploy to Flare Coston2 Testnet
81+
Run the following command in your `smart-contracts` folder:
82+
83+
```bash
84+
npx hardhat run scripts/deploy-flare-adapter.js --network coston
85+
```
86+
87+
### 2. Update Environment Variables
88+
The deployment script will print the **Contract Address**. You must update this address in your project:
89+
90+
1. **Frontend**: Update `VITE_FLARE_ADAPTER_ADDRESS` in `frontend/.env`.
91+
2. **Backend**: Update `FLARE_ADAPTER_ADDRESS` in `backend/.env`.
92+
93+
Re-deploy your frontend and backend if you change these variables.
94+
95+
---
96+
97+
## Verification
98+
After deployment:
99+
1. Open your Frontend URL.
100+
2. Navigate to **Live Charts**.
101+
3. Verify that prices are loading (this confirms Frontend -> Backend communication).
102+
103+
---
104+
105+
## Troubleshooting
106+
107+
### "404: NOT_FOUND" or "ID: bom1::..." Error
108+
If you see an error like `ID: bom1::...` when clicking confirm or entering amounts, it means your **Frontend cannot find your Backend**.
109+
110+
**Cause**: `VITE_API_URL` is missing or incorrect in your Vercel Frontend settings.
111+
112+
**Fix**:
113+
1. Go to your Vercel Project Settings -> **Environment Variables**.
114+
2. Add/Update `VITE_API_URL`.
115+
3. Value: Your **Render Backend URL** (e.g., `https://chain-matrix-backend.onrender.com`).
116+
4. **Important**: You must **Redeploy** the frontend for this change to take effect (go to Deployments -> Redeploy).

0 commit comments

Comments
 (0)