Skip to content

Latest commit

Β 

History

4 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ–¨οΈ Smart Printer Management System

Full-stack print-shop operations platform with AI-assisted waste analysis

React Β· Node.js Β· Express Β· MongoDB Β· JWT Β· Gemini / Groq Vision AI

An Arabic-first management system for print shops that combines employee attendance, print-job tracking, inventory control, printer management, financial reporting, and image-based AI waste classification.


πŸ“Œ Overview

Smart Printer Management System is a full-stack web application designed to help a print shop manage its daily operations from one place.

The system provides two main experiences:

  • Employee App (React): attendance, print-job registration, AI-assisted waste reporting, and personal statistics.
  • Admin Portal (EJS/Express): operational dashboard, employee management, printer management, inventory, attendance reports, printing reports, waste reports, and financial reports.

The project also includes a Vision AI workflow that analyzes an uploaded image of damaged paper and classifies the likely cause as Machine, Employee, or Unknown, with a short Arabic explanation.


✨ Key Features

πŸ‘¨β€πŸ’Ό Admin

  • Dashboard with daily operational statistics.
  • Employee management: view, add, edit, search, and delete employees.
  • Printer management and active-printer tracking.
  • Inventory and paper-stock management.
  • Low-stock monitoring.
  • Print-job management and recent activity tracking.
  • Attendance reports.
  • Printing reports.
  • Waste reports.
  • Financial reporting and daily revenue tracking.
  • Role-based access control for protected admin pages.

πŸ‘· Employee

  • Secure sign-in using JWT authentication.
  • Smart daily Check In / Check Out attendance flow.
  • Browser geolocation capture for attendance records.
  • Prevention of duplicate attendance registration on the same day.
  • Register new print jobs using available paper/material inventory.
  • Server-side print-price calculation.
  • Submit paper-waste reports.
  • Upload a waste image for AI analysis.
  • View personal profile information and monthly statistics.
  • Responsive bottom navigation for quick access to main employee features.

πŸ€– AI Waste Analysis

  • Image upload with validation and an 8 MB size limit.
  • Vision-based waste analysis using Gemini or Groq.
  • Automatic provider fallback when both providers are configured.
  • Classification into:
    • Machine
    • Employee
    • Unknown
  • Short Arabic AI explanation for the detected issue.
  • AI result, provider, explanation, and status are stored with the waste report.
  • Safe manual-review fallback when AI analysis is unavailable or inconclusive.

🧰 Tech Stack

Layer Technologies
Frontend React 19, React Router, Axios, Bootstrap 5, Bootstrap Icons
Employee UI React SPA
Admin UI EJS server-rendered views
Backend Node.js, Express 5
Database MongoDB, Mongoose
Authentication JWT, bcryptjs
AI / Vision Google Gemini API, Groq Vision API
File Uploads Multer
Validation Joi
Maps / Location Browser Geolocation, Leaflet, React Leaflet
Utilities Moment.js, CORS, Cookie Parser, Dotenv

πŸ—οΈ Architecture

flowchart LR
    E[Employee] --> R[React Employee App\nlocalhost:3000]
    A[Admin] --> V[EJS Admin Portal\nlocalhost:3001]

    R --> API[Node.js / Express API]
    V --> API

    API --> DB[(MongoDB)]
    API --> AI{Vision AI}
    AI --> G[Google Gemini]
    AI --> Q[Groq Vision]
Loading

Main Flow

Employee / Admin
       ↓
React SPA / EJS Views
       ↓
Express Routes + Middleware
       ↓
Controllers + Services
       ↓
Mongoose Models
       ↓
MongoDB

Waste Image β†’ AI Service β†’ Gemini / Groq β†’ Classification β†’ MongoDB

πŸ“‚ Project Structure

smart_printer/
β”‚
β”œβ”€β”€ client/                     # React employee application
β”‚   β”œβ”€β”€ public/
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ components/
β”‚   β”‚   β”œβ”€β”€ pages/
β”‚   β”‚   β”‚   β”œβ”€β”€ Login.js
β”‚   β”‚   β”‚   β”œβ”€β”€ Attendance.js
β”‚   β”‚   β”‚   β”œβ”€β”€ PrintJob.js
β”‚   β”‚   β”‚   β”œβ”€β”€ WasteReport.js
β”‚   β”‚   β”‚   └── Profile.js
β”‚   β”‚   └── services/
β”‚   β”œβ”€β”€ .env.example
β”‚   └── package.json
β”‚
β”œβ”€β”€ server/                     # Node.js / Express backend
β”‚   β”œβ”€β”€ config/
β”‚   β”œβ”€β”€ controllers/
β”‚   β”œβ”€β”€ middlewares/
β”‚   β”œβ”€β”€ models/
β”‚   β”œβ”€β”€ routes/
β”‚   β”œβ”€β”€ services/
β”‚   β”‚   └── wasteAIService.js
β”‚   β”œβ”€β”€ utils/
β”‚   β”œβ”€β”€ validators/
β”‚   β”œβ”€β”€ views/                  # EJS admin portal
β”‚   β”œβ”€β”€ public/
β”‚   β”œβ”€β”€ .env.example
β”‚   β”œβ”€β”€ index.js
β”‚   └── package.json
β”‚
β”œβ”€β”€ docs/
β”‚   └── screenshots/
β”‚
└── README.md

