cleanup
This commit is contained in:
parent
fe86e8b35b
commit
43d41f04c7
|
|
@ -0,0 +1,262 @@
|
|||
# 📦 Documentation & Scripts Consolidation Summary
|
||||
|
||||
## What Changed
|
||||
|
||||
Consolidated **50+ documentation files** and **15+ scripts** into a clean, organized structure.
|
||||
|
||||
---
|
||||
|
||||
## 📚 New Documentation Structure (4 Core Files)
|
||||
|
||||
### Main Docs (Keep These!)
|
||||
1. **README.md** - Main entry point, project overview
|
||||
2. **QUICK_START.md** - Getting started in 5 minutes
|
||||
3. **DEPLOYMENT.md** - Complete deployment guide
|
||||
4. **TROUBLESHOOTING.md** - Common issues and fixes
|
||||
|
||||
### Reference Docs (Optional)
|
||||
5. **QUICK_REFERENCE.md** - Command cheat sheet
|
||||
6. **PM2_PRODUCTION_GUIDE.md** - Detailed PM2 documentation
|
||||
|
||||
---
|
||||
|
||||
## 🔧 New Scripts Structure (5 Core Scripts)
|
||||
|
||||
All scripts now in `scripts/` folder:
|
||||
|
||||
1. **scripts/deploy.sh** - Unified deployment (backend, frontend, or both)
|
||||
2. **scripts/diagnose.sh** - Full system diagnostics
|
||||
3. **scripts/backup-db.sh** - Database backup
|
||||
4. **scripts/restore-db.sh** - Database restore from backup
|
||||
5. **scripts/fix-502.sh** - Auto-fix 502 Bad Gateway errors
|
||||
|
||||
---
|
||||
|
||||
## 🗑️ What Got Consolidated
|
||||
|
||||
### Removed Duplicate Deployment Docs (Merged into DEPLOYMENT.md)
|
||||
- ACTUAL_PRODUCTION_SETUP.md
|
||||
- ARCHITECTURE_OVERVIEW.md
|
||||
- DEPLOYMENT_MASTER_GUIDE.md
|
||||
- DEPLOYMENT_README.md
|
||||
- FLUTTER_DEPLOYMENT_GUIDE.md
|
||||
- PM2_QUICK_START.md
|
||||
- PRODUCTION_DIFFERENCES.md
|
||||
- PRODUCTION_UPDATE_GUIDE.md
|
||||
- PROXMOX_DEPLOYMENT_GUIDE.md
|
||||
- QUICK_DEPLOY.md
|
||||
- README_DEPLOYMENT.md
|
||||
- START_HERE.md
|
||||
- FINAL_SETUP_GUIDE.md
|
||||
|
||||
### Removed Duplicate Troubleshooting Docs (Merged into TROUBLESHOOTING.md)
|
||||
- CACHE_BUSTING_GUIDE.md
|
||||
- CACHE_FIX_SUMMARY.md
|
||||
- DEPLOYMENT_TROUBLESHOOTING.md
|
||||
- FIX_502_ERROR.md
|
||||
- FIX_CACHE_NOW.md
|
||||
- FIX_NOW_SERVICE_WORKER.md
|
||||
- FIX_SERVICE_WORKER_CACHE.md
|
||||
- NGINX_PROXY_CACHE_FIX.md
|
||||
|
||||
### Removed Feature/Implementation Docs (Outdated)
|
||||
- COMPLETE_FEATURES_DELIVERED.md
|
||||
- COMPLETE_IMPLEMENTATION_SUMMARY.md
|
||||
- CREATE_GROUP_IMPROVEMENTS.md
|
||||
- EVERYTHING_DELIVERED.md
|
||||
- SIGNUP_FEATURE_IMPLEMENTATION.md
|
||||
- SIGNUP_NAVIGATION_UPDATE.md
|
||||
- SIGNUP_QUICK_START.md
|
||||
- README_NEW_FEATURES.md
|
||||
|
||||
### Removed Planning Docs (No Longer Needed)
|
||||
- LuckyChit_Development_Plan_Revised.md
|
||||
- LuckyChit_Development_Plan.md
|
||||
- Project_Implementation_Plan.md
|
||||
- Technical_Architecture.md
|
||||
- Technical_Implementation_Guide_Revised.md
|
||||
- UI_UX_Design_Guide.md
|
||||
- TRADITIONAL_CHIT_FUND_MATHEMATICS.md
|
||||
|
||||
### Removed Redundant Scripts (Merged into scripts/)
|
||||
- backup-database.sh → scripts/backup-db.sh
|
||||
- clear-cache-and-deploy.sh → scripts/deploy.sh --force
|
||||
- deploy-backend-only.sh → scripts/deploy.sh backend
|
||||
- deploy-frontend-only.sh → scripts/deploy.sh frontend
|
||||
- deploy-frontend-simple.sh → scripts/deploy.sh frontend
|
||||
- deploy-frontend.sh → scripts/deploy.sh frontend
|
||||
- deploy-full.sh → scripts/deploy.sh
|
||||
- deploy.sh → scripts/deploy.sh
|
||||
- diagnose-502.sh → scripts/diagnose.sh
|
||||
- fix-502-auto.sh → scripts/fix-502.sh
|
||||
- fix-and-deploy.sh → scripts/deploy.sh --force
|
||||
- force-cache-bust.sh → scripts/deploy.sh --force
|
||||
- nginx-clear-cache.sh → (manual in TROUBLESHOOTING.md)
|
||||
- restore-database.sh → scripts/restore-db.sh
|
||||
- setup-deployment-scripts.sh → (no longer needed)
|
||||
|
||||
---
|
||||
|
||||
## ✅ Benefits
|
||||
|
||||
### Before
|
||||
- 50+ documentation files (confusing!)
|
||||
- 15+ scripts (which one to use?)
|
||||
- Duplicate information everywhere
|
||||
- Hard to find what you need
|
||||
|
||||
### After
|
||||
- 4 core documentation files (clear!)
|
||||
- 5 unified scripts (simple!)
|
||||
- No duplication
|
||||
- Easy to navigate
|
||||
|
||||
---
|
||||
|
||||
## 📋 How to Clean Up
|
||||
|
||||
### Option 1: Automatic Cleanup (Recommended)
|
||||
```bash
|
||||
chmod +x cleanup-old-files.sh
|
||||
./cleanup-old-files.sh
|
||||
```
|
||||
|
||||
This will:
|
||||
1. Create backup of old files
|
||||
2. Move old docs to `old_docs_backup_*/`
|
||||
3. Keep new structure clean
|
||||
|
||||
### Option 2: Manual Cleanup
|
||||
Keep only these files in root:
|
||||
```
|
||||
README.md
|
||||
QUICK_START.md
|
||||
DEPLOYMENT.md
|
||||
TROUBLESHOOTING.md
|
||||
QUICK_REFERENCE.md
|
||||
PM2_PRODUCTION_GUIDE.md
|
||||
cleanup-old-files.sh
|
||||
scripts/
|
||||
backend/
|
||||
luckychit/
|
||||
```
|
||||
|
||||
Delete everything else!
|
||||
|
||||
---
|
||||
|
||||
## 🎯 New Workflow
|
||||
|
||||
### Before (Confusing)
|
||||
```
|
||||
"Which deployment guide do I read?"
|
||||
"Which script deploys the frontend?"
|
||||
"Where's the troubleshooting info?"
|
||||
```
|
||||
|
||||
### After (Clear!)
|
||||
```
|
||||
Read: README.md (overview)
|
||||
Start: QUICK_START.md (5 minutes)
|
||||
Deploy: ./scripts/deploy.sh (one command)
|
||||
Issues: TROUBLESHOOTING.md (all fixes)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 📖 Documentation Mapping
|
||||
|
||||
### Old → New
|
||||
|
||||
| Old Documentation | New Location |
|
||||
|-------------------|--------------|
|
||||
| All deployment guides | DEPLOYMENT.md |
|
||||
| All troubleshooting guides | TROUBLESHOOTING.md |
|
||||
| All quick start guides | QUICK_START.md |
|
||||
| All architecture docs | DEPLOYMENT.md (Architecture section) |
|
||||
| All cache fix guides | TROUBLESHOOTING.md (Cache section) |
|
||||
| All 502 fix guides | TROUBLESHOOTING.md (502 section) |
|
||||
|
||||
### Old Scripts → New Scripts
|
||||
|
||||
| Old Script | New Script | Usage |
|
||||
|------------|------------|-------|
|
||||
| deploy-full.sh | scripts/deploy.sh | Deploy both |
|
||||
| deploy-backend-only.sh | scripts/deploy.sh backend | Deploy backend |
|
||||
| deploy-frontend-only.sh | scripts/deploy.sh frontend | Deploy frontend |
|
||||
| force-cache-bust.sh | scripts/deploy.sh --force | Force rebuild |
|
||||
| diagnose-502.sh | scripts/diagnose.sh | Diagnostics |
|
||||
| fix-502-auto.sh | scripts/fix-502.sh | Fix 502 |
|
||||
| backup-database.sh | scripts/backup-db.sh | Backup DB |
|
||||
| restore-database.sh | scripts/restore-db.sh | Restore DB |
|
||||
|
||||
---
|
||||
|
||||
## 🚀 Next Steps
|
||||
|
||||
1. **Run cleanup script**:
|
||||
```bash
|
||||
./cleanup-old-files.sh
|
||||
```
|
||||
|
||||
2. **Update your bookmarks**:
|
||||
- README.md (main docs)
|
||||
- QUICK_START.md (getting started)
|
||||
- DEPLOYMENT.md (deployment)
|
||||
- TROUBLESHOOTING.md (fixes)
|
||||
|
||||
3. **Update deployment commands**:
|
||||
```bash
|
||||
# Old
|
||||
./deploy-full.sh
|
||||
|
||||
# New
|
||||
./scripts/deploy.sh
|
||||
```
|
||||
|
||||
4. **Commit changes**:
|
||||
```bash
|
||||
git add .
|
||||
git commit -m "Consolidate documentation and scripts"
|
||||
git push origin prodnew
|
||||
```
|
||||
|
||||
5. **Test new scripts**:
|
||||
```bash
|
||||
./scripts/diagnose.sh # Check everything works
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 💡 Tips
|
||||
|
||||
- **Bookmark** README.md - your new starting point
|
||||
- **Use** scripts/ folder - all deployment tools there
|
||||
- **Check** TROUBLESHOOTING.md first when issues arise
|
||||
- **Delete** old_docs_backup_*/ after confirming everything works
|
||||
|
||||
---
|
||||
|
||||
## ⚠️ Important
|
||||
|
||||
**Before deleting old files**, make sure:
|
||||
- [ ] New scripts are executable (`chmod +x scripts/*.sh`)
|
||||
- [ ] Test `./scripts/deploy.sh` works
|
||||
- [ ] Test `./scripts/diagnose.sh` works
|
||||
- [ ] All team members are aware of new structure
|
||||
- [ ] Update any CI/CD pipelines
|
||||
- [ ] Update any external documentation links
|
||||
|
||||
---
|
||||
|
||||
## 🎉 Result
|
||||
|
||||
**Before**: 65+ files in root directory
|
||||
**After**: 10 core files + organized folders
|
||||
|
||||
**Much cleaner and easier to maintain!** 🚀
|
||||
|
||||
---
|
||||
|
||||
**Questions?** See [README.md](README.md) for the new documentation structure.
|
||||
|
||||
|
|
@ -0,0 +1,244 @@
|
|||
# 🚀 LuckyChit Deployment Guide
|
||||
|
||||
Complete production deployment guide.
|
||||
|
||||
---
|
||||
|
||||
## 📍 Production Setup
|
||||
|
||||
**Server IP**: 192.168.8.148
|
||||
**Domain**: chitfund.deepteklabs.com
|
||||
**User**: luckychit
|
||||
**Project**: /home/luckychit/apps/chitfund
|
||||
**Branch**: prodnew
|
||||
|
||||
---
|
||||
|
||||
## 🏗️ Architecture
|
||||
|
||||
```
|
||||
Internet
|
||||
↓
|
||||
Cloudflare (SSL, CDN)
|
||||
↓
|
||||
Nginx Proxy (LXC 1)
|
||||
↓
|
||||
Application Server (LXC 2: 192.168.8.148)
|
||||
├── PM2: luckychit-api (Port 3000)
|
||||
├── PM2: luckychit-frontend (Port 8080)
|
||||
└── PostgreSQL (Port 5432)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## ⚡ Quick Deploy
|
||||
|
||||
```bash
|
||||
ssh luckychit@192.168.8.148
|
||||
cd /home/luckychit/apps/chitfund
|
||||
./scripts/deploy.sh
|
||||
```
|
||||
|
||||
### Deploy Options:
|
||||
```bash
|
||||
./scripts/deploy.sh # Deploy both backend + frontend
|
||||
./scripts/deploy.sh backend # Backend only
|
||||
./scripts/deploy.sh frontend # Frontend only
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 🔧 Manual Deployment
|
||||
|
||||
### Backend
|
||||
```bash
|
||||
cd /home/luckychit/apps/chitfund
|
||||
git pull origin prodnew
|
||||
cd backend
|
||||
npm install
|
||||
pm2 restart luckychit-api
|
||||
pm2 logs luckychit-api --lines 20
|
||||
```
|
||||
|
||||
### Frontend
|
||||
```bash
|
||||
cd /home/luckychit/apps/chitfund
|
||||
git pull origin prodnew
|
||||
cd luckychit
|
||||
flutter pub get
|
||||
flutter build web --release --pwa-strategy=none
|
||||
pm2 restart luckychit-frontend
|
||||
pm2 logs luckychit-frontend --lines 20
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 📊 PM2 Commands
|
||||
|
||||
```bash
|
||||
pm2 status # Show all processes
|
||||
pm2 logs # Live logs
|
||||
pm2 logs luckychit-api # Backend logs
|
||||
pm2 logs luckychit-frontend # Frontend logs
|
||||
pm2 restart all # Restart everything
|
||||
pm2 monit # Real-time monitoring
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 🗑️ Clear Caches (After Deployment)
|
||||
|
||||
### 1. Server Cache
|
||||
```bash
|
||||
pm2 restart all
|
||||
```
|
||||
|
||||
### 2. Nginx Proxy Cache (if using separate LXC)
|
||||
```bash
|
||||
ssh root@<nginx-lxc-ip>
|
||||
sudo rm -rf /var/cache/nginx/*
|
||||
sudo systemctl reload nginx
|
||||
```
|
||||
|
||||
### 3. Cloudflare Cache
|
||||
- Login to Cloudflare dashboard
|
||||
- Caching → Purge Everything
|
||||
|
||||
### 4. Browser Cache
|
||||
```
|
||||
Hard Refresh: Ctrl + Shift + R (Windows) or Cmd + Shift + R (Mac)
|
||||
Or test in Incognito: Ctrl + Shift + N
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 🔥 Emergency: Complete Cache Clear
|
||||
|
||||
```bash
|
||||
cd /home/luckychit/apps/chitfund
|
||||
./scripts/deploy.sh --force
|
||||
```
|
||||
|
||||
This will:
|
||||
1. Clean all build caches
|
||||
2. Rebuild from scratch
|
||||
3. Restart all services
|
||||
4. Clear nginx cache (if configured)
|
||||
|
||||
---
|
||||
|
||||
## 🗄️ Database Backup
|
||||
|
||||
### Manual Backup
|
||||
```bash
|
||||
./scripts/backup-db.sh
|
||||
```
|
||||
|
||||
### Automated Daily Backup
|
||||
```bash
|
||||
# Add to crontab
|
||||
crontab -e
|
||||
# Add: 0 2 * * * /home/luckychit/apps/chitfund/scripts/backup-db.sh
|
||||
```
|
||||
|
||||
### Restore from Backup
|
||||
```bash
|
||||
./scripts/restore-db.sh
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 🔍 Initial Server Setup (One-Time)
|
||||
|
||||
### 1. Install Dependencies
|
||||
```bash
|
||||
# Node.js, Flutter, PM2, PostgreSQL
|
||||
# See PM2_PRODUCTION_GUIDE.md for details
|
||||
```
|
||||
|
||||
### 2. Setup PM2
|
||||
```bash
|
||||
cd /home/luckychit/apps/chitfund/backend
|
||||
pm2 start src/server.js --name luckychit-api
|
||||
|
||||
cd ../luckychit
|
||||
pm2 serve build/web 8080 --name luckychit-frontend --spa
|
||||
|
||||
pm2 save
|
||||
pm2 startup systemd -u luckychit --hp /home/luckychit
|
||||
```
|
||||
|
||||
### 3. Configure Auto-start
|
||||
```bash
|
||||
pm2 startup
|
||||
# Run the command it outputs
|
||||
pm2 save
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 🔐 Security Checklist
|
||||
|
||||
- [ ] Firewall configured (ports 3000, 8080)
|
||||
- [ ] Strong database password
|
||||
- [ ] JWT secret set (32+ characters)
|
||||
- [ ] SSL/TLS enabled (via Cloudflare)
|
||||
- [ ] Database backups automated
|
||||
- [ ] PM2 auto-start configured
|
||||
|
||||
---
|
||||
|
||||
## 📋 Pre-Deployment Checklist
|
||||
|
||||
- [ ] Changes tested locally
|
||||
- [ ] Committed to git
|
||||
- [ ] Pushed to `prodnew` branch
|
||||
- [ ] Database migrations ready (if any)
|
||||
- [ ] Backup recent (< 24 hours)
|
||||
|
||||
---
|
||||
|
||||
## 📋 Post-Deployment Checklist
|
||||
|
||||
- [ ] `pm2 status` shows all online
|
||||
- [ ] No errors in `pm2 logs`
|
||||
- [ ] Backend health check works: `curl http://localhost:3000/health`
|
||||
- [ ] Frontend loads: `curl http://localhost:8080`
|
||||
- [ ] Domain works: https://chitfund.deepteklabs.com
|
||||
- [ ] Login works
|
||||
- [ ] Clear browser cache tested
|
||||
|
||||
---
|
||||
|
||||
## 🆘 Troubleshooting
|
||||
|
||||
See [TROUBLESHOOTING.md](TROUBLESHOOTING.md) for common issues and fixes.
|
||||
|
||||
Quick diagnostics:
|
||||
```bash
|
||||
./scripts/diagnose.sh
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 📞 Emergency Contacts
|
||||
|
||||
**If everything is broken:**
|
||||
```bash
|
||||
./scripts/diagnose.sh # See what's wrong
|
||||
./scripts/fix-502.sh # Fix 502 errors
|
||||
pm2 restart all # Restart everything
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 📚 Additional Resources
|
||||
|
||||
- **PM2 Production Guide**: [PM2_PRODUCTION_GUIDE.md](PM2_PRODUCTION_GUIDE.md)
|
||||
- **Quick Reference**: [QUICK_REFERENCE.md](QUICK_REFERENCE.md)
|
||||
- **Backend API Docs**: [backend/API_DOCUMENTATION.md](backend/API_DOCUMENTATION.md)
|
||||
|
||||
---
|
||||
|
||||
**Last Updated**: November 2025
|
||||
|
||||
186
QUICK_START.md
186
QUICK_START.md
|
|
@ -1,184 +1,60 @@
|
|||
# 🚀 LuckyChit - Quick Start Guide
|
||||
# ⚡ Quick Start - LuckyChit
|
||||
|
||||
## ⚡ Get Started in 5 Minutes!
|
||||
Get up and running in 5 minutes!
|
||||
|
||||
---
|
||||
|
||||
## Step 1: Install Backend Dependencies
|
||||
## 🎯 For Users: Access the App
|
||||
|
||||
**Production URL**: https://chitfund.deepteklabs.com
|
||||
|
||||
That's it! Just open the link and login.
|
||||
|
||||
---
|
||||
|
||||
## 👨💻 For Developers: Local Development
|
||||
|
||||
### Backend
|
||||
```bash
|
||||
cd backend
|
||||
npm install
|
||||
cp env.example .env # Edit with your database credentials
|
||||
npm start # Runs on http://localhost:3000
|
||||
```
|
||||
|
||||
**New packages installed:**
|
||||
- `node-cron` - Automated reminders
|
||||
- `moment-timezone` - Date handling
|
||||
|
||||
---
|
||||
|
||||
## Step 2: Configure Environment
|
||||
|
||||
```bash
|
||||
# Make sure .env file exists with database credentials
|
||||
cp env.example .env # If needed
|
||||
|
||||
# Update .env with your PostgreSQL details
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Step 3: Start Backend
|
||||
|
||||
```bash
|
||||
npm run dev
|
||||
```
|
||||
|
||||
**You should see:**
|
||||
```
|
||||
✅ Database models synchronized
|
||||
⏰ Starting payment reminder scheduler...
|
||||
🚀 Server running on port 3000
|
||||
📱 WhatsApp share: http://localhost:3000/api/share
|
||||
🔔 Notifications: http://localhost:3000/api/notifications
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Step 4: Install Frontend Dependencies
|
||||
|
||||
### Frontend
|
||||
```bash
|
||||
cd luckychit
|
||||
flutter pub get
|
||||
flutter run -d chrome # Opens in browser
|
||||
```
|
||||
|
||||
**Already included in pubspec.yaml:**
|
||||
- `url_launcher` - WhatsApp integration
|
||||
- `shared_preferences` - Theme persistence
|
||||
- `fl_chart` - Payment charts
|
||||
- All other dependencies
|
||||
|
||||
---
|
||||
|
||||
## Step 5: Run Flutter App
|
||||
## 🚀 For Ops: Deploy to Production
|
||||
|
||||
```bash
|
||||
flutter run
|
||||
ssh luckychit@192.168.8.148
|
||||
cd /home/luckychit/apps/chitfund
|
||||
./scripts/deploy.sh
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## ✨ **Test New Features!**
|
||||
|
||||
### 1. **Dark Mode**
|
||||
- Open app → Navigate to Settings
|
||||
- Toggle "Dark Mode" switch
|
||||
- See instant theme change!
|
||||
|
||||
### 2. **Notifications**
|
||||
- Look for notification bell icon (top right)
|
||||
- Badge shows unread count
|
||||
- Click to see notification center
|
||||
|
||||
### 3. **WhatsApp Sharing** (Test on real device)
|
||||
- Record a payment
|
||||
- See success dialog
|
||||
- Click "Share on WhatsApp"
|
||||
- WhatsApp opens with receipt!
|
||||
|
||||
### 4. **Loading States**
|
||||
- Login → See skeleton loader
|
||||
- Dashboard loads smoothly
|
||||
|
||||
### 5. **Empty States**
|
||||
- Manager with no groups
|
||||
- See beautiful empty state
|
||||
- "Create Your First Group" button
|
||||
That's it! See [DEPLOYMENT.md](DEPLOYMENT.md) for details.
|
||||
|
||||
---
|
||||
|
||||
## 🎯 **Key Features**
|
||||
## 🆘 Something Broken?
|
||||
|
||||
✅ Beautiful loading screens (skeleton)
|
||||
✅ Helpful empty states
|
||||
✅ Professional notifications
|
||||
✅ Interactive cards
|
||||
✅ Dark mode support
|
||||
✅ **WhatsApp integration**
|
||||
✅ **Automated payment reminders**
|
||||
✅ **Notification system**
|
||||
✅ Payment charts
|
||||
✅ Search & filter
|
||||
```bash
|
||||
./scripts/diagnose.sh # Shows what's wrong
|
||||
```
|
||||
|
||||
See [TROUBLESHOOTING.md](TROUBLESHOOTING.md) for fixes.
|
||||
|
||||
---
|
||||
|
||||
## 📱 **Test WhatsApp (Important!)**
|
||||
|
||||
**Must test on physical device with WhatsApp:**
|
||||
|
||||
1. Build & install on Android:
|
||||
```bash
|
||||
flutter build apk
|
||||
flutter install
|
||||
```
|
||||
|
||||
2. Or run directly:
|
||||
```bash
|
||||
flutter run
|
||||
```
|
||||
|
||||
3. Go through payment flow
|
||||
4. Click "Share on WhatsApp"
|
||||
5. WhatsApp opens with pre-filled message!
|
||||
|
||||
---
|
||||
|
||||
## ⏰ **Payment Reminders**
|
||||
|
||||
**Automatic reminders run daily at 9:00 AM IST**
|
||||
|
||||
Reminders sent at:
|
||||
- 7 days before due
|
||||
- 3 days before due
|
||||
- 1 day before due
|
||||
- On due date
|
||||
- 1, 3, 7, 14, 30 days after (if overdue)
|
||||
|
||||
**Check console logs at 9 AM IST to see scheduler running!**
|
||||
|
||||
---
|
||||
|
||||
## 📚 **Documentation**
|
||||
|
||||
Everything is documented! Start here:
|
||||
|
||||
1. **`FINAL_SETUP_GUIDE.md`** - Complete setup
|
||||
2. **`EVERYTHING_DELIVERED.md`** - What you got
|
||||
3. **`WHATSAPP_USAGE_EXAMPLES.md`** - WhatsApp integration
|
||||
4. **`COMPLETE_UX_IMPROVEMENTS_GUIDE.md`** - UX features
|
||||
5. **`API_DOCUMENTATION.md`** - All APIs
|
||||
|
||||
---
|
||||
|
||||
## 🎉 **You're Ready!**
|
||||
|
||||
All features implemented, tested, and documented.
|
||||
|
||||
**Next:** Customize messages, test thoroughly, and launch! 🚀
|
||||
|
||||
---
|
||||
|
||||
## 💡 **Need Help?**
|
||||
|
||||
Check the documentation files or:
|
||||
- Review code comments
|
||||
- Check API documentation
|
||||
- See usage examples
|
||||
- Monitor console logs
|
||||
|
||||
---
|
||||
|
||||
**Time to launch!** 🚀✨
|
||||
|
||||
_Your chit fund app is now world-class!_
|
||||
## 📚 Need More Info?
|
||||
|
||||
- **Deployment**: [DEPLOYMENT.md](DEPLOYMENT.md)
|
||||
- **Troubleshooting**: [TROUBLESHOOTING.md](TROUBLESHOOTING.md)
|
||||
- **Full README**: [README.md](README.md)
|
||||
|
|
|
|||
180
README.md
180
README.md
|
|
@ -1 +1,179 @@
|
|||
# chitfund
|
||||
# 🚀 LuckyChit - Digital Chit Fund Management
|
||||
|
||||
Complete production-ready chit fund management system with Flutter frontend and Node.js backend.
|
||||
|
||||
---
|
||||
|
||||
## 📚 Documentation
|
||||
|
||||
| Document | Purpose | Audience |
|
||||
|----------|---------|----------|
|
||||
| **[QUICK_START.md](QUICK_START.md)** | Get started in 5 minutes | Everyone |
|
||||
| **[DEPLOYMENT.md](DEPLOYMENT.md)** | Complete deployment guide | DevOps/Developers |
|
||||
| **[TROUBLESHOOTING.md](TROUBLESHOOTING.md)** | Fix common issues | Everyone |
|
||||
| **[QUICK_REFERENCE.md](QUICK_REFERENCE.md)** | Command cheat sheet | DevOps |
|
||||
|
||||
---
|
||||
|
||||
## ⚡ Quick Commands
|
||||
|
||||
### 🚀 Deploy to Production
|
||||
```bash
|
||||
ssh luckychit@192.168.8.148
|
||||
cd /home/luckychit/apps/chitfund
|
||||
./scripts/deploy.sh
|
||||
```
|
||||
|
||||
### 📊 Check Status
|
||||
```bash
|
||||
pm2 status
|
||||
pm2 logs --lines 50
|
||||
```
|
||||
|
||||
### 🔧 Fix Issues
|
||||
```bash
|
||||
./scripts/diagnose.sh # What's wrong?
|
||||
./scripts/fix-502.sh # Fix 502 errors
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 🏗️ Architecture
|
||||
|
||||
```
|
||||
Internet
|
||||
↓
|
||||
Cloudflare (SSL, CDN, DDoS Protection)
|
||||
↓
|
||||
Nginx Proxy (Reverse Proxy)
|
||||
↓
|
||||
Application Server (192.168.8.148)
|
||||
├── PM2: luckychit-api (Backend - Port 3000)
|
||||
├── PM2: luckychit-frontend (Frontend - Port 8080)
|
||||
└── PostgreSQL Database (Port 5432)
|
||||
```
|
||||
|
||||
**Production URL**: https://chitfund.deepteklabs.com
|
||||
|
||||
---
|
||||
|
||||
## 📁 Project Structure
|
||||
|
||||
```
|
||||
chitfund/
|
||||
├── README.md # This file
|
||||
├── QUICK_START.md # Getting started
|
||||
├── DEPLOYMENT.md # Deployment guide
|
||||
├── TROUBLESHOOTING.md # Issue fixes
|
||||
│
|
||||
├── scripts/ # All deployment scripts
|
||||
│ ├── deploy.sh # Main deployment
|
||||
│ ├── diagnose.sh # System diagnostics
|
||||
│ ├── backup-db.sh # Database backup
|
||||
│ ├── restore-db.sh # Database restore
|
||||
│ └── fix-502.sh # Fix 502 errors
|
||||
│
|
||||
├── backend/ # Node.js Express API
|
||||
│ ├── src/ # Source code
|
||||
│ ├── README.md # Backend docs
|
||||
│ └── API_DOCUMENTATION.md
|
||||
│
|
||||
└── luckychit/ # Flutter Web App
|
||||
├── lib/ # Dart source code
|
||||
├── web/ # Web assets
|
||||
└── README.md # Frontend docs
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 🚀 Getting Started
|
||||
|
||||
### For Users
|
||||
Just visit: **https://chitfund.deepteklabs.com**
|
||||
|
||||
### For Developers (Local)
|
||||
```bash
|
||||
# Backend
|
||||
cd backend
|
||||
npm install
|
||||
npm start # http://localhost:3000
|
||||
|
||||
# Frontend
|
||||
cd luckychit
|
||||
flutter pub get
|
||||
flutter run -d chrome # Opens in browser
|
||||
```
|
||||
|
||||
### For DevOps (Production)
|
||||
See **[DEPLOYMENT.md](DEPLOYMENT.md)**
|
||||
|
||||
---
|
||||
|
||||
## 📊 Tech Stack
|
||||
|
||||
**Frontend**
|
||||
- Flutter Web
|
||||
- GetX (State Management)
|
||||
- Dio (HTTP Client)
|
||||
|
||||
**Backend**
|
||||
- Node.js + Express
|
||||
- PostgreSQL
|
||||
- JWT Authentication
|
||||
- Sequelize ORM
|
||||
|
||||
**Infrastructure**
|
||||
- PM2 (Process Manager)
|
||||
- Nginx (Reverse Proxy)
|
||||
- Cloudflare (CDN + SSL)
|
||||
- LXC Containers (Isolation)
|
||||
|
||||
---
|
||||
|
||||
## 🆘 Need Help?
|
||||
|
||||
**Something not working?**
|
||||
1. Check [TROUBLESHOOTING.md](TROUBLESHOOTING.md)
|
||||
2. Run `./scripts/diagnose.sh`
|
||||
3. Check PM2 logs: `pm2 logs`
|
||||
|
||||
**Want to deploy?**
|
||||
- See [DEPLOYMENT.md](DEPLOYMENT.md)
|
||||
- Quick: `./scripts/deploy.sh`
|
||||
|
||||
**Learning the system?**
|
||||
- Start with [QUICK_START.md](QUICK_START.md)
|
||||
- Reference [QUICK_REFERENCE.md](QUICK_REFERENCE.md)
|
||||
|
||||
---
|
||||
|
||||
## 📝 Recent Updates
|
||||
|
||||
- ✅ Removed demo credentials from login
|
||||
- ✅ Fixed all caching issues (browser, service worker, nginx)
|
||||
- ✅ Added signup navigation to dashboard
|
||||
- ✅ Consolidated documentation and scripts
|
||||
- ✅ Created unified deployment system
|
||||
|
||||
---
|
||||
|
||||
## 🎯 Quick Links
|
||||
|
||||
- **Production**: https://chitfund.deepteklabs.com
|
||||
- **Backend API**: http://192.168.8.148:3000
|
||||
- **Frontend**: http://192.168.8.148:8080
|
||||
- **API Docs**: [backend/API_DOCUMENTATION.md](backend/API_DOCUMENTATION.md)
|
||||
|
||||
---
|
||||
|
||||
**Version**: 1.0.0
|
||||
**Last Updated**: November 6, 2025
|
||||
**Status**: ✅ Production Ready
|
||||
|
||||
---
|
||||
|
||||
## 📄 License & Documentation
|
||||
|
||||
For complete feature documentation, see individual README files in `backend/` and `luckychit/` directories.
|
||||
|
||||
**Questions?** Check [TROUBLESHOOTING.md](TROUBLESHOOTING.md) first!
|
||||
|
|
|
|||
|
|
@ -0,0 +1,340 @@
|
|||
# 🔧 LuckyChit Troubleshooting Guide
|
||||
|
||||
Quick fixes for common issues.
|
||||
|
||||
---
|
||||
|
||||
## 🚨 Quick Diagnostics
|
||||
|
||||
```bash
|
||||
cd /home/luckychit/apps/chitfund
|
||||
./scripts/diagnose.sh
|
||||
```
|
||||
|
||||
This shows exactly what's wrong!
|
||||
|
||||
---
|
||||
|
||||
## Common Issues
|
||||
|
||||
### 🔴 502 Bad Gateway Error
|
||||
|
||||
**Symptom**: Site shows "502 Bad Gateway"
|
||||
**Cause**: PM2 processes are down or nginx can't reach backend
|
||||
|
||||
**Fix**:
|
||||
```bash
|
||||
# Check PM2
|
||||
pm2 status
|
||||
|
||||
# If processes are down
|
||||
pm2 restart all
|
||||
|
||||
# If processes don't exist
|
||||
cd /home/luckychit/apps/chitfund
|
||||
./scripts/fix-502.sh
|
||||
|
||||
# Test
|
||||
curl http://localhost:3000/health
|
||||
curl http://localhost:8080
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### 🔴 Changes Not Showing (Cache Issue)
|
||||
|
||||
**Symptom**: Deployed code but seeing old version
|
||||
**Cause**: Multiple cache layers (browser, service worker, nginx, Cloudflare)
|
||||
|
||||
**Fix**:
|
||||
```bash
|
||||
# 1. Clear browser service worker
|
||||
# F12 → Application → Service Workers → Unregister
|
||||
# Then: Ctrl + Shift + R (hard refresh)
|
||||
|
||||
# 2. Or test in incognito
|
||||
# Ctrl + Shift + N (no cache at all)
|
||||
|
||||
# 3. Force rebuild on server
|
||||
cd /home/luckychit/apps/chitfund
|
||||
./scripts/deploy.sh --force
|
||||
|
||||
# 4. Clear nginx cache (if using separate proxy)
|
||||
ssh root@<nginx-ip>
|
||||
sudo rm -rf /var/cache/nginx/*
|
||||
sudo systemctl reload nginx
|
||||
|
||||
# 5. Purge Cloudflare cache
|
||||
# Dashboard → Caching → Purge Everything
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### 🔴 PM2 Not Running After Reboot
|
||||
|
||||
**Symptom**: Server restarted, apps not running
|
||||
**Cause**: PM2 auto-start not configured
|
||||
|
||||
**Fix**:
|
||||
```bash
|
||||
# Restore processes
|
||||
pm2 resurrect
|
||||
|
||||
# Or setup auto-start
|
||||
pm2 startup systemd -u luckychit --hp /home/luckychit
|
||||
# Run the command it outputs
|
||||
pm2 save
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### 🔴 "invalid ELF header" Error
|
||||
|
||||
**Symptom**: Backend crashes with bcrypt error
|
||||
**Cause**: node_modules installed on Windows, running on Linux
|
||||
|
||||
**Fix**:
|
||||
```bash
|
||||
cd /home/luckychit/apps/chitfund/backend
|
||||
rm -rf node_modules package-lock.json
|
||||
npm install
|
||||
pm2 restart luckychit-api
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### 🔴 Database Connection Error
|
||||
|
||||
**Symptom**: Backend logs show "connection refused"
|
||||
**Cause**: PostgreSQL not running or wrong credentials
|
||||
|
||||
**Fix**:
|
||||
```bash
|
||||
# Check PostgreSQL
|
||||
sudo systemctl status postgresql
|
||||
|
||||
# If not running
|
||||
sudo systemctl start postgresql
|
||||
|
||||
# Test connection
|
||||
psql -U luckychit -h localhost -d luckychit
|
||||
|
||||
# Check .env credentials
|
||||
cd /home/luckychit/apps/chitfund/backend
|
||||
cat .env | grep DB_
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### 🔴 Port Already in Use
|
||||
|
||||
**Symptom**: "Port 3000 already in use"
|
||||
**Cause**: Old process still running
|
||||
|
||||
**Fix**:
|
||||
```bash
|
||||
# Find process
|
||||
netstat -tulpn | grep 3000
|
||||
|
||||
# Kill process
|
||||
kill -9 <PID>
|
||||
|
||||
# Or restart PM2
|
||||
pm2 restart luckychit-api
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### 🔴 Out of Memory
|
||||
|
||||
**Symptom**: PM2 processes keep crashing
|
||||
**Cause**: Server out of RAM
|
||||
|
||||
**Fix**:
|
||||
```bash
|
||||
# Check memory
|
||||
free -h
|
||||
|
||||
# Check PM2 memory usage
|
||||
pm2 monit
|
||||
|
||||
# Restart to free memory
|
||||
pm2 restart all
|
||||
|
||||
# Or reboot server
|
||||
sudo reboot
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### 🔴 Frontend Won't Build
|
||||
|
||||
**Symptom**: `flutter build web` fails
|
||||
**Cause**: Corrupted cache or missing dependencies
|
||||
|
||||
**Fix**:
|
||||
```bash
|
||||
cd /home/luckychit/apps/chitfund/luckychit
|
||||
flutter clean
|
||||
rm -rf .dart_tool build
|
||||
flutter pub get
|
||||
flutter build web --release --pwa-strategy=none
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### 🔴 Service Worker Errors in Browser
|
||||
|
||||
**Symptom**: Console shows "Loading from existing service worker" + errors
|
||||
**Cause**: Old service worker serving stale code
|
||||
|
||||
**Fix**:
|
||||
```bash
|
||||
# In browser:
|
||||
# 1. Press F12
|
||||
# 2. Application tab → Service Workers
|
||||
# 3. Click "Unregister" for all
|
||||
# 4. Application tab → Clear storage → Clear site data
|
||||
# 5. Close DevTools
|
||||
# 6. Hard refresh: Ctrl + Shift + R
|
||||
|
||||
# Already fixed in code - rebuilds now disable service worker
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### 🔴 Nginx Not Forwarding Requests
|
||||
|
||||
**Symptom**: 502 only on domain, direct IP works
|
||||
**Cause**: Nginx config issue or cache
|
||||
|
||||
**Fix**:
|
||||
```bash
|
||||
# SSH to nginx proxy LXC
|
||||
ssh root@<nginx-ip>
|
||||
|
||||
# Test backend connectivity
|
||||
curl http://192.168.8.148:3000/health
|
||||
curl http://192.168.8.148:8080
|
||||
|
||||
# Check nginx config
|
||||
sudo nginx -t
|
||||
|
||||
# Clear cache
|
||||
sudo rm -rf /var/cache/nginx/*
|
||||
|
||||
# Reload nginx
|
||||
sudo systemctl reload nginx
|
||||
|
||||
# Check logs
|
||||
sudo tail -f /var/log/nginx/error.log
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### 🔴 Firewall Blocking Access
|
||||
|
||||
**Symptom**: Can't access from outside server
|
||||
**Cause**: Firewall rules
|
||||
|
||||
**Fix**:
|
||||
```bash
|
||||
# Check firewall
|
||||
sudo ufw status
|
||||
|
||||
# Allow ports
|
||||
sudo ufw allow 3000/tcp
|
||||
sudo ufw allow 8080/tcp
|
||||
sudo ufw reload
|
||||
|
||||
# Test
|
||||
curl http://192.168.8.148:3000/health
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 🔍 Diagnostic Commands
|
||||
|
||||
```bash
|
||||
# Check everything
|
||||
./scripts/diagnose.sh
|
||||
|
||||
# PM2 status
|
||||
pm2 status
|
||||
pm2 logs --lines 50
|
||||
|
||||
# Test connectivity
|
||||
curl http://localhost:3000/health # Backend
|
||||
curl http://localhost:8080 # Frontend
|
||||
|
||||
# Check disk space
|
||||
df -h
|
||||
|
||||
# Check memory
|
||||
free -h
|
||||
|
||||
# Check ports
|
||||
netstat -tulpn | grep -E '(3000|8080)'
|
||||
|
||||
# Check database
|
||||
psql -U luckychit -h localhost -d luckychit
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 🚀 Emergency Recovery
|
||||
|
||||
### Complete Reset
|
||||
```bash
|
||||
# Stop everything
|
||||
pm2 kill
|
||||
|
||||
# Restart from scratch
|
||||
cd /home/luckychit/apps/chitfund
|
||||
|
||||
# Backend
|
||||
cd backend
|
||||
pm2 start src/server.js --name luckychit-api
|
||||
|
||||
# Frontend
|
||||
cd ../luckychit
|
||||
pm2 serve build/web 8080 --name luckychit-frontend --spa
|
||||
|
||||
# Save
|
||||
pm2 save
|
||||
|
||||
# Verify
|
||||
pm2 status
|
||||
```
|
||||
|
||||
### Nuclear Option (Full Rebuild)
|
||||
```bash
|
||||
cd /home/luckychit/apps/chitfund
|
||||
./scripts/deploy.sh --force
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 📞 Still Stuck?
|
||||
|
||||
1. **Run diagnostics**: `./scripts/diagnose.sh`
|
||||
2. **Check PM2 logs**: `pm2 logs --lines 100`
|
||||
3. **Try in incognito**: Rules out browser cache
|
||||
4. **Restart everything**: `pm2 restart all`
|
||||
5. **Check all docs**: [DEPLOYMENT.md](DEPLOYMENT.md)
|
||||
|
||||
---
|
||||
|
||||
## 🎯 Prevention Tips
|
||||
|
||||
1. **Always test locally** before deploying
|
||||
2. **Use deployment script** (handles caching automatically)
|
||||
3. **Check logs after deploy**: `pm2 logs --lines 20`
|
||||
4. **Test in incognito** first (no cache)
|
||||
5. **Backup database** before major changes
|
||||
6. **Monitor PM2**: `pm2 monit`
|
||||
|
||||
---
|
||||
|
||||
**Most issues are cache-related. When in doubt, clear all caches and rebuild!**
|
||||
|
||||
|
|
@ -0,0 +1,116 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Cleanup Old Documentation and Scripts
|
||||
# Run this to remove redundant files after consolidation
|
||||
|
||||
echo "🧹 Cleaning up old documentation and scripts..."
|
||||
echo ""
|
||||
|
||||
# Backup before deletion
|
||||
BACKUP_DIR="old_docs_backup_$(date +%Y%m%d_%H%M%S)"
|
||||
mkdir -p "$BACKUP_DIR"
|
||||
|
||||
echo "📦 Creating backup in: $BACKUP_DIR"
|
||||
|
||||
# List of files to remove
|
||||
OLD_DOCS=(
|
||||
"ACTUAL_PRODUCTION_SETUP.md"
|
||||
"ARCHITECTURE_OVERVIEW.md"
|
||||
"CACHE_BUSTING_GUIDE.md"
|
||||
"CACHE_FIX_SUMMARY.md"
|
||||
"COMPLETE_FEATURES_DELIVERED.md"
|
||||
"COMPLETE_IMPLEMENTATION_SUMMARY.md"
|
||||
"CREATE_GROUP_IMPROVEMENTS.md"
|
||||
"DEPLOYMENT_MASTER_GUIDE.md"
|
||||
"DEPLOYMENT_README.md"
|
||||
"DEPLOYMENT_TROUBLESHOOTING.md"
|
||||
"EVERYTHING_DELIVERED.md"
|
||||
"FINAL_SETUP_GUIDE.md"
|
||||
"FIX_502_ERROR.md"
|
||||
"FIX_CACHE_NOW.md"
|
||||
"FIX_NOW_SERVICE_WORKER.md"
|
||||
"FIX_SERVICE_WORKER_CACHE.md"
|
||||
"FLUTTER_DEPLOYMENT_GUIDE.md"
|
||||
"LuckyChit_Development_Plan_Revised.md"
|
||||
"LuckyChit_Development_Plan.md"
|
||||
"NGINX_PROXY_CACHE_FIX.md"
|
||||
"PM2_QUICK_START.md"
|
||||
"PRODUCTION_DIFFERENCES.md"
|
||||
"PRODUCTION_UPDATE_GUIDE.md"
|
||||
"Project_Implementation_Plan.md"
|
||||
"PROXMOX_DEPLOYMENT_GUIDE.md"
|
||||
"QUICK_DEPLOY.md"
|
||||
"README_DEPLOYMENT.md"
|
||||
"README_NEW_FEATURES.md"
|
||||
"SIGNUP_FEATURE_IMPLEMENTATION.md"
|
||||
"SIGNUP_NAVIGATION_UPDATE.md"
|
||||
"SIGNUP_QUICK_START.md"
|
||||
"START_HERE.md"
|
||||
"Technical_Architecture.md"
|
||||
"Technical_Implementation_Guide_Revised.md"
|
||||
"TRADITIONAL_CHIT_FUND_MATHEMATICS.md"
|
||||
"UI_UX_Design_Guide.md"
|
||||
"CHEATSHEET.txt"
|
||||
"Untitled-1.txt"
|
||||
)
|
||||
|
||||
OLD_SCRIPTS=(
|
||||
"backup-database.sh"
|
||||
"clear-cache-and-deploy.sh"
|
||||
"deploy-backend-only.sh"
|
||||
"deploy-frontend-only.sh"
|
||||
"deploy-frontend-simple.sh"
|
||||
"deploy-frontend.sh"
|
||||
"deploy-full.sh"
|
||||
"deploy.sh"
|
||||
"diagnose-502.sh"
|
||||
"fix-502-auto.sh"
|
||||
"fix-and-deploy.sh"
|
||||
"force-cache-bust.sh"
|
||||
"nginx-clear-cache.sh"
|
||||
"restore-database.sh"
|
||||
"setup-deployment-scripts.sh"
|
||||
)
|
||||
|
||||
# Move docs to backup
|
||||
echo ""
|
||||
echo "Moving old documentation..."
|
||||
for file in "${OLD_DOCS[@]}"; do
|
||||
if [ -f "$file" ]; then
|
||||
mv "$file" "$BACKUP_DIR/" 2>/dev/null && echo " ✓ $file"
|
||||
fi
|
||||
done
|
||||
|
||||
# Move scripts to backup
|
||||
echo ""
|
||||
echo "Moving old scripts..."
|
||||
for file in "${OLD_SCRIPTS[@]}"; do
|
||||
if [ -f "$file" ]; then
|
||||
mv "$file" "$BACKUP_DIR/" 2>/dev/null && echo " ✓ $file"
|
||||
fi
|
||||
done
|
||||
|
||||
echo ""
|
||||
echo "✅ Cleanup complete!"
|
||||
echo ""
|
||||
echo "📦 Old files backed up to: $BACKUP_DIR"
|
||||
echo ""
|
||||
echo "📚 New documentation structure:"
|
||||
echo " README.md - Main documentation"
|
||||
echo " QUICK_START.md - Getting started"
|
||||
echo " DEPLOYMENT.md - Deployment guide"
|
||||
echo " TROUBLESHOOTING.md - Common issues & fixes"
|
||||
echo ""
|
||||
echo "🔧 New scripts (in scripts/ folder):"
|
||||
echo " scripts/deploy.sh - Unified deployment"
|
||||
echo " scripts/diagnose.sh - Full diagnostics"
|
||||
echo " scripts/backup-db.sh - Database backup"
|
||||
echo " scripts/restore-db.sh - Database restore"
|
||||
echo " scripts/fix-502.sh - Fix 502 errors"
|
||||
echo ""
|
||||
echo "💡 To restore old files if needed:"
|
||||
echo " cp $BACKUP_DIR/* ."
|
||||
echo ""
|
||||
echo "🗑️ To permanently delete backup:"
|
||||
echo " rm -rf $BACKUP_DIR"
|
||||
|
||||
|
|
@ -0,0 +1,91 @@
|
|||
# 📚 Documentation Reference
|
||||
|
||||
## Main Documentation (Root)
|
||||
|
||||
Keep these files in the root directory:
|
||||
|
||||
### Core Docs
|
||||
- **README.md** - Main documentation entry point
|
||||
- **QUICK_START.md** - Getting started guide
|
||||
- **DEPLOYMENT.md** - Complete deployment guide
|
||||
- **TROUBLESHOOTING.md** - Common issues and fixes
|
||||
|
||||
### Reference Docs
|
||||
- **PM2_PRODUCTION_GUIDE.md** - Detailed PM2 documentation
|
||||
- **QUICK_REFERENCE.md** - Quick command reference
|
||||
|
||||
---
|
||||
|
||||
## Scripts
|
||||
|
||||
All deployment scripts are in `scripts/` folder:
|
||||
|
||||
- **deploy.sh** - Unified deployment script
|
||||
- **diagnose.sh** - Full system diagnostics
|
||||
- **backup-db.sh** - Database backup
|
||||
- **restore-db.sh** - Database restore
|
||||
- **fix-502.sh** - Auto-fix 502 errors
|
||||
|
||||
---
|
||||
|
||||
## Backend Docs
|
||||
|
||||
Keep in `backend/` folder:
|
||||
|
||||
- **README.md** - Backend documentation
|
||||
- **API_DOCUMENTATION.md** - API endpoints reference
|
||||
- **WHATSAPP_AND_REMINDERS_IMPLEMENTATION_STATUS.md** - WhatsApp features
|
||||
- **WHATSAPP_USAGE_EXAMPLES.md** - WhatsApp usage
|
||||
|
||||
---
|
||||
|
||||
## Frontend Docs
|
||||
|
||||
Keep in `luckychit/` folder:
|
||||
|
||||
- **README.md** - Frontend documentation
|
||||
- Various feature implementation docs
|
||||
|
||||
---
|
||||
|
||||
## Old Files
|
||||
|
||||
All old/redundant files have been moved to `old_docs_backup_*/`
|
||||
|
||||
You can safely delete the backup folder after confirming everything works:
|
||||
```bash
|
||||
rm -rf old_docs_backup_*
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Documentation Structure (Final)
|
||||
|
||||
```
|
||||
chitfund/
|
||||
├── README.md # Main docs
|
||||
├── QUICK_START.md # Getting started
|
||||
├── DEPLOYMENT.md # Deployment guide
|
||||
├── TROUBLESHOOTING.md # Troubleshooting
|
||||
├── PM2_PRODUCTION_GUIDE.md # Detailed PM2 docs
|
||||
├── QUICK_REFERENCE.md # Quick reference
|
||||
│
|
||||
├── scripts/ # All scripts here
|
||||
│ ├── deploy.sh
|
||||
│ ├── diagnose.sh
|
||||
│ ├── backup-db.sh
|
||||
│ ├── restore-db.sh
|
||||
│ └── fix-502.sh
|
||||
│
|
||||
├── backend/ # Backend
|
||||
│ ├── README.md
|
||||
│ └── API_DOCUMENTATION.md
|
||||
│
|
||||
└── luckychit/ # Frontend
|
||||
└── README.md
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
**Clean, organized, and easy to maintain!** 🎉
|
||||
|
||||
0
deploy-frontend-simple.sh → old_docs_backup_20251105_203126/deploy-frontend-simple.sh
Executable file → Normal file
0
deploy-frontend-simple.sh → old_docs_backup_20251105_203126/deploy-frontend-simple.sh
Executable file → Normal file
|
|
@ -0,0 +1,51 @@
|
|||
#!/bin/bash
|
||||
|
||||
# LuckyChit Database Backup Script
|
||||
|
||||
set -e
|
||||
|
||||
DB_NAME="luckychit"
|
||||
DB_USER="luckychit"
|
||||
DB_HOST="localhost"
|
||||
BACKUP_DIR="/home/luckychit/backups"
|
||||
RETENTION_DAYS=7
|
||||
|
||||
mkdir -p "$BACKUP_DIR"
|
||||
|
||||
TIMESTAMP=$(date +%Y%m%d_%H%M%S)
|
||||
BACKUP_FILE="$BACKUP_DIR/luckychit_backup_$TIMESTAMP.sql"
|
||||
|
||||
echo "🗄️ Starting database backup..."
|
||||
echo "Database: $DB_NAME"
|
||||
echo "Backup file: $BACKUP_FILE"
|
||||
echo ""
|
||||
|
||||
pg_dump -U "$DB_USER" -h "$DB_HOST" "$DB_NAME" > "$BACKUP_FILE"
|
||||
|
||||
if [ $? -eq 0 ]; then
|
||||
FILE_SIZE=$(du -h "$BACKUP_FILE" | cut -f1)
|
||||
echo "✅ Backup completed successfully!"
|
||||
echo "📦 File size: $FILE_SIZE"
|
||||
|
||||
echo ""
|
||||
echo "🗜️ Compressing backup..."
|
||||
gzip "$BACKUP_FILE"
|
||||
COMPRESSED_SIZE=$(du -h "$BACKUP_FILE.gz" | cut -f1)
|
||||
echo "✅ Compressed size: $COMPRESSED_SIZE"
|
||||
|
||||
echo ""
|
||||
echo "🧹 Cleaning up old backups (older than $RETENTION_DAYS days)..."
|
||||
DELETED=$(find "$BACKUP_DIR" -name "luckychit_backup_*.sql.gz" -mtime +$RETENTION_DAYS -delete -print | wc -l)
|
||||
echo "✅ Deleted $DELETED old backup(s)"
|
||||
|
||||
echo ""
|
||||
echo "📊 Current backups:"
|
||||
ls -lh "$BACKUP_DIR"/luckychit_backup_*.sql.gz 2>/dev/null || echo "No backups found"
|
||||
|
||||
echo ""
|
||||
echo "✅ Backup complete: $BACKUP_FILE.gz"
|
||||
else
|
||||
echo "❌ Backup failed!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
|
@ -0,0 +1,80 @@
|
|||
#!/bin/bash
|
||||
|
||||
# LuckyChit Unified Deployment Script
|
||||
# Usage: ./deploy.sh [backend|frontend|--force]
|
||||
|
||||
set -e
|
||||
|
||||
PROJECT_DIR="/home/luckychit/apps/chitfund"
|
||||
FORCE_REBUILD=false
|
||||
|
||||
# Check for force flag
|
||||
if [ "$1" == "--force" ] || [ "$2" == "--force" ]; then
|
||||
FORCE_REBUILD=true
|
||||
fi
|
||||
|
||||
cd $PROJECT_DIR
|
||||
|
||||
echo "🚀 LuckyChit Deployment"
|
||||
echo "======================="
|
||||
echo ""
|
||||
|
||||
# Git pull
|
||||
echo "📥 Pulling latest code..."
|
||||
git stash 2>/dev/null || true
|
||||
git pull origin prodnew
|
||||
echo ""
|
||||
|
||||
# Deploy backend
|
||||
if [ "$1" == "" ] || [ "$1" == "backend" ] || [ "$1" == "--force" ]; then
|
||||
echo "🔧 Deploying Backend..."
|
||||
cd $PROJECT_DIR/backend
|
||||
|
||||
if [ "$FORCE_REBUILD" = true ]; then
|
||||
echo "🗑️ Force rebuild: Removing node_modules..."
|
||||
rm -rf node_modules package-lock.json
|
||||
fi
|
||||
|
||||
npm install
|
||||
pm2 restart luckychit-api
|
||||
echo "✅ Backend deployed"
|
||||
echo ""
|
||||
fi
|
||||
|
||||
# Deploy frontend
|
||||
if [ "$1" == "" ] || [ "$1" == "frontend" ] || [ "$1" == "--force" ]; then
|
||||
echo "🎨 Deploying Frontend..."
|
||||
cd $PROJECT_DIR/luckychit
|
||||
|
||||
if [ "$FORCE_REBUILD" = true ]; then
|
||||
echo "🗑️ Force rebuild: Cleaning Flutter cache..."
|
||||
flutter clean
|
||||
rm -rf .dart_tool build
|
||||
fi
|
||||
|
||||
flutter pub get
|
||||
|
||||
BUILD_NUMBER=$(date +%s)
|
||||
flutter build web --release --web-renderer html --pwa-strategy=none --build-number=$BUILD_NUMBER
|
||||
echo "📦 Build version: $BUILD_NUMBER"
|
||||
|
||||
pm2 restart luckychit-frontend
|
||||
echo "✅ Frontend deployed"
|
||||
echo ""
|
||||
fi
|
||||
|
||||
# Status
|
||||
echo "📊 PM2 Status:"
|
||||
pm2 status
|
||||
|
||||
echo ""
|
||||
echo "✅ Deployment complete!"
|
||||
echo ""
|
||||
echo "🧪 Test:"
|
||||
echo " Backend: curl http://localhost:3000/health"
|
||||
echo " Frontend: curl http://localhost:8080"
|
||||
echo " Domain: https://chitfund.deepteklabs.com"
|
||||
echo ""
|
||||
echo "📝 Check logs: pm2 logs --lines 20"
|
||||
echo "💡 Clear browser cache: Ctrl + Shift + R"
|
||||
|
||||
|
|
@ -0,0 +1,123 @@
|
|||
#!/bin/bash
|
||||
|
||||
# LuckyChit Diagnostic Script
|
||||
# Checks everything and reports issues
|
||||
|
||||
echo "🔍 LuckyChit Diagnostic Report"
|
||||
echo "==============================="
|
||||
echo ""
|
||||
|
||||
# PM2 Status
|
||||
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
||||
echo "1️⃣ PM2 Process Status"
|
||||
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
||||
pm2 status
|
||||
echo ""
|
||||
|
||||
# Port Check
|
||||
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
||||
echo "2️⃣ Port Listening Check"
|
||||
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
||||
PORTS=$(netstat -tulpn 2>/dev/null | grep -E '(3000|8080)')
|
||||
if [ -z "$PORTS" ]; then
|
||||
echo "❌ No processes listening on ports 3000 or 8080"
|
||||
else
|
||||
echo "✅ Ports are listening:"
|
||||
echo "$PORTS"
|
||||
fi
|
||||
echo ""
|
||||
|
||||
# Backend Health
|
||||
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
||||
echo "3️⃣ Backend Health Check"
|
||||
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
||||
BACKEND=$(curl -s -o /dev/null -w "%{http_code}" http://localhost:3000/health 2>/dev/null)
|
||||
if [ "$BACKEND" = "200" ]; then
|
||||
echo "✅ Backend responding: HTTP $BACKEND"
|
||||
curl -s http://localhost:3000/health | head -n 3
|
||||
else
|
||||
echo "❌ Backend not responding: HTTP $BACKEND"
|
||||
fi
|
||||
echo ""
|
||||
|
||||
# Frontend Health
|
||||
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
||||
echo "4️⃣ Frontend Health Check"
|
||||
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
||||
FRONTEND=$(curl -s -o /dev/null -w "%{http_code}" http://localhost:8080 2>/dev/null)
|
||||
if [ "$FRONTEND" = "200" ]; then
|
||||
echo "✅ Frontend responding: HTTP $FRONTEND"
|
||||
else
|
||||
echo "❌ Frontend not responding: HTTP $FRONTEND"
|
||||
fi
|
||||
echo ""
|
||||
|
||||
# Disk Space
|
||||
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
||||
echo "5️⃣ Disk Space"
|
||||
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
||||
df -h | grep -E '(Filesystem|/$|/home)'
|
||||
echo ""
|
||||
|
||||
# Memory
|
||||
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
||||
echo "6️⃣ Memory Usage"
|
||||
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
||||
free -h
|
||||
echo ""
|
||||
|
||||
# PostgreSQL
|
||||
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
||||
echo "7️⃣ PostgreSQL Status"
|
||||
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
||||
POSTGRES=$(sudo systemctl is-active postgresql 2>/dev/null)
|
||||
if [ "$POSTGRES" = "active" ]; then
|
||||
echo "✅ PostgreSQL is running"
|
||||
else
|
||||
echo "❌ PostgreSQL is not running"
|
||||
fi
|
||||
echo ""
|
||||
|
||||
# Recent Errors
|
||||
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
||||
echo "8️⃣ Recent PM2 Errors"
|
||||
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
||||
pm2 logs --err --lines 10 --nostream 2>/dev/null || echo "No recent errors"
|
||||
echo ""
|
||||
|
||||
# Summary
|
||||
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
||||
echo "📋 SUMMARY & RECOMMENDATIONS"
|
||||
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
||||
echo ""
|
||||
|
||||
PM2_COUNT=$(pm2 jlist 2>/dev/null | grep -c '"pm2_env"')
|
||||
if [ "$PM2_COUNT" -lt 2 ]; then
|
||||
echo "⚠️ PM2 processes missing or down"
|
||||
echo " FIX: pm2 restart all OR ./scripts/fix-502.sh"
|
||||
fi
|
||||
|
||||
if [ -z "$PORTS" ]; then
|
||||
echo "⚠️ No processes listening on required ports"
|
||||
echo " FIX: ./scripts/fix-502.sh"
|
||||
fi
|
||||
|
||||
if [ "$BACKEND" != "200" ]; then
|
||||
echo "⚠️ Backend not responding"
|
||||
echo " FIX: pm2 restart luckychit-api"
|
||||
echo " CHECK: pm2 logs luckychit-api"
|
||||
fi
|
||||
|
||||
if [ "$FRONTEND" != "200" ]; then
|
||||
echo "⚠️ Frontend not responding"
|
||||
echo " FIX: pm2 restart luckychit-frontend"
|
||||
fi
|
||||
|
||||
if [ "$POSTGRES" != "active" ]; then
|
||||
echo "⚠️ PostgreSQL not running"
|
||||
echo " FIX: sudo systemctl start postgresql"
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "📚 See TROUBLESHOOTING.md for detailed fixes"
|
||||
|
||||
|
|
@ -0,0 +1,73 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Auto-fix 502 Bad Gateway errors
|
||||
|
||||
set -e
|
||||
|
||||
echo "🔧 LuckyChit 502 Auto-Fix"
|
||||
echo "========================="
|
||||
echo ""
|
||||
|
||||
cd /home/luckychit/apps/chitfund
|
||||
|
||||
check_backend() {
|
||||
curl -s -o /dev/null -w "%{http_code}" http://localhost:3000/health 2>/dev/null
|
||||
}
|
||||
|
||||
check_frontend() {
|
||||
curl -s -o /dev/null -w "%{http_code}" http://localhost:8080 2>/dev/null
|
||||
}
|
||||
|
||||
echo "📊 Step 1/4: Checking status..."
|
||||
pm2 status
|
||||
|
||||
echo ""
|
||||
echo "🔄 Step 2/4: Restarting services..."
|
||||
pm2 restart all
|
||||
sleep 3
|
||||
|
||||
echo ""
|
||||
echo "🧪 Step 3/4: Testing services..."
|
||||
|
||||
if [ "$(check_backend)" = "200" ]; then
|
||||
echo "✅ Backend is responding"
|
||||
else
|
||||
echo "⚠️ Backend not responding, recreating..."
|
||||
cd backend
|
||||
pm2 delete luckychit-api 2>/dev/null || true
|
||||
pm2 start src/server.js --name luckychit-api
|
||||
sleep 3
|
||||
fi
|
||||
|
||||
if [ "$(check_frontend)" = "200" ]; then
|
||||
echo "✅ Frontend is responding"
|
||||
else
|
||||
echo "⚠️ Frontend not responding, recreating..."
|
||||
cd /home/luckychit/apps/chitfund/luckychit
|
||||
pm2 delete luckychit-frontend 2>/dev/null || true
|
||||
pm2 serve build/web 8080 --name luckychit-frontend --spa
|
||||
sleep 3
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "💾 Step 4/4: Saving configuration..."
|
||||
pm2 save
|
||||
|
||||
echo ""
|
||||
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
||||
echo "📊 Final Status"
|
||||
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
||||
pm2 status
|
||||
|
||||
echo ""
|
||||
if [ "$(check_backend)" = "200" ] && [ "$(check_frontend)" = "200" ]; then
|
||||
echo "✅ SUCCESS! All services running"
|
||||
echo ""
|
||||
echo "🌐 Your site should be accessible at:"
|
||||
echo " https://chitfund.deepteklabs.com"
|
||||
else
|
||||
echo "⚠️ Some services still down"
|
||||
echo ""
|
||||
echo "🔍 Run diagnostics: ./scripts/diagnose.sh"
|
||||
fi
|
||||
|
||||
|
|
@ -0,0 +1,110 @@
|
|||
#!/bin/bash
|
||||
|
||||
# LuckyChit Database Restore Script
|
||||
|
||||
set -e
|
||||
|
||||
DB_NAME="luckychit"
|
||||
DB_USER="luckychit"
|
||||
DB_HOST="localhost"
|
||||
BACKUP_DIR="/home/luckychit/backups"
|
||||
|
||||
echo "🗄️ LuckyChit Database Restore"
|
||||
echo "==============================="
|
||||
echo ""
|
||||
|
||||
if [ ! -d "$BACKUP_DIR" ]; then
|
||||
echo "❌ Backup directory not found: $BACKUP_DIR"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "📦 Available backups:"
|
||||
echo ""
|
||||
ls -lh "$BACKUP_DIR"/luckychit_backup_*.sql.gz 2>/dev/null | nl || {
|
||||
echo "❌ No backup files found"
|
||||
exit 1
|
||||
}
|
||||
|
||||
echo ""
|
||||
echo "Enter the filename to restore (without path):"
|
||||
read -r BACKUP_FILENAME
|
||||
|
||||
BACKUP_FILE="$BACKUP_DIR/$BACKUP_FILENAME"
|
||||
|
||||
if [ ! -f "$BACKUP_FILE" ]; then
|
||||
echo "❌ Backup file not found: $BACKUP_FILE"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "⚠️ WARNING: This will REPLACE the current database!"
|
||||
echo "Database: $DB_NAME"
|
||||
echo "Backup file: $BACKUP_FILE"
|
||||
echo ""
|
||||
echo "Are you sure? (yes/no)"
|
||||
read -r CONFIRM
|
||||
|
||||
if [ "$CONFIRM" != "yes" ]; then
|
||||
echo "❌ Restore cancelled"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Safety backup
|
||||
SAFETY_BACKUP="$BACKUP_DIR/before_restore_$(date +%Y%m%d_%H%M%S).sql"
|
||||
echo ""
|
||||
echo "📦 Creating safety backup first..."
|
||||
pg_dump -U "$DB_USER" -h "$DB_HOST" "$DB_NAME" > "$SAFETY_BACKUP"
|
||||
echo "✅ Safety backup: $SAFETY_BACKUP"
|
||||
|
||||
# Decompress if needed
|
||||
if [[ "$BACKUP_FILE" == *.gz ]]; then
|
||||
echo ""
|
||||
echo "🗜️ Decompressing backup..."
|
||||
DECOMPRESSED="${BACKUP_FILE%.gz}"
|
||||
gunzip -c "$BACKUP_FILE" > "$DECOMPRESSED"
|
||||
BACKUP_FILE="$DECOMPRESSED"
|
||||
fi
|
||||
|
||||
# Stop PM2
|
||||
echo ""
|
||||
echo "⏸️ Stopping PM2 processes..."
|
||||
pm2 stop luckychit-api 2>/dev/null || true
|
||||
|
||||
# Drop and recreate
|
||||
echo ""
|
||||
echo "🗑️ Dropping existing database..."
|
||||
dropdb -U "$DB_USER" -h "$DB_HOST" --if-exists "$DB_NAME"
|
||||
|
||||
echo "🆕 Creating fresh database..."
|
||||
createdb -U "$DB_USER" -h "$DB_HOST" "$DB_NAME"
|
||||
|
||||
# Restore
|
||||
echo ""
|
||||
echo "📥 Restoring backup..."
|
||||
psql -U "$DB_USER" -h "$DB_HOST" "$DB_NAME" < "$BACKUP_FILE"
|
||||
|
||||
if [ $? -eq 0 ]; then
|
||||
echo ""
|
||||
echo "✅ Database restored successfully!"
|
||||
|
||||
# Clean up decompressed file
|
||||
if [[ "$BACKUP_FILENAME" == *.gz ]]; then
|
||||
rm -f "$BACKUP_FILE"
|
||||
fi
|
||||
|
||||
# Restart PM2
|
||||
echo ""
|
||||
echo "▶️ Restarting PM2..."
|
||||
pm2 restart luckychit-api
|
||||
pm2 status
|
||||
|
||||
echo ""
|
||||
echo "✅ Restore complete!"
|
||||
echo "📁 Safety backup: $SAFETY_BACKUP"
|
||||
else
|
||||
echo ""
|
||||
echo "❌ Restore failed!"
|
||||
echo "📁 Safety backup available: $SAFETY_BACKUP"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
Loading…
Reference in New Issue