chitfund/backend
Deep Koluguri 9a40854884 Add Dockerfiles and Gitea CI workflow 2026-05-11 15:29:09 -04:00
..
data update the look and feel and added sqilte 2026-04-05 12:48:16 -04:00
migrations update the look and feel and added sqilte 2026-04-05 12:48:16 -04:00
public auth token fix 2025-11-10 18:34:48 -05:00
scripts fixed 2026-04-05 16:01:36 -04:00
src update draw 2026-05-04 23:02:52 -04:00
.env update the look and feel and added sqilte 2026-04-05 12:48:16 -04:00
.env.example fixing link issues 2026-04-05 16:38:37 -04:00
.env.prod added UPI 2025-11-10 11:25:17 -05:00
.gitignore git ignore 2025-11-05 21:46:41 -05:00
API_DOCUMENTATION.md cleanup 2025-11-06 21:45:24 -05:00
DEBUG_AUTH_ISSUE.md update the look and feel and added sqilte 2026-04-05 12:48:16 -04:00
Dockerfile Add Dockerfiles and Gitea CI workflow 2026-05-11 15:29:09 -04:00
README.md cleanup 2025-11-06 21:45:24 -05:00
SETUP_PERSONAL_UPI.md update the look and feel and added sqilte 2026-04-05 12:48:16 -04:00
TROUBLESHOOTING.md cleanup 2025-11-06 21:45:24 -05:00
WHATSAPP_AND_REMINDERS_IMPLEMENTATION_STATUS.md Initial commit 2025-11-05 00:37:09 -05:00
WHATSAPP_USAGE_EXAMPLES.md Initial commit 2025-11-05 00:37:09 -05:00
create-db.js testing new cahnges for db 2025-11-05 10:19:24 -05:00
create-test-user.js Prod 2025-11-05 21:48:30 +00:00
deploy.sh fixed flutter theme issues 2025-11-05 18:19:04 -05:00
ecosystem.config.js cache issue fix 2025-11-05 19:15:26 -05:00
env.example Initial commit 2025-11-05 00:37:09 -05:00
fix-bcrypt.sh fixed flutter theme issues 2025-11-05 18:19:04 -05:00
migrate-commission-field.js Initial commit 2025-11-05 00:37:09 -05:00
package-lock.json update the look and feel and added sqilte 2026-04-05 12:48:16 -04:00
package.json update the look and feel and added sqilte 2026-04-05 12:48:16 -04:00
run-member-number-migration.js run db migration 2025-11-06 14:30:01 -05:00
setup-and-test.bat Initial commit 2025-11-05 00:37:09 -05:00
setup-and-test.sh Initial commit 2025-11-05 00:37:09 -05:00
setup-personal-upi.bat added UPI 2025-11-10 11:25:17 -05:00
simple-test.js Initial commit 2025-11-05 00:37:09 -05:00
test-api.js Initial commit 2025-11-05 00:37:09 -05:00
test-available-users.js Initial commit 2025-11-05 00:37:09 -05:00
test-db-connection.js Initial commit 2025-11-05 00:37:09 -05:00
test-db.js Initial commit 2025-11-05 00:37:09 -05:00
test-signup.js added sign up 2025-11-05 17:25:26 -05:00
test-upi-config.js added UPI 2025-11-10 11:25:17 -05:00

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


🎯 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