Welcome
This guide will help you set up and run the Church Management System API locally, and make your first API call.Clone and Install Dependencies
First, clone the repository and install the required packages:The API uses the following key dependencies:
- Express - Web framework
- Mongoose - MongoDB ODM
- JWT - Authentication tokens
- bcryptjs - Password hashing
- dotenv - Environment configuration
Configure Environment Variables
Create a
.env file in the root directory with the following variables:.env
Start MongoDB
Make sure MongoDB is running on your system:
You can also use MongoDB Atlas (cloud) by updating the
CONNECTION_STRING in your .env file.Register Your First User
Create a new user account:
cURL
Passwords must be at least 6 characters long. The API supports two roles:
pastor and member.API Base URL
All API endpoints are prefixed with the base URL:Local Development
Available Routes
The API exposes three main route groups:| Route Group | Base Path | Description |
|---|---|---|
| Authentication | /api/auth | Register and login endpoints |
| Users | /api/users | User management and profiles |
| Church | /api/church | Church-related operations |
Next Steps
Authentication
Learn about JWT tokens and role-based access control
API Reference
Explore all available endpoints
Troubleshooting
Database Connection Failed
If you seeconnection no work ooo in the console:
- Verify MongoDB is running
- Check your
CONNECTION_STRINGin.env - Ensure network access if using MongoDB Atlas
Server Won’t Start
If the server fails to start:- Check if port 3001 is already in use
- Verify all dependencies are installed (
npm install) - Ensure your
.envfile exists and is properly configured
Token Errors
If you receive token-related errors:- Ensure you’re including the
Bearerprefix in the Authorization header - Check that your token hasn’t expired (tokens last 1 hour)
- Verify your
JWT_SECRETmatches between requests