A comprehensive backend solution for building connected Muslim communities with real-time messaging, event management, and service sharing.
- Features
- Tech Stack
- Prerequisites
- Installation
- Environment Setup
- Getting Started
- API Documentation
- Project Structure
- Key Features
- Real-time Features
- Database Models
- Contributing
- Support
- π€ User Authentication - Secure JWT-based authentication with refresh tokens
- π¬ Real-time Messaging - Group chats and private messaging with Socket.io
- π Event Management - Create, manage, and join community events
- π₯ Group Management - Build and manage community groups
- ποΈ Marketplace - Share products and services within the community
- π³ Payment Integration - PayPal integration for transactions
- π Dashboard Analytics - Community insights and statistics
- πΈ Media Management - Cloudinary integration for image/video storage
- π§ Email Services - Automated email notifications and communications
- π Security - Password reset, email verification, role-based access control
- π Automatic Cleanup - Cron jobs for ad removal and data maintenance
- π± RESTful API - Fully documented REST endpoints
- π€ Profile Management - User profiles with skills and business information
- π Search Functionality - Search across products, services, and users
- β Contact System - User contact and inquiry management
- Runtime: Node.js v22
- Framework: Express.js 5.1
- Database: MongoDB with Mongoose ODM
- Real-time: Socket.io 4.8
- Authentication: JWT (JSON Web Tokens)
- File Storage: Cloudinary
- Payment: PayPal SDK
- Validation: Express Validator
- File Upload: Multer + Multer Storage Cloudinary
- Task Scheduling: Node-cron
- Email: Nodemailer & Resend
- Encryption: Bcryptjs, Crypto
- API Documentation: RESTful endpoints
- Development: Nodemon
Before you begin, ensure you have the following installed:
- Node.js (v22 or higher)
- npm or yarn
- MongoDB Atlas account
- Cloudinary account (for media uploads)
- PayPal Developer account (for payments)
- Gmail Account (for email service)
git clone https://github.com/Rahmasamy/Musliem-Community-Server.git
cd Musliem-Community-Servernpm installCreate a .env file in the root directory and add the following variables:
# Server Configuration
PORT=5000
NODE_ENV=development
# Database
MONGO_URI=mongodb+srv://username:password@cluster0.xxxxx.mongodb.net/?retryWrites=true&w=majority&appName=Cluster0
# JWT Secrets
JWT_SECRET=your_jwt_secret_here
JWT_REFRESH_SECRET=your_refresh_secret_here
JWT_EXPIRES_IN=1h
# Client URLs
CLIENT_URL=http://localhost:5173
CLIENT_URL_PROD=https://yourdomain.com
# Email Configuration
EMAIL_HOST=smtp.gmail.com
EMAIL_PORT=587
EMAIL_USER=your_email@gmail.com
EMAIL_PASS=your_app_password
EMAIL_PORT_PROD=465
# Email Service (Resend)
RESEND_API_KEY=your_resend_api_key
# Cloudinary Configuration
CLOUDINARY_CLOUD_NAME=your_cloud_name
CLOUDINARY_API_KEY=your_api_key
CLOUDINARY_API_SECRET=your_api_secret
# PayPal Configuration (Optional)
# PAYMENT_BASE_URL=https://api-m.sandbox.paypal.comβ οΈ Never commit.envfile to version control- For Gmail: Use App Passwords instead of your regular password
- Ensure your MongoDB Atlas IP Whitelist includes your current IP address or use
0.0.0.0/0for development
Start the development server with hot reload:
npm run devThe server will start on http://localhost:5000
npm startPOST /api/auth/register - Register new user
POST /api/auth/login - Login user
POST /api/auth/refresh-token - Refresh access token
POST /api/auth/forgot-password - Request password reset
POST /api/auth/verify-reset-code - Verify reset code
POST /api/auth/reset-password - Reset password
GET /api/services - Get all services
POST /api/services - Create service
GET /api/services/:id - Get service details
PUT /api/services/:id - Update service
DELETE /api/services/:id - Delete service
GET /api/events - Get all events
POST /api/events - Create event
GET /api/events/:id - Get event details
PUT /api/events/:id - Update event
DELETE /api/events/:id - Delete event
POST /api/events/:id/join - Join event
GET /api/groups - Get all groups
POST /api/groups - Create group
GET /api/groups/:id - Get group details
PUT /api/groups/:id - Update group
DELETE /api/groups/:id - Delete group
POST /api/groups/:id/join - Join group
GET /api/messages - Get messages
POST /api/messages - Send message
DELETE /api/messages/:id - Delete message
GET /api/products - Get all products
POST /api/products - Create product
GET /api/products/:id - Get product details
PUT /api/products/:id - Update product
DELETE /api/products/:id - Delete product
POST /api/payments/create - Create payment
GET /api/payments/:id - Get payment details
GET /api/search?q=query - Search products/services/users
GET /api/dashboard/stats - Get dashboard statistics
GET /api/dashboard/analytics - Get analytics data
src/
βββ config/ # Configuration files
β βββ db.js # MongoDB connection
β βββ basicSetupCloudinary.js
β βββ eventCloudinary.js
β βββ ...
β
βββ controllers/ # Business logic
β βββ authController/
β βββ serviceController/
β βββ eventController/
β βββ groupController/
β βββ messageController/
β βββ privateChatController/
β βββ productController/
β βββ ...
β
βββ models/ # Database schemas
β βββ User/
β βββ Service/
β βββ Event/
β βββ Group/
β βββ Product/
β βββ Message/
β βββ ...
β
βββ routes/ # API endpoints
β βββ authRoutes/
β βββ serviceRoutes/
β βββ eventRoutes/
β βββ groupRoutes/
β βββ ...
β
βββ middlewares/ # Custom middlewares
β βββ auth/
β βββ errorHandleMiddleware/
β βββ upload/
β
βββ services/ # Utility services
β βββ Email/
β βββ payment/
β βββ cron-job/
β βββ dashboard-anayltics/
β
βββ utils/ # Helper utilities
β βββ asyncHandler.js
β
βββ index.js # Application entry point
The application uses Socket.io for real-time communication:
- User Connection -
connection,disconnect - Messaging -
sendMessage,receiveMessage,messageDelete - Notifications - Real-time updates for events, groups, and messages
- Status Updates - User online/offline status
// Client-side (Frontend)
const socket = io('http://localhost:5000');
socket.on('connect', () => {
console.log('Connected to server');
});
socket.emit('sendMessage', { message: 'Hello!' });
socket.on('receiveMessage', (data) => {
console.log('New message:', data);
});- Users - User profiles, authentication data, business info
- Services - Community services listing
- Events - Community events and activities
- Groups - Community groups and forums
- Products - Product listings
- Messages - Group messages
- PrivateMessages - Direct messages between users
- PrivateChats - Chat sessions
- Payments - Payment transactions
- ContactUs - Contact inquiries
- β JWT-based authentication
- β Password hashing with bcryptjs
- β Refresh token rotation
- β Password reset with temporary tokens
- β Role-based access control (RBAC)
- β Email verification
- β CORS protection
- β Input validation with Express Validator
- Enable 2-factor authentication on Gmail
- Generate an App Password
- Use the App Password in
EMAIL_PASSenvironment variable
Configure RESEND_API_KEY for alternative email delivery
We welcome contributions! Please follow these steps:
- Fork the repository
- Create a feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
This project is licensed under the ISC License - see the LICENSE file for details.
For support, email: rahmasamy949@gmail.com or open an issue on GitHub.
- MongoDB for database hosting
- Cloudinary for media management
- Socket.io for real-time features
- PayPal for payment processing
- All contributors and the community
Made with β€οΈ for the Muslim Community