Skip to content

Latest commit

 

History

History
220 lines (166 loc) · 3.95 KB

File metadata and controls

220 lines (166 loc) · 3.95 KB

🚀 Quick Deployment Guide

Prerequisites

  • Node.js installed
  • Cloudflare account configured
  • Wrangler CLI installed

📦 Step 1: Install Dependencies

Frontend:

cd C:\Users\rsimd\Desktop\client-database-system\frontend
npm install

Backend:

cd C:\Users\rsimd\Desktop\client-database-system\backend
npm install

🗄️ Step 2: Verify Database Schema

Make sure your D1 database has the is_active column in the users table. Run this migration if needed:

-- Add is_active column to users table (if not exists)
ALTER TABLE users ADD COLUMN is_active INTEGER DEFAULT 1;

To run the migration:

wrangler d1 execute client-database --command="ALTER TABLE users ADD COLUMN is_active INTEGER DEFAULT 1;"

🎨 Step 3: Build & Deploy Frontend

cd frontend
npm run build
npm run deploy

This will deploy to: https://client-database-tji.pages.dev/


⚙️ Step 4: Deploy Backend

cd backend
wrangler deploy

This will deploy to: https://client-database-api.ghwmelite.workers.dev/


Step 5: Verify Deployment

  1. Visit your frontend URL
  2. Login with: admin / Admin@123
  3. Check all new pages:
    • Dashboard (should show charts)
    • Clients (click one to see detail page)
    • Analytics (view reports)
    • Users (admin only)
    • Settings (all 4 tabs)

🔧 Troubleshooting

Issue: "Module not found" errors

Solution:

cd frontend
npm install react-router-dom axios react-hot-toast recharts

Issue: Backend routes not working

Solution: Redeploy the backend:

cd backend
wrangler deploy --force

Issue: Users page returns 403

Solution: Make sure you're logged in as an admin user. The default admin is:

  • Username: admin
  • Password: Admin@123

Issue: File uploads fail

Solution: Verify R2 bucket configuration in wrangler.toml:

[[r2_buckets]]
binding = "FILES"
bucket_name = "client-database-files"

🎯 Testing New Features

Test User Management:

  1. Login as admin
  2. Go to /users
  3. Click "Add New User"
  4. Fill in details and save
  5. Verify user appears in list
  6. Try editing and deleting

Test Analytics:

  1. Go to /analytics
  2. Change time range dropdown
  3. Verify charts update
  4. Click "Export Report"
  5. Verify CSV downloads

Test Client Detail:

  1. Go to /clients
  2. Click on any client
  3. Add a note
  4. Upload a file
  5. Download the file
  6. Edit client info
  7. Verify all changes save

Test Settings:

  1. Go to /settings
  2. Try each tab
  3. Update profile email
  4. Change password
  5. Toggle preferences

📊 Feature Checklist

After deployment, verify:

  • Dashboard shows 4 stat cards
  • Dashboard shows 3 charts
  • Analytics page loads with charts
  • Analytics export works
  • Client detail page shows notes tab
  • Client detail page shows files tab
  • File upload works
  • File download works
  • Settings page has 4 tabs
  • Users page loads (admin only)
  • User CRUD operations work
  • Branding shows "ClientPro Database"
  • All navigation links work

🎉 Success!

If all items in the checklist pass, your deployment is successful!

Your ClientPro Database is now fully featured with:

  • ✅ User Management
  • ✅ Advanced Analytics
  • ✅ File Uploads
  • ✅ Interactive Charts
  • ✅ Settings Page
  • ✅ Client Detail View

📞 Need Help?

Common commands:

View backend logs:

wrangler tail

Test backend locally:

cd backend
npm run dev

Test frontend locally:

cd frontend
npm run dev

Reset database (careful!):

wrangler d1 execute client-database --command="DELETE FROM users WHERE role='user';"

🔄 Future Updates

To update after code changes:

  1. Make your changes
  2. Run:
# Frontend
cd frontend && npm run build && npm run deploy

# Backend
cd backend && wrangler deploy

That's it! 🚀