const express = require('express');
const cors = require('cors');

// Import all required modular CRUD route components
const authRoutes = require('./routes/auth');
const departmentRoutes = require('./routes/departments');
const employeeRoutes = require('./routes/employees');
const payrollRoutes = require('./routes/payroll');

const app = express();

// Middleware configuration
app.use(cors());
app.use(express.json());

// ==============================================================
// 🔀 API ROUTE MOUNTING (CRUD ENDPOINTS)
// ==============================================================

// 🔐 Authentication & Users (Register / Login / User CRUD)
app.use('/api/auth', authRoutes);

// 🏢 Corporate Structural Units (Departments CRUD)
app.use('/api/hr/departments', departmentRoutes);

// 👥 Digital Workforce Profiles (Employees CRUD)
app.use('/api/hr/employees', employeeRoutes);

// 💵 Financial Processing Engine (Salary matrix CRUD & Bill generation)
app.use('/api/payroll', payrollRoutes);

// ==============================================================
// 🚀 SERVER INITIALIZATION
// ==============================================================
const PORT = 5000;
app.listen(PORT, () => {
    console.log(`=======================================================`);
    console.log(`🚀 SmartPark Core Engine online running on Port ${PORT}`);
    console.log(`💻 Ready to handle complete administrative CRUD loops`);
    console.log(`=======================================================`);
});