# Project plan — sabullion (SA Bullion)

Evidence date: 2026-09-28.

Source repository: `git@bitbucket.org:overdrive/sabullion.git`.

Inspected revision: `master` at `a5cd347` (2024-03-12, "repo update"). The scan-host path `~/projects/sonar_scan/repos/sabullion` was not on this machine. The tree below was read from that git revision. Credential values in `config/dbconnect.php`, `fim_2.0/fim.config.php`, and `webadmin/validateFNBPayment.php` are omitted from this document.

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

## Product

**SA Bullion** is a South African specialist gold-bullion service. Public copy says it converts cash into newly minted Krugerrands, holds them in the client's name, and lets clients manage the holding online. Two named facilities appear throughout the public pages: **BullionGold** and **HasanaGold** (older filenames and comments still say Baraka). HasanaGold is described as a Halaal facility.

Provenance: **Documented** in `content/home-content.txt`, `content/about-story.txt`, and `content/baraka-pricing-feat.txt`.

The about story names founders Hilton Davies, Helen, Imran, and Clint, and says the firm was built with Rand Refinery and "the authorities". Provenance: **Documented** in `content/about-story.txt`. The legal name used in the client mandate template is **SA Bullion I.S.** Provenance: **Documented** in `templates/all/client-mandate.php`.

The site name constant is `Sa Bullion` (`config/site.php`). The public host selected for the live `SERVER_NAME` is `https://sabullion.co.za`.

## Branch reality

| Line | Tip | Date | What it is |
|---|---|---|---|
| `master` (default; `origin/HEAD`) | `a5cd347` | 2024-03-12 | Custom PHP public pages, client dashboard, and Nemo `webadmin`, plus a nested WordPress tree under `magazine/` and a root `.wpress` backup |
| `origin/php8.1` | `bbf8065` | 2023-07-11 | Ancestor of `master`. `master` is 3 commits ahead; `php8.1` has no commits of its own |
| `origin/development` | `fcabece` | 2021-03-01 | WordPress site at the repository root. README: "New SA Bullion WordPress website." Temp URL recorded there: `sabullion.co.za.www18.jnb2.host-h.net` |

`master` and `development` diverged. `git rev-list --left-right --count origin/master...origin/development` reports 29 commits only on `master` and 891 commits only on `development`.

Recent `master` history that still describes product work:

- `a5cd347` (2024-03-12, Rachel Mogano) — "repo update".
- `bfdeb94` (2023-10-24, Uriel Balela) — "PHP 8.1 update".
- `f98ae21` (2023-10-19, Uriel Balela) — "web admin php 8.1 update".
- `bbf8065` / `ebd7e4e` (2023-07) — facility application form changes.
- `e5fe893` (2023-03-28) — storage facility changes.
- `642b0da` (2023-03-13) — "Wordpress cleanup". This commit is the last history touch of root `index.php`.

**Discrepancy:** `master` has no root `index.php`, but root `.htaccess` is a WordPress rewrite that sends requests to `/sabullion/index.php`. `development` is a WordPress tree and stopped in March 2021. `master` also contains `sabullion.co.za-20240215-172951-8h6xci.wpress` (filename date 15 February 2024). Which tree is served at `https://sabullion.co.za` is **Unknown / Requires Confirmation**.

The task-creation scan listed `sonar-project.properties` and `sonarqube_scan.bat` at the repository root. Neither file is in git history. Provenance: **Unknown** — they may have been untracked files on the scan host.

## Objectives (inferred from the site and admin, not from a written plan)

No project plan or requirements document exists on `master`. `development` has only the two-line README above. The following objectives are **Inferred** from copy and from the implemented screens:

- Let a person invest a lump sum or a monthly debit order in physical Krugerrands (BullionGold), including a Halaal variant (HasanaGold).
- Let a person buy Krugerrands from SA Bullion or sell Krugerrands to SA Bullion, and schedule a drop-off.
- Take client and independent-financial-adviser (IFA) applications, collect FICA-style documents, and approve them before the person becomes an active client.
- Give clients, IFAs, "houses", and a global admin an online portfolio (statements, team, calculators).
- Give staff a back office (`webadmin`) for registrations, users, prices, stock, gold sales, storage-facility deliveries, appointments, and audit.
- Publish gold pricing, a magazine, partner pages, and downloadable brochures.

