A comprehensive system management application built with Node.js, Express, and MongoDB, featuring AI-powered automation and intelligent business workflows.
- Clone & Install:
git clone https://github.com/farahmahfouz/order_management_system
cd system-management
npm install
- Environment Configuration:
# Server
PORT=3000
NODE_ENV=development
# Database
MONGODB_URI=mongodb+srv://username:password@cluster.mongodb.net/system_management
# Authentication
JWT_SECRET=your_jwt_secret_key
JWT_EXPIRES_IN=90d
# Email
SENDGRID_API_KEY=your_sendgrid_api_key
EMAIL_FROM=your_verified_sender_email
# AI & Google Services
OPENROUTER_API_KEY=your_openrouter_api_key
GOOGLE_CLIENT_ID=your_google_client_id
GOOGLE_CLIENT_SECRET=your_google_client_secret
- Run Application:
npm start # Development
npm run start:prod # Production
Covers: Authentication, Users, Items, Orders, Reports, Advanced Querying
- Auto-generates 3 promotional messages (1 SMS + 2 social posts) for new Food items ≥ 200 EGP
- Uses OpenRouter Gen AI API for creative content
- New expensive food items (≥200 EGP)
- High-performing items (500+ sales in 10 days)
Hourly cron jobs handle:
- Today's expiry alerts + 5-day warnings
- Email notifications to admins/managers
- Google Calendar integration for expiry reminders
- Auto 25% discount for items expiring within 20 days
- Prevents duplicate applications
- Admin notification reports
- Auto-expire pending orders after 4 hours
- Status tracking and analytics
- Automated CSV generation of daily orders
- Google Drive upload integration
- Email distribution to stakeholders
- 📧 Gmail: Email automation via Nodemailer
- 📅 Calendar: Expiry reminder events
- 💾 Drive: Automated report storage
MongoDB Collections:
- Users: Authentication, profiles, roles
- Items: Product catalog with expiry tracking
- Orders: Order management and analytics
- Password hashing (bcrypt)
- JWT authentication
- Rate limiting & CORS
- Input validation
- NoSQL injection protection
Core: express, mongoose, bcryptjs, jsonwebtoken
Automation: node-cron, dayjs, nodemailer
AI/Services: openrouter, googleapis, sendgrid
Security: helmet, express-rate-limit, cors
system-management/
├── config/ # Configuration
├── controllers/ # Route controllers
├── models/ # Mongoose schemas
├── utils/ # Utilities (email, CSV, cronJobs)
├── routes/ # API routes
├── middlewares/ # Custom middlewares
└── app.js # Entry point
MongoDB Issues:
- Check connection string and network access
- Verify Atlas credentials and IP whitelist
Cron Jobs:
- Check server timezone and logs
- Verify SendGrid API configuration
Google Services:
- Confirm OAuth credentials and API permissions
- Fork repository
- Create feature branch
- Commit changes
- Open Pull Request
ISC License
Built with ❤️ by Farah Mahfouz