Overview
This guide walks you through the complete setup process for the Church Management System API, from installing dependencies to running the server in production.Prerequisites
Before you begin, ensure you have the following installed:- Node.js (v14 or higher)
- MongoDB (v4.4 or higher)
- npm or yarn package manager
- A Stripe account for payment processing
- An email service provider (Brevo/SendinBlue or Gmail)
Installation
Install dependencies
Install all required Node.js packages:The following core dependencies will be installed:
- express (v5.2.1) - Web application framework
- mongoose (v9.1.6) - MongoDB object modeling
- bcryptjs (v3.0.3) - Password hashing
- jsonwebtoken (v9.0.3) - JWT authentication
- stripe (v20.3.1) - Payment processing
- nodemailer (v8.0.1) - Email notifications
- dotenv (v17.2.4) - Environment variable management
Database Setup
MongoDB Configuration
The API uses Mongoose to connect to MongoDB. The connection is established insrc/configs/dbconnect.js:
Database Models
The system uses four main MongoDB collections:Email Configuration
Using Brevo (SendinBlue)
The default email configuration uses Brevo’s SMTP relay:Using Gmail (Alternative)
To use Gmail instead, modifysrc/configs/mailutil.js:
Stripe Payment Setup
Getting Your Stripe Keys
Create a Stripe account
Sign up at stripe.com if you don’t have an account.
Get your API keys
Navigate to Developers > API keys in your Stripe dashboard.
- For testing: Use the Secret key that starts with
sk_test_ - For production: Use the Live secret key starting with
sk_live_
Payment Flow Configuration
The system uses Stripe Checkout Sessions. Configure your success and cancel URLs in.env:
- Success:
${BASE_URL}/complete?session_id={CHECKOUT_SESSION_ID} - Cancel:
${BASE_URL}/cancel
Running the Server
Development Mode
Run the server with auto-reload on file changes:nodemon to automatically restart the server when you modify files.
Production Mode
Run the server in production:The server typically runs on port 3000. Check your
src/app.js file to confirm or modify the port configuration.Verification Steps
After starting the server, verify your setup:Production Deployment
Environment Checklist
Before deploying to production:- Set
NODE_ENV=productionin environment variables - Use strong, unique
JWT_SECRET(minimum 32 characters) - Switch to Stripe live keys (
sk_live_...) - Update
BASE_URLto your production domain - Configure MongoDB Atlas or production database
- Set up proper email service with verified domain
- Enable HTTPS/SSL certificates
- Configure CORS for your frontend domain
- Set up monitoring and logging
Database Migration
For production, use MongoDB Atlas:Security Recommendations
Troubleshooting
Common Issues
Database connection fails- Verify MongoDB is running:
mongod --version - Check
CONNECTION_STRINGformat in.env - Ensure network connectivity to MongoDB server
- Verify SMTP credentials are correct
- Check if email service requires IP whitelisting
- Ensure firewall allows outbound SMTP connections (port 587)
- Confirm you’re using the correct API key (test vs. live)
- Verify
BASE_URLmatches your application URL - Check Stripe dashboard for error logs
- Ensure
JWT_SECRETis set in environment variables - Verify token hasn’t expired (default: 1 hour)
- Check for typos in Authorization header format
Next Steps
Now that your server is running:- User Management Guide - Learn how to manage user registration and profiles
- Church Operations Guide - Set up churches and manage membership
- Donation Campaigns Guide - Create and manage donation campaigns