## Scope

### In scope of `master`

- Public PHP pages under `investment/`, `savings/`, `krugerrand/`, `gold-pricing/`, `partner/`, `mandate/`, `terms/`, `POPINotice/`, `scheduler/`, `downloads/`, and `Krugerrand-Fractional-Ownership-Programme/`.
- Marketing copy in `content/`.
- Client / IFA / house portal in `dashboard/`.
- Staff application in `webadmin/` on the Nemo class framework (`webadmin/_framework/`).
- File-integrity tool in `fim_2.0/`.
- Nested WordPress install in `magazine/` (theme directory `sa_bullion_magazine`, plus the twentyfifteen through twentyseventeen themes, ACF, ACF Repeater, Akismet).
- Vendored libraries: mPDF, PHPMailer, PHPExcel, dompdf, Bootstrap, DataTables, Chart.js, and others under `vendor/`, `vendors/`, and copies inside `dashboard/` and `webadmin/`.

### Out of scope / not in this repository

- The MySQL servers. Connection targets are hardcoded per hostname. The databases are not in git.
- Rand Refinery vault operations. Named in client-facing copy. No refinery API client was found.
- A crontab or other scheduler definition. Cron PHP scripts exist. What invokes them is **Unknown / Requires Confirmation**.
- Automated tests, Docker, and a pipeline file on `master`. `bitbucket-pipelines.yml` exists only in older history and on `development`.
- The contents of the `.wpress` archive. It was not unpacked for this review.

## System architecture

On `master` the runnable PHP application is three surfaces plus two side systems.

### Public site

Each section is its own `index.php`. It loads `config/site.php`, `helpers/requests.php`, `helpers/functions.php`, then a template under `templates/` and a copy file under `content/`. Examples: `investment/bullion-gold/index.php` sets `$PageTemplate` to `/investing/bullion-overview.php` and `$PageContent` to `/bullion-investment-overview.txt`.

Navigation in `templates/includes/sitenav.php` links to directory URLs (`/investment/bullion-gold/`, `/savings/hasana-gold/`, `/krugerrand/buy/`, `/krugerrand/sell/`, `/gold-pricing`, `/downloads`, `/magazine/`, `/partner/`, `/dashboard`). Older `index.php?pageReq=` links remain in menus and in content files. The router that handled `pageReq` was root `index.php`, removed in the WordPress cleanup commit.

### Client dashboard

`dashboard/index.php` requires a session user and redirects to `dashboard/login.php` otherwise. The session value `$_SESSION["USER"]->SYSTEM` selects a sidebar: `GLOBAL_ADMIN`, `HOUSE`, `IFA`, `CLIENT`, or `UNAPPROVED-CLIENT`. Unapproved clients are forced onto `templates/client/docs.php`.

Signup and login are HTTP endpoints under `dashboard/api/signup/` and `dashboard/api/login/`. Calculators are under `dashboard/api/calc/`.

Several dashboard links point at paths that are not directories on `master`: `/the-gold-price/`, `/invest-in-gold/south-african-gold-solutions/`, `/resources/`. Those slugs match a WordPress site more than this PHP tree. Provenance: **Implemented** links; target pages **Unknown / Requires Confirmation**.

### Web admin

`webadmin/index.php` boots Nemo (`_framework/_nemo.cls.php`) and shows dashboard tiles plus two appointment calendars (CT and Bedford). Each back-office area is a `*.php` screen plus an `includes/*.cls.php` class. Menus and security groups are stored in MySQL (`sysSecurityGroup`, `sysMenuLevel2`), so the live menu labels are not in git.

