# ClauseGuard — Deployment Guide ## What's running now | Component | Status | URL | |-----------|--------|-----| | Gradio demo | ✅ Live | https://huggingface.co/spaces/gaurv007/ClauseGuard | | ML model | ✅ On Hub | https://huggingface.co/gaurv007/clauseguard-legal-bert | | FastAPI backend | ❌ Needs host | Code ready in `api/` | | Next.js website | ❌ Needs Vercel | Code ready in `web/` | | Chrome extension | ❌ Needs testing | Code ready in `extension/` | --- ## 1. Test the Chrome Extension (5 minutes) The extension works WITHOUT the backend — it uses local regex fallback. ### Steps: ``` 1. Download the extension/ folder from the repo → Go to https://huggingface.co/spaces/gaurv007/ClauseGuard/tree/main/extension → Or clone: git clone https://huggingface.co/spaces/gaurv007/ClauseGuard 2. Open Chrome → chrome://extensions/ 3. Toggle ON "Developer mode" (top right) 4. Click "Load unpacked" 5. Select the extension/ folder 6. Visit any Terms of Service page (try spotify.com/legal or airbnb.com/terms) 7. The extension will auto-scan and highlight unfair clauses ``` The extension uses local pattern matching until you point it at a running backend. To connect it to the API, change `API_BASE` in `background.js`. --- ## 2. Deploy the Backend (choose one) ### Option A: HuggingFace Spaces (free, easiest) Create a new Space with Docker SDK: 1. Go to https://huggingface.co/new-space 2. Name: `clauseguard-api` 3. SDK: Docker 4. Create this `Dockerfile` in the Space: ```dockerfile FROM python:3.12-slim WORKDIR /app COPY api/requirements.txt . RUN pip install --no-cache-dir -r requirements.txt COPY api/ . EXPOSE 7860 CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"] ``` 5. Copy `api/main.py`, `api/auth.py`, `api/requirements.txt` into the Space 6. Your API will be at: `https://gaurv007-clauseguard-api.hf.space` ### Option B: Railway (free tier, auto-deploy) ```bash # Install Railway CLI npm install -g @railway/cli # Login and deploy cd api/ railway login railway init railway up ``` Your API will get a URL like `https://clauseguard-api-production.up.railway.app` ### Option C: Render (free tier) 1. Go to https://render.com 2. New → Web Service → Connect your Git repo 3. Root directory: `api` 4. Build command: `pip install -r requirements.txt` 5. Start command: `uvicorn main:app --host 0.0.0.0 --port $PORT` ### After deploying the backend: Update `API_BASE` in `extension/background.js`: ```javascript const API_BASE = "https://your-backend-url.com"; // your deployed URL ``` Update `CLAUSEGUARD_API_URL` in `web/.env.local`: ``` CLAUSEGUARD_API_URL=https://your-backend-url.com ``` --- ## 3. Deploy the Website on Vercel (10 minutes) ### Prerequisites: - GitHub account (to push the repo) - Vercel account (free at vercel.com) - Supabase project created - Stripe products created ### Steps: ```bash # 1. Push web/ folder to a GitHub repo cd web/ git init git add . git commit -m "ClauseGuard website" git remote add origin https://github.com/YOUR_USERNAME/clauseguard-web.git git push -u origin main # 2. Go to vercel.com → New Project → Import the GitHub repo # 3. Set the Root Directory to: web # 4. Add environment variables in Vercel dashboard: ``` ### Required environment variables on Vercel: ``` NEXT_PUBLIC_SUPABASE_URL=https://xxxxx.supabase.co NEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY=eyJ... SUPABASE_SERVICE_ROLE_KEY=eyJ... SUPABASE_JWT_SECRET=your-jwt-secret STRIPE_SECRET_KEY=sk_live_... STRIPE_WEBHOOK_SECRET=whsec_... STRIPE_PRO_PRICE_ID=price_... STRIPE_TEAM_PRICE_ID=price_... RESEND_API_KEY=re_... NEXT_PUBLIC_SITE_URL=https://your-domain.vercel.app CLAUSEGUARD_API_URL=https://your-backend-url.com ``` 5. Click Deploy 6. Your site will be at: `https://clauseguard.vercel.app` ### Custom domain: - In Vercel → Settings → Domains → Add `clauseguardweb.netlify.app` - Point your DNS A record to Vercel's IP --- ## 4. Setup Supabase (5 minutes) 1. Go to https://supabase.com → New Project 2. Go to SQL Editor → paste and run `web/lib/supabase/schema.sql` 3. Go to Authentication → Providers → Enable Google and GitHub 4. Copy from Settings → API: - Project URL → `NEXT_PUBLIC_SUPABASE_URL` - `anon` public key → `NEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY` - `service_role` key → `SUPABASE_SERVICE_ROLE_KEY` - JWT Secret → `SUPABASE_JWT_SECRET` --- ## 5. Setup Stripe (5 minutes) 1. Go to https://dashboard.stripe.com 2. Products → Create: - "ClauseGuard Pro" — $12/month recurring - "ClauseGuard Team" — $49/month recurring 3. Copy each product's Price ID → `STRIPE_PRO_PRICE_ID`, `STRIPE_TEAM_PRICE_ID` 4. Developers → Webhooks → Add endpoint: - URL: `https://your-site.vercel.app/api/stripe/webhook` - Events: `customer.subscription.created`, `customer.subscription.updated`, `customer.subscription.deleted`, `invoice.payment_failed` 5. Copy webhook signing secret → `STRIPE_WEBHOOK_SECRET` 6. Settings → Billing → Customer Portal → Enable --- ## 6. Setup Resend (2 minutes) 1. Go to https://resend.com → Sign up 2. API Keys → Create → Copy key → `RESEND_API_KEY` 3. Domains → Add `clauseguardweb.netlify.app` → Add DNS records they give you 4. Until domain is verified, emails send from `onboarding@resend.dev` --- ## Order of operations ``` 1. Supabase (create project, run schema) — 5 min 2. Backend (deploy to Railway/Render/HF) — 5 min 3. Stripe (create products) — 5 min 4. Resend (get API key) — 2 min 5. Vercel (deploy with all env vars) — 10 min 6. Extension (update API_BASE, load unpacked) — 2 min 7. Test everything end-to-end — 5 min ``` Total: ~35 minutes to go fully live.