Website : rimsha.abasa.com
backdoor
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
var
/
www
/
mudeerapi.abasa.com
/
nodetest-backup30April26
/
Filename :
README.md
back
Copy
# Mudeer Backend API - nodetest Node.js/Express backend API for the Mudeer attendance management system. Built with MongoDB, Redis caching, AWS S3 integration, and Firebase Cloud Messaging. ## Tech Stack **Core:** - **Express.js** - Web framework - **MongoDB** with **Mongoose** - Database & ODM - **Redis** - Caching layer - **JWT** (jsonwebtoken) - Authentication - **bcrypt** - Password hashing **Services & Integrations:** - **AWS SDK** (S3) - File storage - **Firebase Admin** - Push notifications - **Nodemailer** - Email service - **node-cron** - Scheduled tasks - **Multer** - File upload handling **Utilities:** - **Moment.js** - Date/time manipulation - **Axios** - HTTP client - **dotenv** - Environment configuration ## Project Structure ``` src/ ├── index.js # Application entry point ├── app.js # Express app configuration ├── config/ # Configuration files (email transporter) ├── controllers/ # Route controllers │ ├── user.controller.js │ ├── attendance.controller.js │ ├── department.controller.js │ ├── notification.controller.js │ └── ... ├── models/ # Mongoose models │ ├── user.models.js │ ├── attendance.model.js │ ├── department.model.js │ └── ... ├── routes/ # API routes │ ├── user.routes.js │ ├── attendance.routes.js │ └── ... ├── middlewares/ # Custom middleware │ ├── check-auth.js │ ├── checkRole.js │ └── checkDepartmentAccess.js ├── services/ # Business logic services │ ├── firebase.js │ ├── notificationService.js │ └── statusUpdater.js ├── db/ # Database connections │ ├── index.js # MongoDB connection │ └── redis.js # Redis connection ├── utils/ # Utility functions │ ├── cacheHelper.js │ ├── invalidationHelper.js │ └── timezone.js └── template/ # Email/notification templates ``` ## Installation ### Prerequisites - Node.js (v18+ recommended) - MongoDB instance - Redis server - AWS S3 bucket (for file storage) - Firebase project (for push notifications) ### Setup 1. **Clone the repository** ```bash git clone https://gs1.abasa.com/sohaib/nodetest.git cd nodetest ``` 2. **Install dependencies** ```bash npm install ``` If you encounter peer dependency conflicts, use: ```bash npm install --legacy-peer-deps ``` 3. **Configure environment variables** Create a `.env` file in the root directory: ```env # Server PORT=8000 NODE_ENV=development # Database DATABASE_URL=mongodb://localhost:27017/mudeer # Redis REDIS_URL=redis://localhost:6379 # Frontend FRONTEND_URL=http://localhost:3000 # AWS S3 AWS_REGION=us-east-1 AWS_ACCESS_KEY_ID=your_access_key AWS_SECRET_ACCESS_KEY=your_secret_key AWS_BUCKET_NAME=your_bucket_name # Firebase FIREBASE_SERVICE_ACCOUNT_KEY={"type":"service_account",...} # Email (SMTP) SMTP_HOST=smtp.gmail.com SMTP_PORT=587 SMTP_USER=your_email@gmail.com SMTP_PASS=your_app_password SMTP_FROM=noreply@mudeer.com # Replication (Optional - for staging) SOURCE_URI=mongodb://source-cluster-uri ``` 4. **Start the server** ```bash npm start ``` The server will run on `http://localhost:8000` (or the port specified in `.env`). ## API Endpoints - `/user/*` - User management, authentication, profiles - `/user/attendance/*` - Attendance tracking - `/user/activeWindow/*` - Active window monitoring - `/user/eventActivity/*` - User activity events - `/user/leave/*` - Leave management - `/department/*` - Department management - `/notification/*` - Push notifications - `/uploads/*` - Static file serving ## Key Features - **Authentication & Authorization** - JWT-based auth with role-based access control - **Caching Strategy** - Redis caching for improved performance - **File Upload** - AWS S3 integration for profile pictures and documents - **Push Notifications** - Firebase Cloud Messaging integration - **Email Service** - Automated emails for attendance, password reset, etc. - **Scheduled Tasks** - Background jobs for status updates - **Database Replication** - Change stream replication for staging environment - **UTC Timezone Handling** - Consistent timezone management across the system ## Development The application uses `nodemon` for auto-reloading during development. The start script includes: - Automatic JSON module support - Environment variable loading via dotenv ## Deployment The project includes GitLab CI/CD configuration for automated deployment to staging and production environments using PM2.