# Project plan — sandwichbaronstore.co.za

Evidence date: 2026-10-04.

Source repository: `git@bitbucket.org:overdrive/sandwichbaronstore.co.za.git`.

Default branch inspected: `master` at `c19a5e7` (2020-06-25, "Add time adjustment beta server API").

This plan describes what the repository contains. It does not decide what the product should become.

There is no README, project plan, or requirements document in the repository or in Silicon Ark. Statements below are recovered from code, configuration, and Git history.

## Product

**Sandwich Baron** online ordering. A registered customer chooses a branch by suburb, builds a sandwich (or other menu item) with modifiers, and places a delivery, collect, or contactless order. The store sends the order to the branch point-of-sale as XML. The branch polls an API for the next queued order and posts status updates back. Customers pay by cash on delivery (when the branch allows it), card (NuPay), or EFT (FastPay / `branchFastPay`), and receive email when the status changes.

Provenance: **Implemented** on `master`. The public name "SANDWICH BARON" is written on the refund page (`refund.php`, policy text dated 3 November 2009). Provenance of that page: **Documented** in the page copy.

The POS integration is referred to in code and comments as KingPOS / Kpolo (`kpoloUsername`, `kpoloEnableCash`, KingPOS XML import crons). Provenance: **Implemented**.

## Branch reality

History on the remote is short. The first commit is `d8ad539` (2020-01-15, "initial commit of full repository"). `master` has 25 commits and stopped on 2020-06-25. Later work continued on `dev` and `qa`.

| Line | Tip | Date | What it is |
|---|---|---|---|
| `master` (default; `origin/HEAD`) | `c19a5e7` | 2020-06-25 | Online store as last merged to the default branch. Check-in time uses `Now()`. |
| `origin/dev` | `254187a` | 2021-08-24 | Same product plus later fixes: Dispatch status, Google Tag Manager, minimum-order calculation change, public-holiday import fix, and other edits. Check-in time still uses `Now()`. |
| `origin/qa` | `2ea1d4d` | 2020-09-17 | Merge of `dev` into `qa`, plus commit `33ff936`. Branch check-in uses `DATE_ADD(Now(), interval 2 hour)`. |
| `origin/dev-collect` | `c19a5e7` | 2020-06-25 | Same commit as `master`. |
| `origin/dev-add-tracking` | `72f2b8d` | 2020-09-17 | Included in `dev` (body-tag fix). Not the tip of `dev`. |
| `origin/dev-dispatch-status` | `b622b16` | 2020-07-27 | Included in `dev` and `qa`. Not the tip of either. |
| `origin/dev-contactless-delivery` | `c3d3eb8` | 2020-03-18 | Ancestor of `master`. |
| `origin/dev-shutdown-message` | `f3ee6b9` | 2020-03-25 | Ancestor of `master`. A later `master` commit says the lockdown message was reverted. |

`dev` commits that are not on `master`:

- `b622b16` (2020-07-27) — order status `Dispatch` in `API/api.php`, email template name `Dispatch Notification`. Also on `qa`.
- `4d71b98` (2020-09-14) — Google Tag Manager in `layouts/header.incl.php`. Also on `qa`.
- `72f2b8d` (2020-09-17) — closing `body` tag fix. On `dev`. Not verified on `qa`.
- `56891d5` (2020-11-23) — minimum-order calculation. On `dev` only. Not on `qa`.
- `3c0da48` (2021-04-08), `427f017` (2021-07-07) — messages are "no message" and "Various updates". On `dev` only.
- `254187a` (2021-08-24) — public-holiday import skips deleted rows. On `dev` only.

`qa`-only commit `33ff936` (2020-07-27) is titled "Added status Dispatch send email". The diff does not add an email. It comments out `dtLastCheckin = Now()` and enables `dtLastCheckin = DATE_ADD(Now(), interval 2 hour)`. Provenance: **Implemented** on `qa`. The commit title does not match the diff.

Bitbucket Pipelines in `bitbucket-pipelines.yml` deploy only branches named `qa` and `prod`. There is no remote branch named `prod`. `master` and `dev` are not pipeline branches.

Which tree is deployed to `www.sandwichbaronstore.co.za` is **Unknown / Requires Confirmation**.

## Objectives (inferred from the implementation)

No written objectives exist in the repository. The following are **Inferred**:

- Let Sandwich Baron customers order from a branch menu for delivery or collection.
- Hand the order to the branch POS and accept status updates from that POS.
- Take card and EFT payment before the order is queued, and allow cash when the branch enables it.
- Give head office a web admin for users, menus, branches, email templates, imports, and order reporting.
- Import KingPOS / OLO catalogue data into the customer database on a schedule.

## Scope

### In scope of the repository

- Customer PHP site: registration, login, profile, menu, basket, checkout, payment return pages, refund policy page, branch-offline page.
- Branch order API (`API/api.php`) and a test-order API (`API/testorder.php`).
- Web admin (`webadmin/`) for catalogue, branches, users, security groups, settings, email, FAQ, audit, imports, and reports.
- KingPOS XML import cron scripts.
- Order-timeout cron.
- Nemo PHP framework under `_framework/`.
- Vendored PDF and spreadsheet libraries (`dompdf`, `mpdf`, `html2pdf`, `fpdi`, `PHPExcel`).
- AWS CodeDeploy spec (`appspec.yml`) and Bitbucket Pipelines deploy script.

### Out of scope / not in this repository

