A full-stack web application for managing donations to NGOs with PayPal integration, user authentication, email verification, and comprehensive admin dashboard.
- Features
- Tech Stack
- Prerequisites
- Installation
- Configuration
- Running the Application
- Usage Guide
- Project Structure
- API Endpoints
- Security Features
- Troubleshooting
- Secure Registration & Login with email verification
- Email Verification via OTP (One-Time Password)
- Password Management - Change password anytime, Reset via email
- PayPal Integration for secure donations (Sandbox & Live)
- Donation History with receipt download (PDF)
- Profile Management - Update personal information
- Dark Mode Support for better user experience
- User Management - View, search, and export user data
- Donation Management - Monitor all donations with filters
- Analytics Dashboard - Visual insights with charts
- Campaign Tracking - Track fundraising goals and progress
- CSV Export - Export user and donation data
- PDF Reports - Generate campaign reports
- Receipt Management - Download receipts for user donations
- React 18+ with TypeScript
- Vite for fast development
- Tailwind CSS for styling
- Recharts for data visualization
- PayPal SDK for payment integration
- jsPDF for receipt generation
- Lucide React for icons
- date-fns for date formatting
- Node.js with Express
- TypeScript for type safety
- MongoDB with Mongoose ODM
- JWT for authentication
- bcryptjs for password hashing
- Nodemailer for email services
- express-validator for input validation
- express-rate-limit for API protection
Before you begin, ensure you have the following installed:
- Node.js (v16 or higher)
- npm or yarn
- MongoDB Atlas account (or local MongoDB)
- PayPal Developer account
- Gmail account (for sending emails)
git clone <repository-url>
cd donatenowBackend:
cd server
npm installFrontend:
cd ..
npm install- Go to MongoDB Atlas
- Create a free cluster
- Create a database user
- Whitelist your IP address (or use 0.0.0.0/0 for development)
- Get your connection string
- Go to PayPal Developer Dashboard
- Create a Sandbox account
- Create a REST API app
- Copy your Client ID and Secret
- Go to Google Account Security
- Enable 2-Step Verification
- Go to App Passwords
- Create a new app password for "Mail"
- Copy the generated password (16 characters)
Create a .env file in the server directory:
# Server Configuration
PORT=5000
NODE_ENV=development
# MongoDB Connection
MONGODB_URI=your_mongodb_connection_string_here
# JWT Secret (generate a random string)
JWT_SECRET=your_secure_random_jwt_secret_here
# Admin Secret Code (for admin registration)
ADMIN_SECRET_CODE=ADMIN2026
# PayPal Configuration
PAYPAL_CLIENT_ID=your_paypal_client_id_here
PAYPAL_CLIENT_SECRET=your_paypal_client_secret_here
PAYPAL_MODE=sandbox
# Email Configuration (Gmail)
EMAIL_SERVICE=gmail
EMAIL_USER=your_gmail_address@gmail.com
EMAIL_PASS=your_16_character_app_password
EMAIL_FROM=DonateNow <your_gmail_address@gmail.com>Important Notes:
- Replace all
your_*_herevalues with your actual credentials - Never commit the
.envfile to version control - Use
PAYPAL_MODE=livefor production - For JWT_SECRET, use a long random string (e.g., generated via
openssl rand -hex 64)
Terminal 1 - Backend:
cd server
npm run devServer will start on http://localhost:5000
Terminal 2 - Frontend:
npm run devFrontend will start on http://localhost:3000 or http://localhost:3001
Frontend:
npm run build
npm run previewBackend:
cd server
npm run build
npm start- Navigate to the registration page
- Fill in your details:
- Full Name
- Mobile Number
- City
- Password (min 4 characters)
- Submit the form
- Check your email for a 6-digit OTP
- Enter the OTP on the verification page (valid for 10 minutes)
- Account created successfully!
- Enter your email and password
- Click "Forgot Password?" if you forgot your password
- Access your dashboard
- From your dashboard, select or enter an amount
- Add an optional message
- Click "Donate Now"
- Complete payment via PayPal Sandbox
- Download your receipt after successful payment
- Go to your profile section
- Click "Change Password"
- Enter current password and new password
- Must be at least 12 characters
- Include uppercase, lowercase, and special character
- Save changes
- Use the regular registration form
- Enter the admin secret code:
ADMIN2026 - Complete email verification
- Login to access admin dashboard
- Overview Tab: View key metrics and charts
- Users Tab: Manage users, search, filter, export CSV
- Donations Tab: Monitor donations with filters by status and date
- Download Reports: Generate PDF campaign reports
- Change Password: Update admin password securely
donatenow/
βββ server/ # Backend Express server
β βββ src/
β β βββ models/ # Mongoose models
β β βββ routes/ # API routes
β β βββ services/ # Business logic (email, etc.)
β β βββ middleware/ # Auth middleware
β β βββ server.ts # Server entry point
β βββ .env # Environment variables
β βββ package.json
β
βββ pages/ # React pages/components
β βββ Home.tsx
β βββ Login.tsx
β βββ Register.tsx
β βββ VerifyEmail.tsx
β βββ UserDashboard.tsx
β βββ AdminDashboard.tsx
β
βββ components/ # Reusable components
β βββ ui/ # UI components
β βββ ChangePasswordModal.tsx
β
βββ services/ # Frontend services
β βββ apiService.ts # API calls
β
βββ types.ts # TypeScript types
POST /api/auth/register- Register new userPOST /api/auth/login- User loginGET /api/auth/me- Get current user
POST /api/verification/verify-otp- Verify OTP and create accountPOST /api/verification/resend-otp- Resend OTP
POST /api/password-reset/request- Request password resetPOST /api/change-password/change-password- Change password
GET /api/donations- Get user donationsPOST /api/donations- Create donationPATCH /api/donations/:id/status- Update donation status
POST /api/paypal/create-order- Create PayPal orderPOST /api/paypal/capture-payment- Capture payment
GET /api/users- Get all usersPUT /api/users/:id- Update userDELETE /api/users/:id- Delete userGET /api/campaign- Get campaign data
- Password Hashing: bcrypt with salt rounds
- JWT Authentication: Secure token-based auth
- Email Verification: OTP-based account verification
- Rate Limiting: Protect against brute force attacks
- Input Validation: Server-side validation with express-validator
- XSS Protection: Sanitized inputs
- CORS: Configured for security
- Environment Variables: Sensitive data not in code
Issue: Verification emails not arriving
Solutions:
- Verify Gmail App Password is correct
- Check spam/junk folder
- Ensure 2-Step Verification is enabled on Gmail
- Verify
EMAIL_USERandEMAIL_PASSin.env - Restart the backend server after changing
.env
Issue: Payment not processing
Solutions:
- Verify PayPal credentials in
.env - Check if using Sandbox account for testing
- Ensure
PAYPAL_MODE=sandboxfor development - Check PayPal Developer Dashboard for errors
Issue: Cannot connect to database
Solutions:
- Check MongoDB URI is correct
- Verify IP whitelist in MongoDB Atlas
- Ensure database user credentials are correct
- Check network connectivity
Issue: Port 5000 or 3000 already occupied
Solutions:
# Windows
netstat -ano | findstr :5000
taskkill /PID <PID> /F
# Change port in server/.env or vite.config.tsThis project is for educational purposes.
For issues or questions:
- Check this README
- Review error logs in terminal
- Verify environment variables
- Check MongoDB and PayPal dashboards
- Use PayPal Sandbox for testing
- Test email verification with a real email
- Check browser console for frontend errors
- Monitor server terminal for backend logs
- Use MongoDB Compass to view database
Made with β€οΈ for making donations simple and transparent