An open API service indexing awesome lists of open source software.

https://github.com/itayshaul111/bgu-mart

Assignment 4 - SPL course, BGU
https://github.com/itayshaul111/bgu-mart

python sql sqlite3

Last synced: about 1 year ago
JSON representation

Assignment 4 - SPL course, BGU

Awesome Lists containing this project

README

          

# ๐Ÿ›’ BGU Mart
**Supermarket Management System โ€“ SPL 2025 @ BGU**

A Python-based inventory and activity management system for supermarket chains, developed as part of the **Systems Programming Lab (SPL)** course at Ben-Gurion University.
The system uses an SQLite3 database to track branches, employees, products, suppliers, and sales/delivery activities.

---

## ๐Ÿ”ง Technologies Used
- **Python 3.9+** โ€“ Core implementation
- **SQLite3** โ€“ Embedded database engine
- **Command-line Interface** โ€“ Standalone scripts for initialization, actions, and reporting

---

## ๐Ÿ’ก Project Structure
```
BGU-Mart/
โ”œโ”€โ”€ bgumart.db # SQLite database (created at runtime)
โ”œโ”€โ”€ initiate.py # Initializes the database from a configuration file
โ”œโ”€โ”€ action.py # Executes activity actions (sales/deliveries)
โ”œโ”€โ”€ printdb.py # Prints database tables and reports
โ”œโ”€โ”€ config.txt # Sample configuration file
โ”œโ”€โ”€ actions.txt # Sample activity input file
โ””โ”€โ”€ README.md # Project documentation
```

---

## ๐Ÿฌ Database Schema

| Table | Description |
|--------------|-------------|
| `employees` | ID, name, salary, and branch assignment |
| `suppliers` | Supplier ID, name, contact information |
| `products` | Product ID, description, price, quantity in stock |
| `branches` | Branch ID, location, and employee count |
| `activities` | Logs of sales and deliveries (product ID, quantity, actor ID, date) |

---

## ๐Ÿ“ฆ Configuration File Format (`config.txt`)

Each line defines one entity using the following format:

| Prefix | Entity | Format |
|--------|------------|--------|
| `B` | Branch | `B,,,` |
| `E` | Employee | `E,,,,` |
| `P` | Product | `P,,,,` |
| `S` | Supplier | `S,,,` |

Example:
```
B,3,Chicago,40
E,106,Sue Davis,75000,3
P,5,Mango,2,7
S,6,Jkl Enterprises,(678) 901-2345
```

> โš  Do **not** insert the record-type prefixes (E, S, P, B) into the database.

---

## ๐Ÿ“ˆ Actions File Format (`actions.txt`)

Format:
```
,,,
```

- `quantity > 0` โ†’ delivery (by supplier)
- `quantity < 0` โ†’ sale (by employee)

Example:
```
3,500,56,20230110 # Delivery from supplier 56
100,-500,1234,20230110 # Sale by employee 1234
```

> โš  Sale is performed only if product stock is sufficient โ€” otherwise, it's ignored silently.

---

## ๐Ÿš€ How to Run

### 1. Initialize the Database
```bash
python3 initiate.py config.txt
```

### 2. Perform Actions
```bash
python3 action.py actions.txt
```

### 3. Print Reports
```bash
python3 printdb.py
```

---

## ๐Ÿ“Š Report Output Formats

### ๐Ÿ‘ฉโ€๐Ÿ’ผ Employees Report
```

```

Sorted by name.

### ๐Ÿ“† Activity Report
```

```

- For delivery: `seller_name = None`
- For sale: `supplier_name = None`

Sorted by date.

---

## ๐Ÿงช Testing
Validate memory and SQL correctness with:
```bash
valgrind --leak-check=full --show-reachable=yes python3 action.py actions.txt
```

---

## ๐Ÿ“š Course Information
- **Course:** SPL โ€“ Systems Programming Lab
- **Institution:** Ben-Gurion University of the Negev
- **Year:** 2025
- **Environment:** Linux CS Lab, SQLite3, Python 3.9+

---

## ๐Ÿง‘โ€๐Ÿ’ป Authors

**Ben Kapon**
Student at BGU
[LinkedIn](https://www.linkedin.com/in/ben-kapon1/)

**Itay Shaul**
Student at BGU
[LinkedIn](https://www.linkedin.com/in/itay-shaul/)

---