# Sales Record Management System (SRMS)

**Student:** SANGANO INEZA DAVINA  
**Exam:** National Practical Exam 2025-2026  
**Sector:** ICT and Multimedia — Software Development  
**Company:** SalesPro Ltd, Huye District, Southern Province, Rwanda

---

## Project Structure

```
Sangano_Ineza_Davina_National_Practical_Exam_2026/
├── ERD.md                    # Entity Relationship Diagram documentation
├── database/
│   └── schema.sql            # MySQL database schema (SRMS)
├── backend-project/          # Node.js + Express API
└── frontend-project/         # React.js + Tailwind CSS UI
```

---

## Technologies Used

| Layer    | Technology                          |
|----------|-------------------------------------|
| Frontend | React.js, Tailwind CSS, Axios, Vite |
| Backend  | Node.js, Express.js                 |
| Database | MySQL                               |
| Auth     | JWT + bcrypt                        |

---

## Setup Instructions

### 1. Create the Database

Open MySQL and run the schema file:

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

Or import `database/schema.sql` using phpMyAdmin / MySQL Workbench.

### 2. Configure Backend

```bash
cd backend-project
copy .env.example .env
```

Edit `.env` with your MySQL credentials:

```
DB_HOST=localhost
DB_USER=root
DB_PASSWORD=your_password
DB_NAME=SRMS
```

Install dependencies and seed the default user:

```bash
npm install
npm run seed-user
npm start
```

Backend runs at: **http://localhost:5000**

### 3. Start Frontend

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

Frontend runs at: **http://localhost:5173**

---

## Default Login

| Field    | Value     |
|----------|-----------|
| Username | admin     |
| Password | admin123  |

---

## Application Features

### Navigation Menu
- **Customer** — Add new customers (Insert)
- **Product** — Add new products (Insert)
- **Sales** — Insert, Retrieve, Update, Delete sales
- **Reports** — Daily, Weekly, Monthly reports
- **Logout** — Sign out

### CRUD Operations (per exam requirements)
| Entity   | Insert | Retrieve | Update | Delete |
|----------|--------|----------|--------|--------|
| Customer | ✅     | —        | —      | —      |
| Product  | ✅     | —        | —      | —      |
| Sale     | ✅     | ✅       | ✅     | ✅     |

### Reports
- **Daily** — Today's customers, products, and sales
- **Weekly** — Last 7 days
- **Monthly** — Last 30 days

---

## API Endpoints

| Method | Endpoint              | Description        |
|--------|-----------------------|--------------------|
| POST   | /api/auth/login       | User login         |
| POST   | /api/auth/register    | Create user account|
| POST   | /api/customers        | Add customer       |
| GET    | /api/customers        | List customers     |
| POST   | /api/products         | Add product        |
| GET    | /api/products         | List products      |
| GET    | /api/sales            | List all sales     |
| GET    | /api/sales/:invoice   | Retrieve one sale  |
| POST   | /api/sales            | Record new sale    |
| PUT    | /api/sales/:invoice   | Update sale        |
| DELETE | /api/sales/:invoice   | Delete sale        |
| GET    | /api/reports/daily    | Daily report       |
| GET    | /api/reports/weekly   | Weekly report      |
| GET    | /api/reports/monthly  | Monthly report     |

---

## ERD Summary

- **Customer** (1) → (N) **Sale** — One customer can have many sales
- **Product** (1) → (N) **Sale** — One product can appear in many sales

See `ERD.md` for the full diagram with primary keys and foreign keys.

---

Developed by **SANGANO INEZA DAVINA** for the National Practical Exam 2025-2026.
