# Project plan — intersect_cloud_prod

Evidence date: 2026-10-12.

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

Inspected revision: `main` at `f4affe164d19d6d8eba86cf05b13504af7201bb5` (2025-01-06 17:46:09 +0200, Jaco Brits, "latest update"). `git ls-remote` reports that commit as `refs/heads/main`. `git rev-list --count HEAD` is 1. There are no other branches and no tags on the remote.

The scan-host path `~/projects/sonar_scan/repos/intersect_cloud_prod` was not on this machine. The tree below was read from that git revision.

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

No `silicon_ark/intersect_cloud_prod/` directory existed before these files. Silicon Ark already has `intersect_cloud_v2/` and `intersect_lambda/`. Those are different repositories. See [Related repositories](#related-repositories).

## Product

The Flutter package name is `simpleflow_hub`. The Material app title, Android label, and iOS display name are **Simpleflow Hub**.

Provenance: **Implemented** in `pubspec.yaml` (`name: simpleflow_hub`), `lib/main.dart` (`title: 'Simpleflow Hub'`), `android/app/src/main/res/values/strings.xml`, and `ios/Runner/Info.plist`.

The README title is also "Simpleflow Hub", then the FlutterFlow starter sentence "A new Flutter project." It does not describe customers, workflows, or goals. Provenance: **Documented**, and thin.

The Android application id and iOS bundle id are `co.za.intersectcloud.simpleflowhub`. Deep-link scheme `simpleflowhub` uses host `simpleflowhub.com`. The only configured backend URL is `https://prod-alb.simpleflowhub.app`. Provenance: **Implemented**.

What the product does, from the screens and tables that are actually wired:

- A signed-in user works inside one tenant. System admins can switch tenant.
- The shell is Dashboard, Process Hub, notifications, tasks, messages, and a "more" bar on small screens.
- Process Hub shows the processes linked to the current tenant and opens a matching form list (job cards, inspections, bookings, pest-control reports, quality reports, tickets, documents).
- Admins manage tenants, users, and clients. Tenant admins manage their own users.
- The web build is what the pipeline deploys. Android, iOS, and Windows projects are in the tree.

Who the commercial customers are, beyond names compiled into the code (Pest Elite, Plateau), is **Unknown / Requires Confirmation**.

## Branch reality

| Line | Tip | Date | What it is |
|---|---|---|---|
| `main` (only remote branch) | `f4affe1` | 2025-01-06 | Entire Flutter app in one commit message: "latest update" |

The onboarding issue (OVER-161, captured 2026-09-28) recorded the same tip and the same message. This clone agrees.

History before that commit is not on the remote. Whether earlier commits were squashed, or this repository was created as a single export, is **Unknown / Requires Confirmation**.

## Objectives (inferred from the app, not from a written plan)

No project plan or requirements document exists in the repository. The following are **Inferred** from the implemented screens:

- Give each tenant a branded workspace (logo and colours stored on the tenant).
- Run operational processes: tasks, job cards, inspections, bookings, documents, assets, support tickets, and messages.
- Carry tenant-specific form packs in the same app. The packs visible in code are a general set, a Pest Elite pest-control set, and a Plateau quality-report set.
- Let a system admin operate across tenants, and a tenant admin operate inside one tenant.
- Publish the Flutter web build to AWS (S3 and CloudFront).

## Scope

### In scope of `main`

- Flutter app `simpleflow_hub` version `1.0.0+1`, generated largely by FlutterFlow (custom-action headers say so).
- Targets present as projects: Android, iOS (including an `ImageNotification` extension), web, and Windows.
- Supabase client: auth, PostgREST table classes, storage uploads, and a small set of RPC calls.
- Custom Dart for PDF generation, signatures, file upload, OTP helpers, theme colours, and HTML placeholder replacement.
- Bitbucket pipeline that deploys `build/web` to S3 and invalidates CloudFront.
- A committed `build/` tree, including `build/web`. `.gitignore` comments out `/build/`, so the build output is tracked.

### Out of scope / not in this repository

- The Supabase database itself: SQL migrations, RLS policies, Edge Functions, and the bodies of the RPCs the app calls. Only the client calls and generated row classes are here.
- The AWS account, S3 bucket name, CloudFront distribution id, and OIDC role. Those are pipeline variables (`$AWS_PROD_ARN`, `$AWS_REGION`, `$AWS_S3_BUCKET`, `$DISTRIBUTION_ID`).
- Store listings. Nothing in git says the Android or iOS app is published.
- `intersect_cloud_v2` and `intersect_lambda`. See below.
- `sonar-project.properties` and `sonarqube_scan.bat`. OVER-161 listed both at the repository root. Neither file is in `f4affe1`. `.gitignore` does not match those names.

## System architecture

```text
Browser / Android / iOS / Windows
        │
        ▼
Flutter app (simpleflow_hub)
  go_router pages, FlutterFlow widgets, FFAppState
        │
        ▼
https://prod-alb.simpleflowhub.app
  Supabase auth (implicit flow) + PostgREST + storage + realtime
        │
        ▼
Postgres tables and RPCs (not in this repo)

Web deploy path (pipeline on main):
  committed build/web  →  S3 ($AWS_S3_BUCKET)  →  CloudFront invalidation
```

The pipeline's compile step is commented out. The step that runs is deploy-only. Provenance: **Implemented** in `bitbucket-pipelines.yml`.

## Major components

| Component | Where | Role |
|---|---|---|
| App shell | `lib/main.dart` | Splash, auth stream, theme, bottom nav on phone (Home, Process Hub, Notifications, Tasks, More) |
| Router | `lib/flutter_flow/nav/nav.dart`, `lib/index.dart` | Named routes. Logged-out `/` shows Login |
| Auth | `lib/pages/auth/`, `lib/auth/supabase_auth/` | Email sign-in, forgot password, reset password, create-password page |
| Tenant session | `FFAppState` in `lib/app_state.dart` | Current tenant, system role, tenant role, colours, persisted in secure storage |
| Process Hub | `lib/pages/process_hub/process_hub/` | Tenant processes and the form lists those processes open |
| Management | `lib/pages/management/` | Tenants, users, clients. Routed pages live here |
| General forms | `lib/pages/general_forms/` | Routed tasks, assets, calendar, documents, support tickets |
| Pest Elite forms | `lib/pages/pest_elite/` | Site forms, checklists, bookings, tickets, documents |
| Plateau forms | `lib/pages/plateau/` | Service, non-conformance, and corrective-action reports |
| PDFs and signatures | `lib/custom_code/` | Client-side PDF builders and signature pads |
| Data client | `lib/backend/supabase/database/tables/` | 109 generated table/view classes |
| API calls | `lib/backend/api_requests/api_calls.dart` | Direct PostgREST and RPC calls using the anon key |

## Milestones visible in git

| When | Commit | What landed |
|---|---|---|
| 2025-01-06 | `f4affe1` | Single commit, message "latest update". Full app as inspected here |

No earlier or later milestone is on the remote.

## Implementation plan

There is no forward plan in the repository. Current status: **one commit on `main`, last changed 2025-01-06, web deploy pipeline present, database and cloud resources outside this repo**.

## Known dependencies

Runtime (selected; full pin list is `pubspec.yaml` / `pubspec.lock`):

- Flutter SDK `>=3.0.0 <4.0.0`. `.metadata` revision `4d7946a68d26794349189cf21b3f68cc6fe61dcb`, channel stable. The pipeline downloads Flutter 3.10.0 and then runs `flutter upgrade`.
- `supabase_flutter` 2.6.0, `go_router` 12.1.3, `provider` 6.1.2, `flutter_riverpod` (declared; app state uses Provider).
- `pdf`, `pdfx`, `signature`, `file_picker`, `image_picker`, `flutter_secure_storage`, `hive`, `sqflite`.
- Barcode scanner and colour picker from FlutterFlow git refs.

Deploy:

- Bitbucket Pipelines, Atlassian S3 deploy pipe 1.1.0, CloudFront invalidation pipe 0.10.1, AWS OIDC.

## Related repositories

| Repository | Relationship |
|---|---|
| `intersect_cloud_v2` | Empty apart from a starter `.gitignore` (commit `6dd7641`, 2024-09-27). It is not a second version of this app. Silicon Ark: `intersect_cloud_v2/`. |
| `intersect_lambda` | Separate repository. Its mail and Supabase behaviour is not this app's behaviour. Silicon Ark: `intersect_lambda/`. |

## Discrepancies found while onboarding

1. OVER-161's scan listed `sonar-project.properties` and `sonarqube_scan.bat`. They are not in git.
2. The pipeline compiles nothing on `main`. It deploys the committed `build/web`.
3. Backend URL is `prod-alb.simpleflowhub.app`. A default profile image in the add-user screen points at `lwbyelfbryqvcvebcsin.supabase.co`.
4. Router auth is required only for `SupportTicketList`. Other named routes leave `requireAuth` at its default, false.
5. Choosing a Process Hub filter deletes `job_card` rows whose `status` is null.
6. Parallel page trees exist (`pages/user_management`, `pages/authentication`, `pages/tasks`, and several `process_hub_*` copies) that `lib/index.dart` does not export.

Details and provenance are in `prd.md`, `features.md`, `business-rules.md`, and `technical-documentation.md`.
