# Project plan — magalies-pharma-heisenberg-frontend

Evidence date: 2026-10-09.

Source repository: `git@bitbucket.org:overdrive/magalies-pharma-heisenberg-frontend.git`.

Inspected revision: `master` at `f153f4f` (2026-02-02, Dirk, `dirk@overdrive.co.za`, "adding code changes"). Full hash `f153f4f5d4807c85e49c01a5e5a77c594eff0cc3`. `origin/HEAD` points at `master`. History is 661 commits, from `b1bc0fe` (2021-11-15, Nick Thorby, "Initial commit") to `f153f4f`.

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

No `silicon_ark/magalies-pharma-heisenberg-frontend/` directory existed before this file. Related Heisenberg sets already in Silicon Ark are named under [Related Silicon Ark projects](#related-silicon-ark-projects).

The scan-host path `~/projects/sonar_scan/repos/magalies-pharma-heisenberg-frontend` was not on this machine. Evidence below is from a clone of `origin/master`. OVER-189 (captured 2026-09-28) listed `sonar-project.properties` and `sonarqube_scan.bat` beside the git files. Those two names are not in this clone and are not in `git ls-files` output implied by the tree. Whether they exist only on the scan host is **Unknown / Requires Confirmation**.

## Product

**Documented.** `README.md` titles the project "MagaliesPharma" and says it was generated with Angular CLI 12.2.13. `package.json` names the npm package `magalies-pharma`, version `0.0.0`, private. `src/index.html` sets the browser title to "Magaliesberg Pharmaceuticals". The signed-in dashboard heading is "Hi, Welcome to Magalies Pharmaceuticals" (`src/core/components/dashboard/dashboard.component.html`).

**Inferred.** A staff and customer portal for Magalies Pharmaceuticals (compounding / prescription fulfilment). Signed-in users submit prescriptions, review orders, split them, scan batches during fulfilment, print labels, capture Dawn Wing waybills, maintain a medicine catalogue, run stocktakes, and administer Cognito users. The API host, S3 bucket names, and Cognito settings all use the Heisenberg name.

**Implemented.** An Angular 12 single-page application. The default route redirects to `/portal`, which wraps child screens in an AWS Amplify authenticator (`src/core/components/portal/portal.component.html`). Signup is hidden. Login is by email.

The three names (MagaliesPharma, Magaliesberg Pharmaceuticals, Magalies Pharmaceuticals) are all present. Which legal name is authoritative is **Unknown / Requires Confirmation**.

## Branch reality

| Line | Tip | Date | What it is |
|---|---|---|---|
| `master` (default; `origin/HEAD`) | `f153f4f` | 2026-02-02 | Only branch on the Bitbucket remote. 661 commits, 2021-11-15 through 2026-02-02 |

`git tag -l` printed nothing. `git branch -a` showed `master` and `origin/master` only.

Commit volume by author (`git shortlog -sn`): Patrice Chaula 351, Patrice 144, wezside 115, Nick Thorby 18, Wesley 13, Nick 12, Wesley Swanepoel 6, Dirk 1, Jordan Levy 1. "Patrice" and "Patrice Chaula", and "Nick" / "Nick Thorby", and "Wesley" / "Wesley Swanepoel" / "wezside", are likely the same people. That grouping is **Inferred**.

The previous tip before Dirk's commit was `5acc36e` (2023-05-30, Nick, "fixed environments"). There is a gap of about 32 months, then one commit that touches 133 files (+34,656 / −4,528). The message is "adding code changes" and does not list the features. See `features.md`.

OVER-189 recorded the same tip: `f153f4f`, 2026-02-02, "adding code changes", branch `master`. This clone agrees.

Earlier remotes appear only inside merge messages, including `ssh://exonic/v1/repos/magalies-pharma-heisenberg-frontend` (`03e451c`). Those remotes are not the current Bitbucket `origin`. Whether they still exist is **Unknown / Requires Confirmation**.

## Objectives

No project plan, issue tracker, or product brief is in the repository. `README.md` is the Angular CLI template plus one local note: `set NODE_OPTIONS=--openssl-legacy-provider` before `ng serve`.

**Inferred** from the screens that are routed today:

1. Let a signed-in user submit a prescription (PDF plus patient, prescriber, company, and line items).
2. Let prescription, fulfilment, and packaging staff review, split, fulfil, and ship orders.
3. Let SuperAdmin users see dashboard charts and reports, manage Cognito users, and read logs.
4. Maintain individuals, companies, and a medicine catalogue (dosage type, dosage unit, package type).
5. Count stock by scanning batch barcodes.
6. Print batch barcodes and medicine labels through a local print server, and capture courier waybills through the Heisenberg API.

No written objective states that this list is complete or still approved. **Unknown / Requires Confirmation.**

## Scope

### In scope of `master`

1. The Angular application under `src/` (components, services, guards, resolvers, interfaces, form module).
2. Environment files that point the browser at a Heisenberg HTTP API, Cognito, S3, what3words, Dawn Wing (via the API), and a print server.
3. AWS CodeBuild specs that `npm install`, `ng build`, and `aws s3 sync` the `dist/magalies-pharma` output.
4. Cypress specs for prescription submission, Karma config, and a Puppeteer runner wired as `npm test`.
5. Static assets, including a logo and a terms file whose body is the sentence "Watch this space - Terms & Conditions coming soon".

### Out of scope / not in this repository

- The Heisenberg HTTP API. Call paths are listed in `technical-documentation.md`. Behaviour of those routes is documented separately under `magalies-pharma-heisenberg-serverless`, whose inspected tip is older than this frontend (2023-05-03).
- The Zebra print process. This app posts to it. The print repository is `magalies-pharma-heisenberg-print-server`.
- `sonar-project.properties` and `sonarqube_scan.bat`, named by OVER-189 and absent from git.
- Any mobile app, database migration, or infrastructure-as-code for Cognito, S3, or CloudFront. Those are not in this tree.

## System shape

```text
Browser (Angular 12, Amplify UI)
  ├─ Cognito user pool (email sign-in; groups are roles)
  ├─ Heisenberg HTTP API  (dev execute-api host, or https://api.magaliespharma.com)
  │    orders, medicine, users, batches, fulfilment, stocktake,
  │    waybill proxy, presigned S3 URLs, reports, OTP, logs
  ├─ S3 prescription bucket (upload and download via presigned URLs)
  ├─ what3words HTTP API (address words)
  └─ Print server (POST /label/, /barcode/, /deliverylabel/)
```

Deployment in the CodeBuild files is a static upload to an S3 bucket. Nothing in this repository configures CloudFront, a custom domain, or cache headers. How the bucket is served to browsers is **Unknown / Requires Confirmation**.

## Major components

| Area | Where | Role |
|---|---|---|
| Shell and sign-in | `src/app/app.component.ts`, `src/core/components/portal/` | Amplify config; authenticator; redirect `/portal` to `/portal/dashboard` after sign-in |
| Navigation and roles | `src/core/components/side-nav/`, `src/core/directives/auth-group.directive.ts`, `src/core/guards/role-authorisation.guard.ts` | Menu visibility by Cognito group. Route guard is attached only to `portal` |
| Prescriptions | `src/form/components/client-form/`, `src/core/components/prescription-*`, `src/core/services/prescription.service.ts` | Submit, list, review, view, PDF |
| Fulfilment and batches | `src/core/components/order-fulfilment/`, `batch-*`, `src/core/services/batch.service.ts` | Create batches, link order items, scan, print |
| Shipping | `src/core/services/shipping.service.ts`, `shipping-form`, `waybill-review-orders` | Waybill number, capture, complete, public waybill review |
| Catalogue | `medicine-*`, `individual-*`, `company-*`, `order-medicine-*` | CRUD screens against the API |
| Stocktake | `stocktake-view`, `stocktake-reports`, `stocktake.service.ts` | Count scan and difference / scanned reports |
| Users and logs | `user-*`, `log-list`, `user.service.ts`, `log.service.ts` | Cognito user admin and an audit list |
| Dashboard | `dashboard.component.ts`, `dashboard.service.ts` | Charts and Excel/report downloads for SuperAdmin |

`src/app/prescription/prescription.module.ts` declares `FormComponent` and `ThankYouComponent` and is not imported by `AppModule`. It is not on a route. **Implemented** as unused module source.

## Milestones visible in git

| When | Commit | What landed |
|---|---|---|
| 2021-11-15 | `b1bc0fe` | Initial commit (Nick Thorby) |
| 2021-11-28 | `f20f6cc` | Initial import (wezside) |
| 2021-11-29 to 2023-04 | many | Form, portal, orders, medicine, users, batches, shipping. Not re-listed commit by commit |
| 2023-04-21 | `6f2f520` | Non-admin users should not see the users table |
| 2023-04-25 | `c178dee` | Welcome heading on the dashboard |
| 2023-04-25 | `f333fa4` | Full page reload on sign-in |
| 2023-05-17 | `374b53d` | Waybill number generated by the server |
| 2023-05-30 | `5acc36e` | Environment fix. Last commit before the 2026 gap |
| 2026-02-02 | `f153f4f` | Large update: stocktake, order-medicine, OTP service, prescription form/view, waybill review page, CodeBuild dev/prod specs, dashboard and review rework |

No milestone document assigns dates or owners beyond these commit messages.

## Implementation plan

No roadmap file exists. The working tree on `master` is the plan that was executed. Nothing in git describes work after `f153f4f`.

**Unknown / Requires Confirmation** whether `magalies-pharma-heisenberg-frontend-new` was intended to replace this application. That other repository, documented separately, contains only `.gitignore`.

## Known dependencies

Runtime libraries are in `package.json`. The ones that define product behaviour:

- Angular 12.2, Angular Material 12, Bootstrap 5, RxJS 6.6
- `aws-amplify` 4 and `@aws-amplify/ui-angular` 2 (Cognito sign-in)
- `axios` (present; HTTP calls inspected in services use Angular `HttpClient`)
- `@what3words/api` 4
- `jspdf` and `jspdf-autotable` (order PDF)
- `exceljs` and `file-saver` (spreadsheet downloads)
- `ngx-charts`, `ngx-quill`, `ngx-dropzone`
- Node 14 in all three `buildspec*.yml` files

Build and test: Angular CLI 12.2.13, Karma, Jasmine, Cypress 12.17.4, TypeScript 4.3.

`puppeteer-test.js` requires `puppeteer` and `mkdirp`. Neither name is in `package.json`. **Implemented** as a script that cannot install those packages from this manifest.

## Current project status

**Implemented** and on `master` as of 2026-02-02. Version in `package.json` is still `0.0.0`. No git tag marks a release.

`environment.prod.ts` sets `production: false`. A production build replaces `environment.ts` with that file (`angular.json`) and still does not call `enableProdMode()`, because `src/main.ts` checks `environment.production`. **Implemented.**

Both environment files point Dawn Wing configuration at the UAT base URL and use sender site `TEST01`, what3words `test.test.test`, and placeholder coordinates. The production file does this as well. Whether live couriers use those values is **Unknown / Requires Confirmation**.

CodeBuild bucket names differ across the three specs (`heisenberg-frontend-prod`, `heisenberg-frontend-prod-overdrive`, `sil-heisenberg-frontend-dev`). Which pipeline is attached in AWS is **Unknown / Requires Confirmation**. This repository has no `bitbucket-pipelines.yml`.

## Related Silicon Ark projects

| Directory | What it documents | How this frontend relates |
|---|---|---|
| `magalies-pharma-heisenberg-serverless` | Heisenberg HTTP API, Cognito groups SuperAdmin, Prescription, Fulfilment, Packaging, Customer. Tip `7d003d5` (2023-05-03) | **Inferred.** This app calls paths that match that API (`/order`, `/batch`, `/medicine`, `/user`, `/waybill/*`, `/presigned-url/*`). This frontend also calls `/otp`, `/stocktake/*`, `/ordermedicine`, and `/waybillorder/{n}`, which that older API document set does not name. Whether a newer API revision serves them is **Unknown / Requires Confirmation** |
| `magalies-pharma-heisenberg-print-server` | Express on port 3000, `POST /barcode` and `POST /label`. Tip `07aa3df` (2022-10-19) | **Inferred.** `batch.service.ts` posts to `{printServer}/label/` and `{printServer}/barcode/`. `shipping.service.ts` also posts to `{printServer}/deliverylabel/`. The print-server tree has no `/deliverylabel` route. Trailing slashes and `/deliverylabel/` are **Requires Confirmation** |
| `magalies-pharma-heisenberg-frontend-new` | Bitbucket repo whose only tracked file is `.gitignore` (`a110255`, 2024-11-20) | A different slug. It does not contain this application |

## Human confirmation

- Product owner, live URL, and whether `master` at `f153f4f` is what production serves.
- Whether the 2026 commit was an approved release or an unpublished dump.
- Whether Dawn Wing UAT settings in `environment.prod.ts` are intentional.
- Whether the print server in production is the host `printserver:3000`, and whether it implements `/deliverylabel/`.
- Whether the serverless API still deployed matches the paths this UI calls.
- Fate of the public `/submit` Cypress journey and the `/thanks` route (neither is in `app-routing.module.ts` today).
