|
|
||
|---|---|---|
| .. | ||
| data | ||
| migrations | ||
| public | ||
| scripts | ||
| src | ||
| .env | ||
| .env.example | ||
| .env.prod | ||
| .gitignore | ||
| API_DOCUMENTATION.md | ||
| DEBUG_AUTH_ISSUE.md | ||
| Dockerfile | ||
| README.md | ||
| SETUP_PERSONAL_UPI.md | ||
| TROUBLESHOOTING.md | ||
| WHATSAPP_AND_REMINDERS_IMPLEMENTATION_STATUS.md | ||
| WHATSAPP_USAGE_EXAMPLES.md | ||
| create-db.js | ||
| create-test-user.js | ||
| deploy.sh | ||
| ecosystem.config.js | ||
| env.example | ||
| fix-bcrypt.sh | ||
| migrate-commission-field.js | ||
| package-lock.json | ||
| package.json | ||
| run-member-number-migration.js | ||
| setup-and-test.bat | ||
| setup-and-test.sh | ||
| setup-personal-upi.bat | ||
| simple-test.js | ||
| test-api.js | ||
| test-available-users.js | ||
| test-db-connection.js | ||
| test-db.js | ||
| test-signup.js | ||
| test-upi-config.js | ||
README.md
LuckyChit Backend
Node.js + Express + PostgreSQL backend for chit fund management.
🚀 Quick Setup
# Install dependencies
npm install
# Configure environment
cp env.example .env
nano .env
# Setup database
sudo -u postgres psql
CREATE DATABASE luckychit;
\q
# Run migration
node run-member-number-migration.js
# Start server
npm start
# or with PM2
pm2 start ecosystem.config.js
📁 Structure
backend/
├── src/
│ ├── controllers/ # Request handlers
│ ├── models/ # Database models
│ ├── routes/ # API routes
│ ├── middleware/ # Auth, validation
│ ├── services/ # Background jobs
│ ├── config/ # Configuration
│ └── utils/ # Helper functions
│
├── migrations/ # Database migrations
├── *.js # Utility scripts
└── *.md # Documentation
🔌 API Endpoints
See API_DOCUMENTATION.md for complete reference.
Base URL: http://localhost:3000/api
Quick Reference
- Auth:
/api/auth/* - Groups:
/api/chit-groups/* - Members:
/api/members/* - Draws:
/api/monthly-draws/* - Payments:
/api/payments/*
💾 Database
Models
- User - User accounts (with email, address, emergency contact)
- ChitGroup - Chit fund groups
- GroupMember - Relationships (with member_number)
- MonthlyDraw - Draw results
- Payment - Payment records
- Notification - Notification log
Migrations
Member Number Migration:
node run-member-number-migration.js
This adds member_number field (1, 2, 3...) to all members.
🧪 Testing
# Test database connection
node test-db-connection.js
# Test API
node test-api.js
# Create test user
node create-test-user.js
🔧 Common Commands
# Development
npm start # Start dev server
npm run dev # Watch mode (if configured)
# Production
pm2 start ecosystem.config.js
pm2 restart chitfund-backend
pm2 logs chitfund-backend
pm2 status
# Database
node run-member-number-migration.js
sudo -u postgres psql -d luckychit
📊 Environment Variables
# Database
DB_HOST=localhost
DB_PORT=5432
DB_NAME=luckychit
DB_USER=luckychit
DB_PASSWORD=your_password
# JWT
JWT_SECRET=your_secret_key
JWT_EXPIRY=7d
# Server
PORT=3000
NODE_ENV=production
🆘 Troubleshooting
See TROUBLESHOOTING.md for solutions to common issues:
- Module not found
- PostgreSQL authentication
- Migration errors
- Connection issues
📚 Documentation
- API_DOCUMENTATION.md - Complete API reference
- TROUBLESHOOTING.md - Fix common issues
- WHATSAPP_USAGE_EXAMPLES.md - WhatsApp integration
🎯 Latest Updates
Version 2.0 (November 2025):
- ✅ Member numbers (#1, #2, #3...)
- ✅ Admin edit/delete features
- ✅ Enhanced error messages
- ✅ Bug fixes
See ../CHANGELOG.md for full history.
Status: Production Ready ✅