Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/SidneyEmeka/church_management_system/llms.txt

Use this file to discover all available pages before exploring further.

Welcome

This guide will help you set up and run the Church Management System API locally, and make your first API call.
1

Clone and Install Dependencies

First, clone the repository and install the required packages:
git clone <repository-url>
cd church_management
npm install
The API uses the following key dependencies:
  • Express - Web framework
  • Mongoose - MongoDB ODM
  • JWT - Authentication tokens
  • bcryptjs - Password hashing
  • dotenv - Environment configuration
2

Configure Environment Variables

Create a .env file in the root directory with the following variables:
.env
# Server Configuration
PORT=3001
BASE_URL=http://localhost:3001

# Database
CONNECTION_STRING=mongodb://localhost:27017/church_management
# Or use MongoDB Atlas:
# CONNECTION_STRING=mongodb+srv://<username>:<password>@cluster.mongodb.net/church_management

# JWT Secret (use a strong random string)
JWT_SECRET=your_super_secure_jwt_secret_key_here
Make sure to use a strong, unique JWT secret in production. Never commit your .env file to version control.
3

Start MongoDB

Make sure MongoDB is running on your system:
# If using local MongoDB
mongod

# Or if using MongoDB as a service
sudo systemctl start mongod
You can also use MongoDB Atlas (cloud) by updating the CONNECTION_STRING in your .env file.
4

Start the Server

Run the development server:
npm run dev
You should see output like:
DB CONNECTED localhost, church_management
Server is running on http://localhost:3001
5

Verify API is Running

Test the health check endpoint:
cURL
curl http://localhost:3001/health
Expected response:
{
  "message": "Church Management System API",
  "version": "1.0.0",
  "status": "running"
}
6

Register Your First User

Create a new user account:
cURL
curl -X POST http://localhost:3001/api/auth/register \
  -H "Content-Type: application/json" \
  -d '{
    "email": "[email protected]",
    "password": "securePassword123",
    "role": "pastor",
    "invitedBy": "admin"
  }'
{
  "success": true,
  "message": "Registeration Successful",
  "data": "A verification link has been sent to you. Kindly verify your email address"
}
Passwords must be at least 6 characters long. The API supports two roles: pastor and member.
7

Login and Get Access Token

Authenticate to receive a JWT token:
cURL
curl -X POST http://localhost:3001/api/auth/login \
  -H "Content-Type: application/json" \
  -d '{
    "email": "[email protected]",
    "password": "securePassword123"
  }'
Response:
{
  "success": true,
  "message": "Login Successful",
  "data": {
    "User": {
      "email": "[email protected]",
      "role": "pastor",
      "profile": {},
      "invitedBy": "admin",
      "isProfileComplete": false,
      "createdAt": "2026-03-07T10:30:00.000Z"
    },
    "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
  }
}
Save the token value - you’ll need it for authenticated requests. Tokens expire after 1 hour.
8

Make Your First Authenticated Request

Use the token to access protected endpoints:
cURL
curl -X GET http://localhost:3001/api/users/profile \
  -H "Authorization: Bearer YOUR_TOKEN_HERE"
Replace YOUR_TOKEN_HERE with the token from the login response.

API Base URL

All API endpoints are prefixed with the base URL:

Local Development

http://localhost:3001

Available Routes

The API exposes three main route groups:
Route GroupBase PathDescription
Authentication/api/authRegister and login endpoints
Users/api/usersUser management and profiles
Church/api/churchChurch-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 see connection no work ooo in the console:
  • Verify MongoDB is running
  • Check your CONNECTION_STRING in .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 .env file exists and is properly configured

Token Errors

If you receive token-related errors:
  • Ensure you’re including the Bearer prefix in the Authorization header
  • Check that your token hasn’t expired (tokens last 1 hour)
  • Verify your JWT_SECRET matches between requests

Build docs developers (and LLMs) love