πŸš€ Getting Started

Prerequisites

Make sure you have:

  • Node.js 18+
  • npm
  • A MongoDB Atlas database or local MongoDB instance
  • Optional: a Gemini API key and/or Groq API key for AI waste analysis

1. Clone the repository

git clone <YOUR_REPOSITORY_URL>
cd <YOUR_PROJECT_FOLDER>

2. Configure the backend

cd server
npm install

Create server/.env using server/.env.example:

PORT=3001
CLIENT_ORIGIN=http://localhost:3000

MONGO_URI=mongodb+srv://USERNAME:PASSWORD@YOUR_CLUSTER.mongodb.net/smart_printer?retryWrites=true&w=majority
JWT_SECRET=replace_with_a_long_random_secret

# Preferred AI provider: gemini or groq
AI_PROVIDER=gemini

# Gemini
GEMINI_API_KEY=your_gemini_api_key
GEMINI_MODEL=gemini-2.5-flash

# Optional Groq fallback
GROQ_API_KEY=your_groq_api_key
GROQ_VISION_MODEL=qwen/qwen3.8-27b

Start the backend:

npm run dev

or:

npm start

Backend URL:

http://localhost:3001

3. Configure the frontend

Open another terminal:

cd client
npm install

Create client/.env:

REACT_APP_API_URL=http://localhost:3001

Start React:

npm start

Frontend URL:

http://localhost:3000

πŸ” Authentication & Authorization

The application uses JWT-based authentication.

  • Protected employee API routes require a valid token.
  • Admin-only routes use role-based authorization middleware.
  • Passwords are hashed using bcryptjs.
  • Secrets and database credentials are stored in environment variables.

Important: Never commit server/.env or real API keys to GitHub.


πŸ€– AI Waste Detection Workflow

  1. The employee selects the printer where the issue occurred.
  2. The number of wasted sheets is entered.
  3. A photo of the damaged paper is uploaded.
  4. The backend validates and sends the image to the configured Vision AI provider.
  5. The AI returns a strict structured result containing the likely cause and an Arabic explanation.
  6. The waste report and AI analysis are stored in MongoDB.
  7. If the preferred provider fails, the service can automatically try the configured fallback provider.

Example AI result:

{
  "decision": "Machine",
  "explanation": "يوجد Ψͺلف Ω…Ψ§Ψ―ΩŠ واآح في Ψ§Ω„ΩˆΨ±Ω‚ يرجح وجود Ω…Ψ΄ΩƒΩ„Ψ© Ω…ΩŠΩƒΨ§Ω†ΩŠΩƒΩŠΨ© Ψ£Ψ«Ω†Ψ§Ψ‘ Ψ§Ω„Ψ·Ψ¨Ψ§ΨΉΨ©."
}

πŸ“Έ Screenshots

πŸ” Authentication & Main Views

Login

Login Page
Admin Dashboard

Admin Dashboard
Employee View

Employee View
Smart Attendance

Smart Attendance

πŸ–¨οΈ Printing & AI Waste Analysis

Print Job Registration

Print Job Registration
AI Waste Upload

AI Waste Upload
AI-Assisted Waste Analysis Result

AI Waste Analysis Result

βš™οΈ Administration & Profile

Inventory Management

Inventory Management
Employee Management

Employee Management
Employee Profile

Employee Profile

πŸ“Š Admin Dashboard Metrics

The admin dashboard summarizes important daily data, including:

  • Total printers
  • Total employees
  • Low-stock inventory items
  • Daily revenue
  • Print jobs created today
  • Employees present today
  • Total wasted sheets today
  • Recent print jobs
  • Current staff attendance status

πŸ›‘οΈ Security Notes

  • Keep .env files outside version control.
  • Use a strong, unique JWT_SECRET.
  • Rotate API keys immediately if they are ever exposed.
  • Restrict MongoDB Atlas network access and database-user permissions.
  • Use HTTPS and secure deployment secrets in production.
  • Consider HttpOnly secure cookies instead of browser localStorage for production authentication.

πŸ—ΊοΈ Future Improvements

  • Server-side attendance geofencing around the workplace.
  • Separate check-in and check-out GPS locations.
  • MongoDB transactions / atomic stock updates for high-concurrency printing.
  • Improved dashboard charts and analytics.
  • Push/email notifications for low stock.
  • More advanced AI waste categories and confidence scoring.
  • Export reports to PDF/Excel.
  • Full responsive admin dashboard.
  • Automated API and integration tests.
  • Production deployment with HTTPS.

βœ… Current Status

  • React production build: working
  • Backend JavaScript syntax validation: passing
  • MongoDB integration: working
  • JWT authentication: working
  • Role-based admin protection: working
  • Attendance flow: working
  • Print-job workflow: working
  • AI waste analysis: working
  • Gemini / Groq fallback support: implemented

πŸ“„ License

This project is currently intended for educational and academic use. Add a dedicated LICENSE file if you plan to distribute it publicly under a specific open-source license.


Smart Printer Management System
Built to make print-shop operations smarter, more traceable, and easier to manage.

About

Full-stack print shop management system with smart attendance, print-job tracking, inventory control, admin reporting, and AI-assisted paper waste analysis.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages