# Supply Chain Management System (SCMS)

Web application for **SupplyNet Ltd** — National Practical Exam 2026.

## Project Structure

```
SCMS/
├── backend-project/     # Node.js + Express + MySQL API
├── frontend-project/    # React.js + Tailwind CSS + Axios
├── database/            # MySQL schema (SCMS database)
├── docs/ERD.md          # Entity Relationship Diagram documentation
└── FirstName_LastName_National_Practical_Exam_2026/  # Rename for submission
```

## Exam Requirements Checklist

| # | Requirement | Status |
|---|-------------|--------|
| 1 | ERD with PK/FK and cardinalities | `docs/ERD.md` + hand-drawn copy required |
| 2 | MySQL database `SCMS` with 3 tables | `database/scms_schema.sql` |
| 3 | Save in `FirstName_LastName_National_Practical_Exam_2026` | Rename folder with your name |
| 4 | React frontend with Tailwind | `frontend-project/` |
| 5 | Node.js backend with Express | `backend-project/` |
| 6 | Menu: Supplier, Shipment, Delivery, Reports, Logout | Implemented |
| 7 | Insert on all 3 forms; CRUD on shipment & delivery only | Implemented |
| 8 | User account (username/password) | Login + Register |
| 9 | Axios integration | `src/api/axios.js` |
| 10 | Daily/weekly/monthly reports | Reports page |

## Prerequisites

- Node.js 18+
- MySQL 8+

## Setup

### 1. Database

```bash
mysql -u root -p < database/scms_schema.sql
```

### 2. Backend

```bash
cd backend-project
copy .env.example .env
# Edit .env with your MySQL password
npm install
npm run seed
npm start
```

API runs at `http://localhost:5000`

Default login: **admin** / **admin123**

### 3. Frontend

```bash
cd frontend-project
npm install
npm run dev
```

App runs at `http://localhost:3000`

## API Endpoints

| Method | Endpoint | Description |
|--------|----------|-------------|
| POST | `/api/auth/register` | Create user account |
| POST | `/api/auth/login` | Login |
| POST | `/api/suppliers` | Insert supplier |
| GET | `/api/suppliers` | List suppliers |
| POST/GET/PUT/DELETE | `/api/shipments` | Shipment CRUD |
| POST/GET/PUT/DELETE | `/api/deliveries` | Delivery CRUD |
| GET | `/api/reports/:entity/:period` | Reports (daily/weekly/monthly) |

Entities: `suppliers`, `shipments`, `deliveries`

## ERD (Summary)

- **Supplier** (1) — supplies — (N) **Shipment**
- **Shipment** (1) — contains — (N) **Delivery**

See `docs/ERD.md` for full diagram and Mermaid export.
