Moonlitic Platform
MOONLITIC
Patient/Consumer Portal — Full Architecture

Patient/Consumer Portal — Architecture & Actor Model

Data Monetization, Clinical Trial Matching, Consent Lifecycle — The B2C Side of Moonlitic

Version: 1.0  ·  Date: April 2026  ·  Classification: Confidential
Depends on: Folder 01 (Patient Consent + Clear), Folder 02 (Clinical Intelligence), Folder 03 (Payouts), Folder 07 (Marketplace)
Audience: Chief Architect, Engineering Leads, Product, Compliance

Table of Contents

1 What This Portal Does 2 Design Decision: One Portal, One Auth 3 The Actors (Updated Platform-Wide) 4 The Patient Journey 5 Phase A: Data Monetization 6 Phase B: Clinical Trial Matching 7 Consent, Revocation & Immutability 8 Cross-Folder Dependencies 9 Security & Privacy (B2C-Specific) 10 Screens & Tab Structure 11 Production Roadmap

1. What This Portal Does

The Moonlitic platform has two revenue surfaces. The Marketplace (Folder 07) sells de-identified cohort data to B2B Tile Builders at $XXX,XXX/year. But where does that data come from? From patients who consented in Folder 01.

This portal is the patient's window into the value their data creates. It answers three questions every consented patient eventually asks:

  1. "What is my data worth?" — Data Monetization dashboard: estimated earnings based on which categories they consented to, what marketplace demand exists, and what queries have used their cohort.
  2. "Are there clinical trials I qualify for?" — Clinical Trial Matching: two-way matching between patients and CRO Tile Builders. Patient sees trials and potential earnings. CRO sees aggregate match counts. Nothing happens until the patient explicitly accepts.
  3. "Can I change my mind?" — Always yes. The patient can revoke monetization consent at any time per category. Their record is NEVER deleted. Data provenance is maintained. Immutability is maintained. Revocation means "stop using my data going forward" — it does not erase history.
For the Chief Architect: This is the first cross-folder feature in the Moonlitic platform. The patient's identity comes from Folder 01 (Clear PKCE + consent). Their health profile comes from Folder 02 (FHIR/EHR via Data Aggregator). Their earnings flow through Folder 03 (Payouts). Their data is queried through Folder 07 (Marketplace). This portal sits on top of all four.

2. Design Decision: One Portal, One Auth Engine

Decision: The Patient/Consumer is added as a new role in the existing Marketplace Portal — NOT a separate application.

Rationale: A login is a login. The AuthEngine validates credentials, issues a JWT, and determines role. What changes after login is which tabs are visible and what actions are available. Duplicating auth layers creates security drift.

ConcernB2B (Tile Companies, Approvers, Finance, Admin)B2C (Patient/Consumer)Implementation
Login mechanismEmail + password + MFAEmail + password + MFASame AuthEngine.login()
Identity verificationCompany EIN + compliance screeningClear IAL2 (biometric + gov ID)Pre-auth: Clear is done in Folder 01 before they ever reach the portal
MFA requirementMandatory (TOTP)Optional (encouraged)Same engine, mfaRequired flag per role
Password policy12+ chars (enterprise)8+ chars (consumer-friendly)Same engine, minLength per role
Session lifetime1 hour4 hoursSame JWT, expiry per role
Post-login tabsRevenue, Onboard, Approval, Billing, Dashboard, ACLMy Data, Clinical Trials, EarningsSame getEnabledTabs(role)
Data access directionQueries warehouse (outbound)Views own data + earnings (inbound)Different engines behind the tabs

Result: Zero duplicated auth logic. One security surface to audit. One place to patch.

3. The Actors — Updated Platform-Wide View

With the Patient/Consumer addition, the Moonlitic platform now has 11 distinct actor types (Clinician is parked for future). Here is the complete roster:

#ActorTypeRole CodePortal TabsPrimary Action
1Patient / ConsumerExternal, B2CPATIENTMy Data, Trials, EarningsView data value, match trials, earn income
2New RegistrantExternal, B2BNEW_REGISTRANTOnboardFill wizard, submit application
3Tile Company (any type)External, B2BTILE_COMPANYOnboard, Approval, Billing, Dashboard, ACLQuery data, manage credits
4Approver — BusinessInternalAPPROVER_BUSINESSApproval, ACLApprove/reject (1st)
5Approver — FunctionalInternalAPPROVER_FUNCTIONALApproval, ACLApprove/reject (2nd)
6Approver — SalesInternalAPPROVER_SALESApproval, ACLApprove/reject (3rd)
7Approver — TechnicalInternalAPPROVER_TECHNICALApproval, ACLApprove/reject (4th)
8FinanceInternalFINANCEBilling, ACLConfirm wire payments
9AdminInternalADMINRevenue, Onboard, Approval, Billing, Dashboard, ACLMonitor marketplace, reinstate tiles
10ClinicianTBDCLINICIANTBDPARKED — Future

The New Actor in Detail: Patient / Consumer

🧑‍⚕️
PATIENT

Patient / Consumer

Who: A real person who has already completed Folder 01 consent (Clear IAL2 verified, 12-category consent selection). They are NOT anonymous. Their identity has been biometrically verified.

Pre-requisite to reach this portal:

  • Completed Clear PKCE authentication (Folder 01)
  • Passed age verification (18+, COPPA)
  • Selected at least 1 of 12 consent categories
  • ACL consent record written (immutable)
  • Aggregator EHR data connection established (Folder 02)

What they can see:

  • My Data tab — which categories they consented to, estimated value per category, accept/revoke monetization toggles, data provenance trail
  • Clinical Trials tab — matching trials based on health profile, potential earnings per trial, accept/decline per trial, payment status
  • Earnings tab — total income earned, payout history, pending payments, revocation history

What they can do:

  • Toggle monetization ON/OFF per data category (granular control)
  • Accept or decline clinical trial participation
  • Revoke any consent at any time (data never deleted, provenance preserved)
  • View how their data has been used (anonymized query log)

What they CANNOT do:

  • See other patients' data
  • See which specific companies queried their cohort (de-identified)
  • Access B2B tabs (Marketplace, Approval, Billing, Revenue)
  • Delete their record (immutability guarantee)
🔬
TILE_COMPANY (CLINICAL_TRIAL)

Clinical Trial Company / CRO

Who: An already-approved Tile Builder of type CLINICAL_TRIAL. They declared their research intent during onboarding (what conditions, what data categories, what cohort size they need).

What's NEW for them (added to existing Dashboard):

  • Patient Matching card — aggregate count of consented patients matching their declared criteria
  • Recruitment Request — submit a request to approach matched patients (system sends invitation, NOT the CRO directly)
  • Enrollment Status — how many patients accepted, declined, pending

What they CANNOT do:

  • See individual patient identities (ever)
  • Contact patients directly (system mediates all communication)
  • Bypass patient consent (no consent = no match visible)

Key rule: The CRO sees numbers. The patient sees details. The system sits in between. The CRO never knows WHO until the patient says YES and the interaction moves off-platform.

4. The Patient Journey — End to End

Visual Lifecycle

1Clear VerifyFolder 01
2ConsentFolder 01
3EHR ConnectFolder 02
4Portal LoginThis Portal
5View ValueMy Data tab
6Accept/DeclineMonetization
7Match TrialsTrials tab
8EarnEarnings tab

Detailed Step Breakdown