- The MySQL databases. Schema and live rows are not in Git. `DB Update Scripts/` contains no `.sql` files.
- The KingPOS / Kpolo application that polls the API.
- NuPay and FastPay. This repo only posts to them.
- The RDS instance and the CodeDeploy application in AWS. Names are referenced; the AWS account is not in Git.
- A customer mobile app. None is in the repository.
- An automated test suite for this application. Test files under `webadmin/vendors/` belong to third-party libraries.

## System architecture

One PHP application, two MySQL databases, selected by HTTP host.

```text
Browser
  → customer PHP (Nemo) on Apache
      → customer database (orders, users, menu, rules)
      → NuPay (card) or FastPay (EFT)

Branch POS (KingPOS / Kpolo)
  → GET API/api.php (branch id + owner credentials [+ status XML])
      → oldest queued order XML returned
      → order status updated from the posted XML

Cron / manual PHP scripts
  → ZIP import of KingPOS XML into web-admin staging
  → copy staging into the customer database
  → fail orders that stay Queued or InProcess too long
```

Web admin connects to both databases (`$DATABASE_SETTINGS` for web admin, `$DATABASE_SETTINGS_CUSTOMER` for the store). The customer site connects only to the customer database. Provenance: **Implemented** (`system.php`, `webadmin/system.php`).

### Hosts configured in code

Active (not commented) host keys on `master`:

| HTTP host key | Customer database name | Web-admin database name |
|---|---|---|
| `debian` / `debian.net` | `sandwich_baron_customer` | `sandwich_baron_webadmin` |
| `lamp` | `sandwich_baron_customer` | `sandwich_baron_webadmin` |
| `dev.overdrive.co.za` | `sand_baron_customer` | No matching host key in `webadmin/system.php` |
| `beta.sandwichbaronstore.co.za` | `beta_customer` | `beta_webadmin` |
| `www.sandwichbaronstore.co.za` | `sbolocustomer` | `sbolowebadmin` |

`sandwichbaronstore.co.za` is rewritten to `www.sandwichbaronstore.co.za`. An empty `SERVER_NAME` is also forced to the www host. Provenance: **Implemented**.

Database usernames and passwords are hardcoded in `system.php` and `webadmin/system.php`. They are **not copied into this document**. See technical documentation.

Beta and www entries point at the same RDS hostname in `eu-west-1` and set `SERVER_PROTOCOL` to HTTPS. A commented block still shows an older localhost production configuration. Provenance: **Implemented** as source configuration. Which block matches the server that is actually running is **Unknown / Requires Confirmation**.

## Major components

| Component | Role | Evidence |
|---|---|---|
| Customer storefront | Register, sign in, menu, basket, checkout | `client.*.php`, `login.php`, `includes/client.*.cls.php` |
| Checkout and payment | Delivery method, cash / card / EFT, NuPay and FastPay | `client.order.confirm.php`, `payment/`, `paymentSuccess.php`, `paymentEFTNotify.php` |
| Order API | Branch poll and status update | `API/api.php` |
| Web admin | Catalogue, branches, users, reports, imports | `webadmin/` |
| Rules | Timeouts, minimum order, email-from, delivery charge id | `oloRuleProvider` via `project.functions.inc.php` |
| Import | KingPOS ZIP to customer tables | `webadmin/cron.daily.import*.php` |
| Deploy | CodeDeploy onto Apache | `appspec.yml`, `bitbucket-pipelines.yml`, `codedeploy_deploy.py` |

## Milestones visible in Git

There is no milestone plan. The commit sequence on `master` is the implementation record:

1. 2020-01-15 — full repository imported.
2. 2020-01-20 — EFT success uses the notify page; cancelled payments use order status `-3`; status becomes Queued only when the current status is NotPaid (`-1`).
3. 2020-01-21 to 2020-02-14 — test-order API.
4. 2020-03-12 to 2020-03-18 — card payment logging; NuPay test portal switched to live; contactless delivery.
5. 2020-03-23 to 2020-03-27 — card gateway pointed at a testing portal, then a shutdown message added and the lockdown message reverted.
6. 2020-04-14 — "Changes for prod".
7. 2020-06-10 to 2020-06-25 — collect option, then the beta check-in time adjustment (left commented on `master`).

After `master` stopped: Dispatch and Tag Manager (mid-2020, on `dev` and `qa`), minimum-order change (November 2020, `dev` only), public-holiday import fix (August 2021, `dev` only).

## Implementation plan

No forward plan is in the repository. Current project status is a maintained legacy PHP store whose default branch has not moved since June 2020, while `dev` moved until August 2021.

## Known dependencies

- PHP with mysqli, sessions, and Apache (`httpd` in the CodeDeploy hooks). PHP version is **Unknown / Requires Confirmation**. The pipeline image is `python:3.5.1` and is used only to zip and deploy.
- MySQL / MariaDB, two databases per environment.
- Nemo framework (in-repo).
- NuPay card gateway and FastPay EFT (`branchFastPay`).
- KingPOS / Kpolo at each branch.
- AWS CodeDeploy, S3, and RDS (names in source and pipeline variables).
- Bitbucket Pipelines variables: `QA_*` and `PROD_*` for AWS keys, region, CodeDeploy application, deployment group, and S3 bucket. Values are not in Git.

## Current project status

| Item | State |
|---|---|
| Default branch | `master` at `c19a5e7`, 2020-06-25 |
| Newest product commit | `origin/dev` at `254187a`, 2021-08-24 |
| Pipeline branch that exists | `qa` (2020-09-17). `prod` is named in YAML and is absent |
| Silicon Ark docs before this change | None |
| Application tests | None in the product code |
| Open product questions | Which branch is live; whether Dispatch, Tag Manager, and the 2020 minimum-order change are in production |
