# joshua-onyekachukwu/provance-original architecture

> Architecture diagram of the GitHub repository joshua-onyekachukwu/provance-original, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-07-20). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/joshua-onyekachukwu/provance-original
- Repository: https://github.com/joshua-onyekachukwu/provance-original

## Overview

#### Purpose and boundaries
Provance is a synthetic-media verification MVP: a public marketing site plus an authenticated workspace where invited users upload images, initiate verification scans, and review printable reports. The active implementation is React/Vite frontend + NestJS API/worker; `api/` is explicitly legacy and should not receive new work. Paths: `src/main.jsx`, `backend/src/main.ts`, `api/server.js`.

#### Frontend application and routing
The Vite React entry mounts public pages, auth flows, and `/app/*` workspace routes. Authentication state and route protection are client-side concerns; API calls and Supabase client integration are centralized separately. Key paths: `src/App.jsx`, `src/context/AuthContext.jsx`, `src/components/auth/ProtectedRoute.jsx`.

#### Public onboarding and access control
Public visitors can submit waitlist applications, then use invite acceptance, sign-in, and password-reset flows. The Nest auth and waitlist modules expose versioned `/v1` endpoints and mediate Supabase-backed identity operations. Admin-only controls are guarded server-side. Paths: `backend/src/auth/auth.controller.ts`, `backend/src/waitlist/waitlist.service.ts`, `backend/src/common/guards/admin.guard.ts`.

#### Authenticated verification workspace
Workspace pages cover dashboard, upload submission, scan/report history and detail, print output, account, team placeholder, and admin operations. The frontend obtains signed upload capability and scan state through its API layer; report presentation derives from scan payloads and MVP signals. Paths: `src/pages/app/AppUploadsPage.jsx`, `src/pages/app/AppReportsPage.jsx`, `src/lib/api.js`.

#### Scan lifecycle and asynchronous boundary
The primary control flow is: authenticated user selects a supported image → frontend requests scan/upload workflow → media is placed in Supabase Storage through signed access → API creates/updates a scan record → submission enqueues work → separate worker consumes the job and writes asynchronous status/results → UI polls scan endpoints and renders reports. The queue boundary keeps scan processing out of API request latency. Paths: `backend/src/scans/scans.service.ts`, `backend/src/queue/queue.service.ts`, `backend/src/worker.ts`.

#### Persistence and external infrastructure
Supabase supplies authentication, database persistence, and object storage; SQL migrations define waitlist/auth, scans, admin operations, and profiles. BullMQ-compatible queue wiring uses Upstash Redis. Production topology separates API and worker on Fly.io, while the frontend deploys to Vercel. Paths: `backend/src/supabase/supabase.service.ts`, `supabase/migrations/0002_scans.sql`, `backend/fly.worker.toml`.