`webadmin/login.php` can mark the session `USER_TYPE` as `GLOBAL_ADMIN`. `dashboard/login.php` skips destroying that session when the referrer is `/webadmin` on the same host, which is how a staff user enters the client portal.

### WordPress magazine and the WordPress backup

`magazine/` is a full WordPress tree, including `wp-config.php`. Root `.htaccess` and the `.wpress` file are a second WordPress presence that is not a working tree of PHP templates. `development` is a third WordPress presence, at the repository root, last committed in 2021.

### File integrity monitor

`fim_2.0/` is Nemo FIM. It walks a directory, records files, compares them to stored master rows, and exposes Ignore / Update actions. It also forces directory mode `0755` and file mode `0644` when it records a path. Config files exist for dev, qa, and live. `fim.config.php` sets `$siteEnviroment = "qa"` while pointing `$FIMBaseURL` at `https://sabullion.co.za/fim_2.0/`. Which config a cron actually includes was not established from `fim.cron.php` (it includes `fim.cls.php` only).

## Environments named in code

`config/site.php` switches on `$_SERVER["SERVER_NAME"]`:

| Host | URL constant |
|---|---|
| `localhost` | `https://localhost/sabullion_current_live` |
| `lamp` | `http://lamp/sabullion` |
| `dev.overdrive.co.za` | `http://dev.overdrive.co.za/sabullion` |
| `sabullion.overdriveqa.co.za` | `https://sabullion.overdriveqa.co.za` |
| `sabullion-staging.overdriveqa.co.za` | `https://sabullion-staging.overdriveqa.co.za` |
| `sabullion.co.za` (also the `default`) | `https://sabullion.co.za` |

A commented line also mentions `sabullion.co.za.dedi773.jnb3.host-h.net`.

## Major components

| Component | Path | Role |
|---|---|---|
| Public pages | `investment/`, `savings/`, `krugerrand/`, `gold-pricing/`, `partner/`, `templates/`, `content/` | Marketing and request wizards |
| Dashboard | `dashboard/` | Client, IFA, house, and global-admin portal |
| Web admin | `webadmin/` | Staff back office on Nemo |
| FIM | `fim_2.0/` | File inventory and permission fixer |
| Magazine | `magazine/` | WordPress |
| Scheduler page | `scheduler/` | "Schedule Drop Off" public page |
| Shared config | `config/site.php`, `config/dbconnect.php` | Host switch and two PDO connections |

## Dependencies known from the tree

- PHP, with a 2023 effort to run on PHP 8.1. `webadmin/index.php` comments "PHP 8". No `composer.json` at the repository root. Libraries are vendored.
- MySQL via PDO. Two connections: `$SA` (called the access database in comments) and `$DBH` (called the web database).
- Sharenet spot page `https://www.sharenet.co.za/v3/spot.php`, scraped by the gold and silver price scripts.
- FNB eCommerce `https://pay.ms.fnb.co.za/eCommerce/v2/validateTransaction` in `webadmin/validateFNBPayment.php`. A sandbox URL under `sandbox.ms.fnb.co.za` is commented out inside `webadmin/cron.gold.price.php`.
- mPDF / dompdf / PHPExcel for documents and spreadsheets.
- PHPMailer for mail.

## Implementation plan and milestones

There is no milestone plan in the repository. The git history is the only sequence, and it is maintenance rather than a roadmap:

1. 2019 — pipeline experiments and the first merge of `development` (`310c903`).
2. 2020-05 — "impliment fim to SABullion QA" (`4fc096f`).
3. 2022-04 — large content, plugin, and admin dumps.
4. 2023-03 — WordPress cleanup, storage facility, product quantity and filters.
5. 2023-07 — facility application form changes.
6. 2023-10 — web admin and PHP 8.1 updates.
7. 2024-03-12 — last commit on `master`.

Nothing in git describes work after 12 March 2024. Planned work is **Unknown**.

## Current project status

`master` is the default branch and has not moved since 12 March 2024. `development` has not moved since 1 March 2021. `php8.1` is contained in `master`.

Status of production deployment is **Unknown / Requires Confirmation**.
