# Project plan — findndrive_pwa

Evidence date: 2026-10-15. Source repository: `git@bitbucket.org:overdrive/findndrive_pwa.git`.

Inspected revision: `master` at `d61d13b` (2023-08-08 16:08:01 +0200, author Dirk, subject "adding tier to app session and readd login"). `origin/HEAD` points at `master`. The only remote branch is `origin/master`. The scan-host path recorded on the onboarding issue was not on this machine. The tree was read from a full clone of that revision.

There is no prior Silicon Ark directory for this project. There is a related directory `silicon_ark/findndrive_webportal/` for the admin and `CarApi` server. This plan does not change that directory.

## What this repository is

`package.json` names the package **fnd**, version `0.0.1`, private. `index.html` titles the page **Find&Drive**. The repository name is `findndrive_pwa`.

Implemented behaviour is a React 18 single-page application, built with Vite, that walks a signed-in visitor through a vehicle-loan simulator: monthly budget and body style, model, monthly kilometres, a tiered cost-of-ownership card, a finance calculator, salary and expenses, a risk breakdown, then either apply, fix-my-credit, or a recommended alternative. Instalments, insurance, fuel, and risk bands are calculated in the browser. Each step is also posted to `CarApi` on `https://admin.findndrive.co.za`.

Provenance: **Implemented**. A written product goal beyond the on-screen copy was not found. No README exists in the repository.

The tree has no web app manifest and no service worker. The name says PWA. The implementation is a Vite SPA. Whether an installable PWA was intended is **Requires Confirmation**.

## Objectives visible in the repository

| Objective | Evidence | Provenance |
|---|---|---|
| A visitor signs in before any journey screen | `App.jsx` renders `Login` until `loged_in` is truthy | Implemented |
| The visitor sets a monthly amount and a body style, then a model and monthly kilometres | `SelectACar`, `SelectModel`, `AverageUsage` | Implemented |
| The visitor sees repayment, insurance, and fuel for a tiered example car | `CostOfOwnership1`, `GetCarTiers` | Implemented |
| The visitor calculates an instalment from deposit, credit answer, term, and balloon | `Calculator`, `FinanceCalculate` | Implemented |
| The visitor enters salary, debt, living costs, and savings, then sees a risk breakdown | `ChancesOfApproval`, `ResultOptions`, `RiskLevelCalculation` | Implemented |
| Apply, fix-my-credit, or a cheaper recommendation can be posted back to the API | `Congratulations`, `FixMyCredit`, `SelectModelRecommended` | Implemented |
| Production builds deploy from `master` to S3 and invalidate CloudFront | `bitbucket-pipelines.yml` | Implemented |

## Scope

In this repository:

- React pages and styled-components under `src/pages` and `src/components`.
- In-memory journey state in `FormContext` and `AppContext`.
- Browser formulas in `src/util`.
- Axios posts to `CarApi` step methods.
- A Bitbucket Pipelines file that builds with Vite and deploys `dist/` from `master`.
- A SonarQube project key in `sonar-project.properties`. The pipeline does not run a scan.

Not in this repository:

- The `CarApi` server, the vehicle catalogue, and the staff admin. Those live in `findndrive_webportal`.
- A loan application that is submitted to a bank. Apply and fix-my-credit post a session payload and show a completion screen.
- A database, queue, or background worker.
- An installable PWA shell (manifest, service worker, offline cache).
- Automated tests. `npm run test` is not a script. The `master` pipeline comments that command out.

## Architecture

```text
Browser (Vite + React 18 SPA)
        |
        +-- Login gate (in-memory flag)
        +-- Four-step journey UI
        +-- Local formulas (finance, insurance, fuel, risk, maintenance timing)
        |
        v
POST CarApi/<step>
        |
        +-- production build: https://admin.findndrive.co.za/CarApi/<step>
        +-- vite dev: same host via the /CarApi proxy
        |
        v
findndrive_webportal (separate repository)

Also, on the price-range screens only:
GET https://geolocation-db.com/json/
```

State is React context. A refresh clears the login flag, the UUID `app_id`, and the journey. Nothing is written to `localStorage` or `sessionStorage`.

## Major components