#### API composition and operational controls
`AppModule` composes account, auth, admin, scans, waitlist, Supabase, queue, and health modules. Cross-cutting guards enforce Supabase authentication, admin access, and throttling; a global exception filter establishes API error handling. Account preferences presently remain local on the frontend despite backend account scaffolding, making profile persistence an intentional unfinished boundary. Paths: `backend/src/app.module.ts`, `backend/src/common/guards/supabase-auth.guard.ts`, `backend/src/account/account.service.ts.

Main entry points: [`backend/src/supabase/supabase.service.ts`](https://github.com/joshua-onyekachukwu/provance-original/blob/main/backend/src/supabase/supabase.service.ts) (Supabase), [`backend/src/app.module.ts`](https://github.com/joshua-onyekachukwu/provance-original/blob/main/backend/src/app.module.ts) (Application modules), [`backend/src/main.ts`](https://github.com/joshua-onyekachukwu/provance-original/blob/main/backend/src/main.ts) (API bootstrap), [`src/App.jsx`](https://github.com/joshua-onyekachukwu/provance-original/blob/main/src/App.jsx) (Routes and pages)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["React frontend"]
  node_vite_entry["Vite entry<br/>frontend entry<br/>[main.jsx]"]
  node_router["Routes and pages<br/>React routing<br/>[App.jsx]"]
  node_auth_context["Auth state<br/>React context<br/>[AuthContext.jsx]"]
  node_protected_route["Workspace guard<br/>route guard<br/>[ProtectedRoute.jsx]"]
  node_workspace["Uploads and reports<br/>workspace pages<br/>[AppReportsPage.jsx]"]
  node_frontend_api["API client<br/>frontend API layer<br/>[api.js]"]
end

subgraph group_api["NestJS API"]
  node_api_bootstrap["API bootstrap<br/>NestJS entry<br/>[main.ts]"]
  node_app_module["Application modules<br/>NestJS composition<br/>[app.module.ts]"]
  node_auth_waitlist["Auth and waitlist<br/>v1 API modules<br/>[auth.controller.ts]"]
  node_api_guards["Auth, admin, throttling<br/>API controls"]
  node_scans_service["Scan workflow<br/>scan service<br/>[scans.service.ts]"]
end

subgraph group_async["Async scanning"]
  node_queue_service["Job producer<br/>queue service<br/>[queue.service.ts]"]
  node_worker{{"Scan worker<br/>NestJS worker<br/>[worker.ts]"}}
end

subgraph group_platform["Platform services"]
  node_supabase[("Supabase<br/>auth, database, storage")]
  node_migrations["SQL schema<br/>Supabase migrations<br/>[0002_scans.sql]"]
  node_redis[("Upstash Redis<br/>BullMQ backend")]
  node_deployment["Production deployment<br/>Vercel and Fly.io<br/>[fly.worker.toml]"]
end

node_legacy_api["Legacy API<br/>deprecated Express API<br/>[server.js]"]

node_vite_entry -->|"mounts"| node_router
node_router -->|"uses"| node_auth_context
node_router -->|"guards /app"| node_protected_route
node_protected_route -->|"allows"| node_workspace
node_workspace -->|"requests workflow and status"| node_frontend_api
node_frontend_api -->|"calls /v1 API"| node_api_bootstrap
node_api_bootstrap -->|"loads"| node_app_module
node_app_module -->|"composes"| node_auth_waitlist
node_app_module -->|"applies"| node_api_guards
node_app_module -->|"composes"| node_scans_service
node_auth_waitlist -->|"identity and applications"| node_supabase
node_api_guards -->|"validates identity"| node_supabase
node_scans_service -->|"scan records and signed uploads"| node_supabase
node_scans_service -->|"submits scan"| node_queue_service
node_queue_service -->|"publishes jobs"| node_redis
node_redis -->|"delivers jobs"| node_worker
node_worker -->|"writes status and results"| node_supabase
node_migrations -->|"defines schema"| node_supabase
node_deployment -->|"hosts API"| node_api_bootstrap
node_deployment -->|"hosts separately"| node_worker
node_legacy_api -.->|"replaced by"| node_api_bootstrap

click node_vite_entry "https://github.com/joshua-onyekachukwu/provance-original/blob/main/src/main.jsx"
click node_router "https://github.com/joshua-onyekachukwu/provance-original/blob/main/src/App.jsx"
click node_auth_context "https://github.com/joshua-onyekachukwu/provance-original/blob/main/src/context/AuthContext.jsx"
click node_protected_route "https://github.com/joshua-onyekachukwu/provance-original/blob/main/src/components/auth/ProtectedRoute.jsx"
click node_workspace "https://github.com/joshua-onyekachukwu/provance-original/blob/main/src/pages/app/AppReportsPage.jsx"
click node_frontend_api "https://github.com/joshua-onyekachukwu/provance-original/blob/main/src/lib/api.js"
click node_api_bootstrap "https://github.com/joshua-onyekachukwu/provance-original/blob/main/backend/src/main.ts"
click node_app_module "https://github.com/joshua-onyekachukwu/provance-original/blob/main/backend/src/app.module.ts"
click node_auth_waitlist "https://github.com/joshua-onyekachukwu/provance-original/blob/main/backend/src/auth/auth.controller.ts"
click node_api_guards "https://github.com/joshua-onyekachukwu/provance-original/blob/main/backend/src/common/guards/supabase-auth.guard.ts"
click node_scans_service "https://github.com/joshua-onyekachukwu/provance-original/blob/main/backend/src/scans/scans.service.ts"
click node_queue_service "https://github.com/joshua-onyekachukwu/provance-original/blob/main/backend/src/queue/queue.service.ts"
click node_worker "https://github.com/joshua-onyekachukwu/provance-original/blob/main/backend/src/worker.ts"
click node_supabase "https://github.com/joshua-onyekachukwu/provance-original/blob/main/backend/src/supabase/supabase.service.ts"
click node_migrations "https://github.com/joshua-onyekachukwu/provance-original/blob/main/supabase/migrations/0002_scans.sql"
click node_deployment "https://github.com/joshua-onyekachukwu/provance-original/blob/main/backend/fly.worker.toml"
click node_legacy_api "https://github.com/joshua-onyekachukwu/provance-original/blob/main/api/server.js"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_vite_entry,node_router,node_auth_context,node_protected_route,node_workspace,node_frontend_api toneBlue
class node_api_bootstrap,node_app_module,node_auth_waitlist,node_api_guards,node_scans_service toneAmber
class node_queue_service,node_worker toneMint
class node_supabase,node_migrations,node_redis,node_deployment toneRose
class node_legacy_api toneNeutral
```

## Components

### React frontend

Vite public and authenticated workspace.