StepWhereActorWhat HappensSystem Output
1. Identity Folder 01 Patient Completes Clear NIST IAL2 verification: government ID scan, selfie liveness, biometric match. Age verified (18+ or guardian path). moonliticUserId, ial2Verified=true, verifiedName, verifiedDob
2. Consent Folder 01 Patient Selects from 12 consent categories (3×4 grid). Sensitive categories (Mental Health, SUD, Genetic) get enhanced confirmation modals. Immutable ACL consent record with aclTransactionId
3. EHR Connect Folder 02 System Aggregator API pulls patient's EHR data from connected providers. FHIR mapping applied. De-identification for warehouse. aggregatorId + clinical profile (conditions, medications, demographics)
4. Portal Login This Portal Patient Logs into the unified portal with email + password (+ optional MFA). AuthEngine returns role=PATIENT. Patient tabs enabled. JWT (4h expiry), patient dashboard rendered
5. View Value My Data tab Patient Sees their consented categories, how many marketplace queries have touched their cohort, estimated earnings per category based on demand. Data value dashboard with per-category breakdown
6. Accept/Decline My Data tab Patient Toggles monetization ON or OFF per category. ON = their de-identified data is included in marketplace queries. OFF = excluded going forward (historical usage preserved). ACL record: MONETIZATION_ACCEPTED or MONETIZATION_REVOKED per category
7. Match Trials Trials tab Patient Sees clinical trials that match their health profile. Each shows: condition, phase, compensation, location, CRO name. Patient can ACCEPT or DECLINE. On ACCEPT: ACL record + notification to CRO (aggregate count updated). Off-platform interaction begins.
8. Earn Earnings tab Patient Views total earnings, monthly breakdown, payout history (via Folder F06_Payouts engine). Clinical trial payments tracked separately from marketplace data income. Payout records via Velo Payments (Folder 03)

5. Phase A: Data Monetization — How the Patient Earns

5.1 The Value Equation

A patient's data generates revenue when Tile Builders query the marketplace. The patient's share is calculated from:

VariableSourceExample
Categories consentedFolder 01 consent recordClaims, Clinical Outcomes, Rx, Demographics (4 of 12)
Marketplace demandFolder 07 query historyClaims queried 342 times this month, Rx queried 187 times
Cohort inclusionEntitlement + de-identification matchPatient's de-identified record was in 28 query cohorts this month
Revenue share %Platform policyPatient receives X% of marketplace revenue attributed to their cohort

5.2 The "My Data" Dashboard

What the patient sees when they open the My Data tab:

UI ElementDescription
Consent Summary CardShows all 12 categories. Green = consented + monetizing. Gray = consented but not monetizing. Red = not consented. Each has an ON/OFF toggle.
Estimated Monthly ValueDollar estimate based on current marketplace demand for their consented categories. Updates monthly. Not a guarantee.
Data Activity FeedAnonymized log: "Your data was included in 12 aggregate queries this week across Claims and Demographics." No company names. No query details.
Provenance TrailImmutable timeline: when they consented, when monetization was toggled, when revocations occurred. Sourced from ACL.
Per-Category ValueBar chart: which categories generate the most value. Helps patient understand which consents matter most financially.

5.3 Accept / Revoke Monetization

ActionEffectReversible?ACL Entry
Accept (toggle ON)Patient's de-identified data for this category is included in future marketplace queriesYes, anytimeMONETIZATION_ACCEPTED { patientId, category, timestamp }
Revoke (toggle OFF)Patient's data for this category is excluded from future queries. Historical query results that already included their data are NOT retroactively removed (immutability).Yes, can re-accept laterMONETIZATION_REVOKED { patientId, category, timestamp, priorQueryCount }
Immutability guarantee: When a patient revokes, their future data is excluded but their historical participation is permanent. This is NOT a bug — it is a legal and data integrity requirement. If a query result was generated while consent was active, that result remains valid. Retroactive deletion would corrupt marketplace data provenance and violate the trust of Tile Builders who paid for those results. The ACL records the revocation timestamp so any audit can distinguish pre-revocation (valid) from post-revocation (excluded) data.

6. Phase B: Clinical Trial Matching — Two-Way

6.1 How Matching Works

The matching engine sits between two actors who never directly see each other until the patient says YES:

SideActorWhat They DeclaredWhat They See
Supply Patient Consent categories + EHR-derived health profile (conditions, medications, demographics) List of matching trials with: condition, phase, compensation, CRO name, eligibility criteria
Demand CRO (CLINICAL_TRIAL tile) During onboarding: target conditions (ICD-10 codes), required demographics, study phase, compensation offered, cohort size needed Aggregate count only: "142 consented patients match your criteria." NO individual identities.

6.2 The Matching Sequence

