# EduPay — School Payroll Management System

A full-stack **MERN** application for managing school staff payroll: employees, departments, salary structures, and monthly pay runs.

![Stack](https://img.shields.io/badge/React-18-blue) ![Node](https://img.shields.io/badge/Node.js-Express-green) ![MongoDB](https://img.shields.io/badge/MongoDB-NoSQL-green) ![Tailwind](https://img.shields.io/badge/Tailwind-CSS-38bdf8)

## Features

- **Dashboard** — Stats, 6-month payroll charts, staff breakdown by role
- **Employees** — CRUD with salary allowances and deductions
- **Departments** — Organize staff by academic/admin units
- **Payroll** — Generate monthly payroll, mark as paid, period filters
- **Auth** — JWT login with protected API routes
- **UI** — Modern Tailwind design with gradients, charts (Recharts), responsive layout

## Tech Stack

| Layer    | Technology                          |
|----------|-------------------------------------|
| Frontend | React 18, Vite, Tailwind CSS, Recharts |
| Backend  | Node.js, Express, Mongoose          |
| Database | MongoDB (NoSQL)                     |
| Auth     | JWT + bcrypt                        |

## Prerequisites

- [Node.js](https://nodejs.org/) 18+
- [MongoDB](https://www.mongodb.com/try/download/community) running locally (or MongoDB Atlas URI)

## Quick Start

### 1. Install dependencies

```bash
cd scholl
npm install
npm run install:all
```

### 2. Configure environment

Copy `server/.env.example` to `server/.env` and set your MongoDB URI if needed:

```
MONGODB_URI=mongodb://127.0.0.1:27017/school_payroll
```

### 3. Seed demo data

```bash
npm run seed
```

### 4. Run the app

```bash
npm run dev
```

- **Frontend:** http://localhost:5173  
- **API:** http://localhost:5000  

### Demo login

| Email              | Password  |
|--------------------|-----------|
| admin@school.edu   | admin123  |

You can also **register a new account** at http://localhost:5173/register

## Project Structure

```
scholl/
├── client/          # React + Vite + Tailwind
│   └── src/
│       ├── pages/       Dashboard, Employees, Departments, Payroll
│       ├── components/  Layout, Modal, StatCard
│       └── context/     AuthContext
├── server/          # Express API
│   └── src/
│       ├── models/      User, Employee, Department, Payroll
│       ├── routes/      REST endpoints
│       └── seed.js      Demo data
└── README.md
```

## API Endpoints

| Method | Endpoint                    | Description              |
|--------|-----------------------------|--------------------------|
| POST   | /api/auth/login             | Login                    |
| GET    | /api/dashboard/stats        | Dashboard analytics      |
| GET    | /api/employees              | List employees           |
| POST   | /api/employees              | Create employee          |
| GET    | /api/departments            | List departments         |
| GET    | /api/payrolls               | List payroll records     |
| POST   | /api/payrolls/generate      | Generate monthly payroll |

## Production Build

```bash
npm run build --prefix client
NODE_ENV=production npm start --prefix server
```

Serve the `client/dist` folder with Express static middleware or a CDN in production.

## License

MIT