- [Vite entry](https://github.com/joshua-onyekachukwu/provance-original/blob/main/src/main.jsx): frontend entry · `src/main.jsx`
- [Routes and pages](https://github.com/joshua-onyekachukwu/provance-original/blob/main/src/App.jsx): React routing · Serves public onboarding, auth, and /app workspace pages. · `src/App.jsx`
- [Auth state](https://github.com/joshua-onyekachukwu/provance-original/blob/main/src/context/AuthContext.jsx): React context · Maintains client authentication state. · `src/context/AuthContext.jsx`
- [Workspace guard](https://github.com/joshua-onyekachukwu/provance-original/blob/main/src/components/auth/ProtectedRoute.jsx): route guard · Protects authenticated workspace routes. · `src/components/auth/ProtectedRoute.jsx`
- [Uploads and reports](https://github.com/joshua-onyekachukwu/provance-original/blob/main/src/pages/app/AppReportsPage.jsx): workspace pages · Submits images, polls scans, and presents printable reports. · `src/pages/app/AppReportsPage.jsx`
- [API client](https://github.com/joshua-onyekachukwu/provance-original/blob/main/src/lib/api.js): frontend API layer · Centralizes API calls and Supabase client integration. · `src/lib/api.js`

### NestJS API

Versioned application API and access controls.

- [API bootstrap](https://github.com/joshua-onyekachukwu/provance-original/blob/main/backend/src/main.ts): NestJS entry · `backend/src/main.ts`
- [Application modules](https://github.com/joshua-onyekachukwu/provance-original/blob/main/backend/src/app.module.ts): NestJS composition · Composes auth, scans, accounts, admin, queue, waitlist, Supabase, and health. · `backend/src/app.module.ts`
- [Auth and waitlist](https://github.com/joshua-onyekachukwu/provance-original/blob/main/backend/src/auth/auth.controller.ts): v1 API modules · Handles invitations, sign-in support, reset flows, and applications. · `backend/src/auth/auth.controller.ts`
- [Auth, admin, throttling](https://github.com/joshua-onyekachukwu/provance-original/blob/main/backend/src/common/guards/supabase-auth.guard.ts): API controls · Supabase authentication and server-side admin enforcement. · `backend/src/common/guards/supabase-auth.guard.ts`
- [Scan workflow](https://github.com/joshua-onyekachukwu/provance-original/blob/main/backend/src/scans/scans.service.ts): scan service · Creates scan records, issues upload workflow, and exposes status/results. · `backend/src/scans/scans.service.ts`

### Async scanning

Queue-backed scan processing.

- [Job producer](https://github.com/joshua-onyekachukwu/provance-original/blob/main/backend/src/queue/queue.service.ts): queue service · Enqueues scan work outside request latency. · `backend/src/queue/queue.service.ts`
- [Scan worker](https://github.com/joshua-onyekachukwu/provance-original/blob/main/backend/src/worker.ts): NestJS worker · Consumes scan jobs and persists asynchronous results. · `backend/src/worker.ts`

### Platform services

Managed persistence, queue infrastructure, and deployments.

- [Supabase](https://github.com/joshua-onyekachukwu/provance-original/blob/main/backend/src/supabase/supabase.service.ts): auth, database, storage · Provides identity, scan persistence, and signed object storage. · `backend/src/supabase/supabase.service.ts`
- [SQL schema](https://github.com/joshua-onyekachukwu/provance-original/blob/main/supabase/migrations/0002_scans.sql): Supabase migrations · Defines scans, profiles, waitlist/auth, and admin data. · `supabase/migrations/0002_scans.sql`
- **Upstash Redis**: BullMQ backend
- [Production deployment](https://github.com/joshua-onyekachukwu/provance-original/blob/main/backend/fly.worker.toml): Vercel and Fly.io · Frontend deploys to Vercel; API and worker run separately on Fly.io. · `backend/fly.worker.toml`

### Other components

- [Legacy API](https://github.com/joshua-onyekachukwu/provance-original/blob/main/api/server.js): deprecated Express API · Explicitly excluded from new work. · `api/server.js`

## Connections

- Vite entry → Routes and pages: mounts
- Routes and pages → Auth state: uses
- Routes and pages → Workspace guard: guards /app
- Workspace guard → Uploads and reports: allows
- Uploads and reports → API client: requests workflow and status
- API client → API bootstrap: calls /v1 API
- API bootstrap → Application modules: loads
- Application modules → Auth and waitlist: composes
- Application modules → Auth, admin, throttling: applies
- Application modules → Scan workflow: composes
- Auth and waitlist → Supabase: identity and applications
- Auth, admin, throttling → Supabase: validates identity
- Scan workflow → Supabase: scan records and signed uploads
- Scan workflow → Job producer: submits scan
- Job producer → Upstash Redis: publishes jobs
- Upstash Redis → Scan worker: delivers jobs
- Scan worker → Supabase: writes status and results
- SQL schema → Supabase: defines schema
- Production deployment → API bootstrap: hosts API
- Production deployment → Scan worker: hosts separately
- Legacy API → API bootstrap: replaced by