#FromToActionSystem Rule
1CROSystemDeclares trial criteria during Tile onboarding (or via dedicated trial listing form)Criteria stored: conditions, demographics, phase, compensation, cohort size
2SystemSystemMatching engine runs: cross-references CRO criteria against consented patient profilesOnly patients with: (a) active consent for relevant categories, (b) monetization ON, (c) matching health profile
3SystemCRO"Patient Matching" card on their Dashboard: "142 patients match. Request recruitment?"CRO sees AGGREGATE COUNT ONLY. No names, no IDs, no profiles.
4CROSystemClicks "Request Recruitment" — submits recruitment requestSystem validates: active tile, paid invoices, BAA executed. If pass → invitations queued.
5SystemPatientTrial invitation appears in patient's "Clinical Trials" tabPatient sees: condition, phase, compensation, CRO name, eligibility summary. NOT the CRO contacting them — the SYSTEM presenting an opportunity.
6aPatientSystemACCEPT — patient agrees to participateACL: TRIAL_ACCEPTED { patientId, trialId, croTileId, compensation }. CRO's enrollment count increments. Off-platform handoff initiated.
6bPatientSystemDECLINE — patient says noACL: TRIAL_DECLINED { patientId, trialId }. CRO sees aggregate decline count (not who). Patient can change mind later if trial still active.
7SystemBothOn ACCEPT: system provides CRO with a secure handoff token (single-use) to initiate off-platform contactAll further interaction between patient and CRO happens OUTSIDE Moonlitic. Platform's role ends at consent + payment.

6.3 Payment & Lock Rules

ScenarioRuleMoney Flow
Patient ACCEPTS trial Compensation amount is locked. CRO pays Moonlitic. Moonlitic pays patient via Folder F06_Payouts. CRO → Moonlitic → Patient (Velo Payments)
Patient backs out AFTER accepting + payment Patient must repay the compensation. Moonlitic facilitates repayment. Until repaid, patient's trial participation status = WITHDRAWN_UNPAID. Patient → Moonlitic → CRO (less processing fee)
Patient DECLINES No financial obligation. No contact. Trial invitation disappears. No money moves
CRO cancels trial All pending invitations withdrawn. Accepted patients keep compensation earned to date. No clawback by CRO. CRO absorbs sunk cost
Critical privacy rule: The CRO NEVER sees individual patient identity through the platform. The matching engine works on de-identified profiles. When a patient ACCEPTS, the system creates a secure handoff that connects the two parties — but the platform itself does not store or transmit PHI to the CRO. The off-platform interaction is between two consenting parties under the trial's own IRB protocol.

7. Consent, Revocation & Immutability — The Three Laws

Law 1: The Patient Always Has Choice

The patient can accept or decline monetization per category, at any time. They can accept or decline any clinical trial. There is no penalty for declining. There is no pressure to accept. Their data has value, and they choose what to do with it.

Law 2: Records Are Never Deleted

When a patient revokes consent or declines a trial, their record is not deleted. The ACL entry marking their original consent remains. The ACL entry marking their revocation is appended. The chain is immutable. This protects both the patient (proof they revoked) and the platform (proof consent existed when data was used).

Law 3: Revocation Is Forward-Looking

Revoking monetization means "stop including my data in future queries." It does NOT mean "retroactively erase my data from past query results." Past results were generated under valid consent. Retroactive deletion would corrupt data provenance and violate Tile Builder trust. The timestamp in the ACL is the legal boundary.

Law 4: Clinical Trial Exit Has a Cost

Unlike data monetization (free to revoke), clinical trial participation has a financial lock. If a patient accepted a trial and received compensation, backing out requires repayment. This protects the CRO from patient churn after investment. Moonlitic mediates the repayment. Once repaid, the patient is free.

8. Cross-Folder Dependencies

This is the first feature that spans all major folders. Here is exactly what depends on what:

This Portal NeedsFromFolderSpecific ComponentData Exchanged
Patient identity (verified) Folder 01 First Party Consent clear-backend.js → Clear PKCE flow moonliticUserId, ial2Verified, verifiedName, verifiedDob
Consent categories selected Folder 01 First Party Consent texas-health-consent.html → ACL consent record 12-category selection array, aclTransactionId, enhancedConsentFlags
Patient health profile Folder 02 Clinical Intelligence Aggregator API → FHIR mapping aggregatorId, conditions (ICD-10), medications, demographics, lab results
De-identified warehouse presence Folder 02 Clinical Intelligence De-identification engine (Safe Harbor / Expert Determination) De-identified patient record in warehouse (no direct PHI)
Marketplace query activity Folder 07 Marketplace DeliveryEngine query history Aggregate query counts per category (how many queries touched this patient's cohort)
CRO trial criteria Folder 07 Marketplace CLINICAL_TRIAL tile onboarding data Target conditions, demographics, phase, compensation, cohort size
Revenue attribution Folder 07 Marketplace BillingEngine + credit consumption Per-query credit cost → revenue share calculation
Patient payouts Folder 03 Payouts disbursement-engine.js + velo-client.js Payout amount, disbursement status, Velo payment ID
Clinical trial payment processing Folder 03 Payouts payout-orchestrator.js Trial compensation amount, CRO source, patient destination, repayment tracking
Immutable audit trail All Folders Cross-cutting ACL (Azure Confidential Ledger) Every consent, revocation, monetization toggle, trial accept/decline, payout
Architecture note: This table is the integration contract. Every row is an API boundary in production. The portal prototype will simulate these data sources, but the Chief Architect should plan service interfaces at each of these 10 touchpoints.

9. Security & Privacy — B2C-Specific Concerns

ConcernB2B Approach (existing)B2C Approach (new)Rationale
Identity verificationCompany EIN + compliance screeningClear NIST IAL2 (biometric + gov ID)Patients need higher identity assurance — they're real people, not companies
MFAMandatory TOTPOptional (strongly encouraged)Consumer adoption barrier — mandatory MFA kills conversion. Encourage, don't block.
Session lifetime1 hour4 hoursConsumers browse casually. Forcing re-login hourly is hostile UX.
Data visibilitySees de-identified warehouse dataSees ONLY their own data + anonymized activityPatient never sees other patients. Never sees raw query details. Aggregate activity only.
Revocation rightsN/A (companies don't "revoke")Per-category, per-trial, anytimePatient autonomy is foundational. HIPAA right of access and control.
Data deletion requestsN/ADenied — records are immutableExplain clearly: data is never deleted, but consent can be revoked (forward-looking). Provenance integrity.
Minor protectionN/A (B2B)Age verified at Clear step. <18 routed to guardian consent (COPPA).Legal requirement
Financial dataWire references (B2B)Payout details (B2C via Velo)Different payment rail. Patient sees earning history, not wire refs.

10. Screens & Tab Structure

The PATIENT role gets 3 tabs in the unified portal. Here's the detailed screen spec:

Returning Patient Welcome Panel (all tabs)

On every login, patients see a contextual "Welcome back" card above their My Data KPIs showing what changed since their last visit:

CardContentAction
New Trial MatchesCount + condition names + max compensation for new trials matching their profileClick → jumps to Trials tab
Pending PayoutsDollar amount + count of payouts being processed via VeloClick → jumps to Earnings tab
Last PayoutAmount, source (data vs trial), date, Velo referenceInformational
Query ActivityNumber of new queries on their de-identified data since last loginInformational

Implementation: renderPatientWelcome() injects a card into the #patientWelcomePanel div above My Data KPIs. Each card is clickable and navigates to the relevant tab. Shows last login timestamp.

Tab 1: My Data

UI ComponentContentData Source
KPI RowEstimated Monthly Income | Categories Active | Total Queries on Your Cohort | Lifetime EarningsFolder 07 query stats + Folder 03 payout totals
Category Cards (12)Each category: name, status (Consented/Not), monetization toggle (ON/OFF), demand indicator (High/Med/Low), estimated valueFolder 01 consent record + Folder 07 demand data
Data Activity FeedScrollable timeline: "Your data was included in N queries this week" (anonymized, no company names)Folder 07 query history (aggregated)
Provenance TrailImmutable event log: consent given, monetization toggled, revocations, payoutsACL (cross-folder)
Value ChartBar chart: monthly earnings by categoryFolder 03 payout records

Tab 2: Clinical Trials

UI ComponentContentData Source
Matching Trials ListCards per matching trial: condition, phase (I/II/III/IV), compensation, CRO name, locations, eligibility summaryMatching engine (Folder 02 profile × Folder 07 CRO criteria)
Accept/Decline ButtonsPer-trial action. Accept shows confirmation with payment lock warning. Decline is silent.ACL write on action
My EnrollmentsTrials accepted: status (ENROLLED, ACTIVE, COMPLETED, WITHDRAWN), compensation received, datesACL + Folder 03 payout records
Withdrawal FlowIf enrolled: "Withdraw" button with repayment warning modal showing amount owedACL + Folder 03 repayment tracking

Tab 3: Earnings

UI ComponentContentData Source
Total Earnings KPILifetime earnings, This Month, Pending PayoutFolder 03 disbursement-engine.js
Income BreakdownTwo streams: (1) Data Monetization income (marketplace queries), (2) Clinical Trial compensation. Separate totals.Folder 03 + Folder 07
Payout HistoryTable: date, amount, source (marketplace/trial), status (PAID/PENDING/PROCESSING), Velo referenceFolder 03 velo-client.js
Revocation HistoryTimeline of monetization revocations with financial impact: "Revoked Claims on March 15 — estimated $X/month reduction"ACL + revenue attribution

11. Production Roadmap

11.1 What the Prototype Will Demonstrate

FeaturePrototype State
PATIENT role in AuthEngineDemo patient user with simulated consent record
My Data dashboard12 category cards with toggles, simulated demand/value data
Accept/Revoke monetizationWorking toggles with ACL logging, provenance trail
Clinical trial matching3–5 simulated trials matched to demo patient's profile
Accept/Decline trialWorking with payment lock rules, withdrawal flow
Earnings dashboardSimulated payout history for both income streams
CRO matching cardAggregate match count on CLINICAL_TRIAL tile dashboard

11.2 What Production Requires

ItemPriorityProduction RequirementSuggested Tech
Clear IntegrationP0Real PKCE flow with Clear production endpoint. IAL2 verification. Session binding.Folder 01 clear-backend.js (already built)
Aggregator EHR ConnectionP0Real patient health profile from connected EHR providers. FHIR mapping.Folder 02 Aggregator API integration
Revenue Attribution EngineP0Calculate patient's share of marketplace revenue. Per-query attribution to cohort members.New engine: maps Folder 07 query results to consented patient pool
Matching EngineP0Cross-reference CRO criteria against patient profiles. Real-time or batch.Azure Functions + Cosmos DB queries on de-identified profiles
Velo Payout IntegrationP1Real money movement to patients. KYC, tax reporting (1099), disbursement.Folder 03 velo-client.js + disbursement-engine.js (already built)
Secure Handoff (Trial Accept)P1Single-use, time-limited token for CRO to initiate off-platform contact with accepted patient.HMAC-signed token with 72h expiry + ACL tracking
Trial Repayment FlowP1Patient repays compensation on withdrawal. Moonlitic mediates. CRO receives minus processing fee.Folder 03 payout-orchestrator.js reverse flow
Guardian Consent (Minors)P2COPPA-compliant guardian consent pathway for patients under 18.Folder 01 clear-backend.js age check (already built)
Push NotificationsP2Notify patients of new matching trials, payout arrivals, revocation confirmations.Azure Notification Hubs or Firebase

11.3 Build Sequence

Phase A (Weeks 1–3): Add PATIENT role to existing portal. Build My Data dashboard with consent card grid, monetization toggles, simulated value data, provenance trail. All ACL logging. Demo patient user.

Phase B (Weeks 4–6): Build Clinical Trial matching. Patient-side: trial cards, accept/decline, payment lock, withdrawal. CRO-side: matching count card on their existing dashboard, recruitment request. Matching engine with simulated profiles.

Phase C (Weeks 7–8): Build Earnings dashboard. Two income streams. Payout history (simulated Velo data). Revocation history with financial impact. Monthly breakdown charts.

Estimated prototype: 8 weeks. Builds on top of existing 3,005-line portal — no new file, no new auth layer.