# Project plan — ipw-php

Evidence date: 2026-10-11.

Source of implementation truth: `git@bitbucket.org:overdrive/ipw-php.git`, branch `main`, commit `054883d9` (2026-09-28, “auditor score alignment”).

The onboarding snapshot recorded commit `eda1a748` (2026-09-23, “pipeline fix”). `main` has moved one commit past that snapshot. History reviewed here is the last 80 commits on `main` (2026-08-27 through 2026-09-28). Commits older than that window were not inspected.

There was no existing `silicon_ark/ipw-php/` documentation set. The application repository already contains product and technical notes. Those notes disagree with each other. This plan treats the CodeIgniter 4 tree as what is implemented, and marks older notes when they describe a different codebase.

## Product

IPW is the Integrated Production of Wine programme. `ipw-php` is the web application members and IPW staff use to manage producer groups, self-assessments, IPW audits, SEV audits, scores, probation, SAWIS compliance, certificates, documents, and public IPW content.

Provenance: **Documented** in `README.md` feature list and `knowledgeBase/Overview.md` title. The running application is the CodeIgniter 4 project under `app/`, `public/`, and `spark`, not the `livesite/` and `system/` paths named in `knowledgeBase/Overview.md`.

## Objectives visible in the repository

| Objective | Evidence | Provenance |
|---|---|---|
| Replace or match the live IPW site (`ipw.co.za`) for members, auditors, and administrators | `scope/IPW_FEATURE_COMPARISON.md`, `scope/FEATURE_VERIFICATION_SUMMARY.md` | Documented. The comparison claims feature parity. That claim was not re-tested against the live site in this review |
| Keep farm and cellar evaluation scoring aligned with the legacy scheme, including a 70% farm pass and a 65% cellar A/B/C pass | `app/Config/ScoringRules.php`, `README.md` | Implemented, and documented in the README |
| Keep probation behaviour aligned with the legacy `ipw_old` rules, and only then enable the rewrite module | `knowledgeBase/ProbationManagement.md` | Documented against `App\Services\ProbationLifecycle` |
| Read producer, farm, and SO2 data from SAWIS BIS without writing to BIS | `BIS_INTEGRATION_README.md` (legacy paths), `app/Services/BisService.php`, `standalone-api/` | The read-only rule is documented for the legacy ODBC client. The current PHP service forces the standalone API path. See technical documentation |
| Run scoring tests and a SonarQube scan on `main` and on pull requests | `bitbucket-pipelines.yml` | Implemented in pipeline config |

The January 2025 scope (`scope/IPW_Audit_Platform_Scope.md`) states goals that were then still to be built: three audit types, an automatic auditor copy when a producer submits, a consolidated history page, relationship navigation, and documents linked to an audit. Some of that is now in code (application types 0, 1, and 2). An automatic copy-on-submit was not found in `MemberEvaluations`. Treat the rest of that scope as **Planned** unless a later requirement cites a specific controller.

## Scope

### In the current application

- Public IPW content pages and legacy `*.php` bookmarks that show a moved-page notice (`LegacyRedirect`, `PublicRoutes`).
- Login, registration, forgot-password, and reset-password. Two-factor routes exist only as comments.
- Staff and member user administration, groups, SAWIS numbers, group merge, and SAWIS-number transfer.
- Evaluation form templates and member submissions (self-assessment, IPW audit, SEV audit).
- Scoring, spray-programme appendices, optional farm Table B, certificates, probation, SAWIS compliance, audit lists, reports, laboratory analysis, SO2 reports, and document upload/download.
- English and Afrikaans UI strings (`app/Helpers/language_helper.php`).
- Role and route policy on top of login (`RoutePolicy`, `Authorization`).

### Out of scope for this knowledge update

- Changing the `ipw-php` source repository.
- Deciding whether legacy knowledge-base pages should be rewritten inside `ipw-php`.
- Confirming which environment (production `ipw.co.za`, staging, or another host) is the customer-facing system.

### Explicitly called out of an older project scope

`scope/IPW_Audit_Platform_Scope.md` (January 2025, “Ready for Client Review”) lists these as future phases, not that project: automatic removal of sections that do not apply, advanced scoring-rule changes, a mobile-specific redesign, extra user roles beyond auditor/admin, and a weekly automatic external sync. Later commits do change scoring, mobile layout, and permissions. Those later commits override the January 2025 “out of scope” list for the code that exists now. Whether the client still treats those items as out of scope is **Unknown / Requires Confirmation**.

