# DAB Enterprise Ltd - Business Web Solution (BWS)
## National Practical Exam 2026

**Developer:** [FirstName LastName]  
**Institution:** [School Name]  
**Location:** Kigali, Rwanda  
**Date:** June 2026

---

## Project Structure

```
FirstName_LastName_National_Practical_Exam_2026/
├── backend-project/          # Node.js + Express + MongoDB API
│   ├── src/
│   │   ├── models/           # Mongoose models (User, Product, Sales, StockStatus)
│   │   ├── routes/           # Express routes (auth, products, sales, stock, reports)
│   │   ├── middleware/       # Auth session middleware
│   │   └── server.js         # Entry point
│   ├── .env                  # Environment variables
│   └── package.json
│
└── frontend-project/         # React.js + Tailwind CSS
    ├── src/
    │   ├── components/       # Layout, Navbar
    │   ├── pages/            # Login, Dashboard, Products, Sales, StockStatus, Reports
    │   └── utils/            # Axios API config, AuthContext
    └── package.json
```

---

## Setup Instructions

### Prerequisites
- Node.js v18+
- MongoDB (local or Atlas)
- npm

### Backend Setup

```bash
cd backend-project
npm install
# Edit .env and set your MONGO_URI
npm run dev
```

Server runs on: http://localhost:5000

### Frontend Setup

```bash
cd frontend-project
npm install
npm start
```

App runs on: http://localhost:3000

---

## Entity Relationship Diagram (ERD)

### Entities & Relationships:

**PRODUCT** (ProductID PK, ProductName, Category, Quantity, UnitPrice, TotalPrice)  
**SALES** (SalesID PK, ProductID FK, SoldQuantity, SoldUnitPrice, SoldTotalPrice, SalesDate)  
**STOCKSTATUS** (StockID PK, ProductID FK, SalesID FK, AvailableQuantity, SoldQuantity, RemainingQuantity)

**Relationships:**
- PRODUCT has many SALES (1 to many)
- PRODUCT has one STOCKSTATUS (1 to 1)
- SALES updates STOCKSTATUS (1 to 1)

---

## Features

- ✅ Session-based authentication with encrypted passwords (bcryptjs)
- ✅ Full CRUD on Products, Sales, Stock Status
- ✅ Daily Sales Report
- ✅ Daily Stock Status Report (Product Name, Stored Qty, Sold Qty, Remaining Qty)
- ✅ Responsive UI with Tailwind CSS
- ✅ Axios integration (React ↔ Node.js)
- ✅ MongoDB with Mongoose ORM
- ✅ Auto stock tracking on every sale

---

## Default Login

After running the app, register via: http://localhost:3000/login → "Register"

**Suggested credentials:**
- Username: `admin`
- Password: `Admin@2026!` (meets strong password policy)

---

## Tech Stack

| Layer      | Technology                     |
|------------|-------------------------------|
| Frontend   | React.js 18, Tailwind CSS      |
| Backend    | Node.js, Express.js            |
| Database   | MongoDB, Mongoose              |
| Auth       | express-session, bcryptjs      |
| HTTP Client| Axios                          |

---

## Cleanup (After Assessment)
> **⚠️ Ask permission from assessor BEFORE removing project.**

```bash
# Remove project folder
rm -rf FirstName_LastName_National_Practical_Exam_2026

# Drop MongoDB database
mongosh --eval "use dab_enterprise; db.dropDatabase()"
```
