Backend for Zenith: A comprehensive personal growth platform where users complete daily challenges across multiple categories, get AI-powered coaching, track progress with streaks and leaderboards, and redeem earned points for real cash rewards via automated UPI payouts.
Frontend Repository: zenith-frontend
- Node.js + TypeScript + Express
- PostgreSQL + Prisma ORM
- Razorpay (Payments)
- Google Gemini (AI Chat)
- Redis (Caching)
- Install dependencies:
npm install- Configure environment variables in
.env:
DATABASE_URL="postgresql://user:password@localhost:5432/zenith"
PORT=3000
JWT_SECRET=your-jwt-secret
RAZORPAY_API_URL=https://api.razorpay.com/v1
RAZORPAY_API_KEY=your-key
RAZORPAY_API_SECRET=your-secret
RAZORPAY_MERCHANT_ACCOUNT_NUMBER=your-account-number
RAZORPAY_WEBHOOK_SECRET=your-webhook-secret
GEMINI_API_KEY=your-gemini-key
REDIS_HOST=localhost
REDIS_PORT=6379- Run migrations and start server:
npx prisma migrate dev
npx prisma generate
npm run devcurl -X POST 'http://localhost:3000/reward' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer YOUR_TOKEN' \
-d '{
"pointsRewarded": 3000,
"amount": 20000,
"vpaAddress": "user@upi",
"rewardType": "CASHBACK"
}'curl -X GET 'http://localhost:3000/reward/history' \
-H 'Authorization: Bearer YOUR_TOKEN'curl -X GET 'http://localhost:3000/transaction' \
-H 'Authorization: Bearer YOUR_TOKEN'curl -X POST 'http://localhost:3000/transaction/contact' \
-H 'Content-Type: application/json' \
-d '{
"name": "John Doe",
"email": "john@example.com",
"contact": "9876543210"
}'Configure Razorpay webhook URL: https://yourdomain.com/transaction/webhook
Events: payout.processed, payout.rejected, payout.reversed
src/
├── clients/ # External services (Redis, Gemini)
├── controllers/ # Request handlers
├── jobs/ # Background jobs
├── middlewares/ # Auth, file upload
├── prisma/ # Database schema
├── repo/ # Database queries
├── routes/ # API routes
├── types/ # TypeScript types
└── utils/ # Helper functions
- Reward redemption: 3000 points = ₹200 (fixed)
- All authenticated endpoints require JWT Bearer token
- Amounts are in paise (smallest currency unit)