## System shape

```text
Browser
  → public/ (web root)
  → CodeIgniter 4 (spark, app/Controllers, app/Config/Routes.php)
  → Filters: maintenance, language, login, route policy, menu grant, hidden staff pages
  → MySQL via MySQLi (local database)
  → SAWIS BIS (read): BisService → standalone HTTP API (forced in code) or ODBC (class still contains a direct PDO path)
  → Mail via CodeIgniter email service
  → PDF via mPDF; spreadsheets via PHPSpreadsheet; CSV via league/csv
```

Major components and where they live:

| Component | Location |
|---|---|
| HTTP controllers | `app/Controllers/` |
| Domain services | `app/Services/` |
| Scoring policy | `app/Config/ScoringRules.php`, `LegacyScoringMatrix.php`, `SprayProgrammeScores.php`, `CellarTypes.php` |
| Access policy | `app/Config/RoutePolicy.php`, `RoutePolicyGrants.php`, `app/Filters/` |
| Persistence | `app/Models/`, `app/Database/Migrations/`, `db_schema.sql` |
| CLI | `spark`, `app/Commands/` |
| BIS bridge that does not depend on CodeIgniter | `standalone-api/` |
| Public assets and uploaded audit files | `public/` |

## Implementation status

The repository is an active CodeIgniter 4 application on `main`, not a greenfield starter. `composer.json` still says the package description is “Transactflow” and `php: ^8.0`. `README.md` and the pipeline image say PHP 8.3. That conflict is recorded under technical documentation.

Recent delivery, from commit subjects in the inspected window (not a complete backlog):

| Window | What the commits say changed |
|---|---|
| 2026-08-27 to 2026-08-28 | Member RBAC, menu order, certificates farm/cellar column, document categories, self-assessment, probation, spray-product upload, data-leak fix |
| 2026-09-01 to 2026-09-04 | Certificate PDF layout, ownership transfer, document performance, email and mobile layout, SAWIS compliance, self-assessment |
| 2026-09-07 to 2026-09-17 | Permissions, large document sets, scoring and filters, SAWIS activation, control products, probation rules loosened, user management |
| 2026-09-21 to 2026-09-28 | Audit issue fix, user-management updates, pipeline fix, auditor score alignment |

No milestone dates beyond those commits are in the repository. Jira board `SI` and Confluence space `AO` are linked from `README.md`. Their current contents were not read.

`knowledgeBase/ProbationManagement.md` says production was not using the rewrite probation module until the legacy-parity cutover, and that `php spark probation:process` should be scheduled only after that code is deployed. Whether that schedule is now live is **Unknown / Requires Confirmation**.

## Dependencies

Runtime packages in `composer.json`:

- PHP platform constraint `^8.0` (pipeline installs `php:8.3-cli`)
- `codeigniter4/framework` `^4.0`
- `aws/aws-sdk-php` `^3.254`
- `mpdf/mpdf` `^8.1`
- `phpoffice/phpspreadsheet` `^5.0` (`README.md` still says `^1.25`)
- `orhanerday/open-ai` `^3.5`
- `league/csv` `^9.16`
- PHP extension `simplexml`

Dev: PHPUnit 9, Faker, vfsStream.

External systems named in code or docs: SAWIS BIS (ODBC and/or HTTPS API), SMTP/SendGrid settings in `env`, OpenAI completions helper, Slack helper, a commented Salesforce helper, and a commented Africa’s Talking SMS helper. AWS SDK is required by Composer. Which AWS services the running product calls was not traced end to end. **Unknown / Requires Confirmation** beyond the dependency being present.

## Known documentation debt inside the source repo

These files are useful history. They are not a safe description of the current routes:

- `overview.md` describes a generic “Transactflow” starter and PHP `^8.0`.
- `knowledgeBase/Overview.md` and `knowledgeBase/RolesAndInteractions.md` cite `livesite/*.php` and `system/*.php`.
- `knowledgeBase/BusinessRules.md` and `knowledgeBase/Certification.md` state rules (virus scanning, encryption at rest, certificate tables, category weights summing to 100%) that were not found as implemented behaviour in the CI4 scoring and certificate code reviewed here.
- `BIS_INTEGRATION_README.md` analyses `system/BIS.php` and `livesite/` SQL. Current BIS access is `App\Services\BisService` plus `standalone-api/`.

Do not copy credentials from those files into new docs. Defaults and hardcoded secrets are called out in `technical-documentation.md` without repeating the secret values.