| Area | Role |
|---|---|
| `src/App.jsx` | Route table. Logged-out visitors only see `Login`. |
| `src/context/AppContext.jsx` | Payload fields posted to `CarApi`, including a new `app_id` UUID |
| `src/context/FormContext.jsx` | Screen state: selections, money inputs, `loged_in`, default prime `12.75` |
| `src/context/UserContext.jsx` | `user` and `age`. No page reads it |
| `src/util/ApiCall.js` | POST helper |
| `src/util/FinanceCalculate.js` | Instalment, fees, balloon, interest |
| `src/util/RiskLevelCalculation.js` | Risk bands and `canApply` |
| `src/pages/*` | One screen per route |
| `bitbucket-pipelines.yml` | `master` build and S3/CloudFront deploy; manual `staging` pipeline; `dev` install-only |

## Milestones visible in Git history

History runs from the initial commit `c24c68d` (2023-05-21, Jaco Brits) to `d61d13b` (2023-08-08). There are no tags. Authors in the log are Jaco Brits, Dirk, and RDvanRooyen.

| Period | What landed | Provenance |
|---|---|---|
| 2023-05-21 | Initial commit | Git history |
| 2023-06 | Extra screens and pipeline updates | Git history |
| 2023-07-06 to 2023-07-18 | Layout, select-a-car, calculator, result and congratulations screens, Vite build output `dist/` | Git history |
| 2023-07-19 to 2023-07-27 | Formulas, API posts, login page, maintenance and services, fix-my-credit | Git history |
| 2023-07-28 | Login page disabled (`cb14500`) | Git history |
| 2023-07-31 to 2023-08-08 | Tier filtering, debt and living-expense fields, login page restored | Git history |

No commit after 2023-08-08 was on `origin/master` at inspection time. Whether the S3 site is still served is **Unknown**.

## Implementation plan

No roadmap, issue tracker, or TODO document is in the repository. Commented-out code shows work that was started and then turned off:

- Header search, login button, and links to Home, About, Services, and Contact.
- "How it works" and "Watch an explainer video" buttons.
- Redirect to fix-my-credit when the recommended model list is empty.
- Maintenance and service month caps (6 months, 36 months, and a 75,000 km skip).

Those are **not** current behaviour. Whether any of them is still planned is **Requires Confirmation**.

The fix-my-credit screen copy says "Credit assistance tool coming soon!" Provenance: **Implemented** copy. A later tool is **Planned** only as that sentence. No implementation of the tool is in this repository.

## Known dependencies

| Dependency | Where | Notes |
|---|---|---|
| `https://admin.findndrive.co.za/CarApi/*` | `ApiCall.js`, `vite.config.js` | Production host and the dev proxy target |
| `https://geolocation-db.com/json/` | `SelectACar`, `SelectModelRecommended` | Country, city, state, postal code, IPv4. Failure sends the visitor to the error screen |
| Node image `node:16.15.0` | `bitbucket-pipelines.yml` | Pipeline image only |
| React 18.2, React Router 6.11, Vite 4.3, Axios 1.4, styled-components 6 rc, react-bootstrap 2.7, react-uuid 2 | `package.json` | |
| AWS S3 and CloudFront | pipeline pipes | Bucket name and distribution id are pipeline variables. Values are not in the repo |
| Absa visual assets and footer legal text | `src/assets`, `Footer.jsx` | Partner status beyond the assets and copy is **Requires Confirmation** |

## Current project status

- Single branch `master`, last commit 2023-08-08.
- Login gate is on (restored in the last commit).
- Journey formulas and `CarApi` posts are present.
- No test suite, no README, no environment sample file.
- `master` deploy path is `dist/`. The manual `staging` pipeline still publishes `build/` and runs `npm run test`, which is not a script. Staging and production pipeline definitions disagree.
- Sonar project key is recorded. No scan step is in the pipeline. `sonarqube_scan.bat` was listed on the onboarding issue's scan-host snapshot and is not in this Git tree.

## Human confirmation

- Is Find&Drive still a live product, and is this `master` what production serves?
- Was an installable PWA required, or is the Vite SPA the product?
- Are the hardcoded prime rates, fees, fuel price, and insurance percentages still the approved figures?
- Should `findndrive_webportal` documentation be updated to name this repository as the `CarApi` client? That directory still describes the client as unknown.
