# sakura3id/community-portal architecture

> Architecture diagram of the GitHub repository sakura3id/community-portal, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/sakura3id/community-portal
- Repository: https://github.com/sakura3id/community-portal

## Overview

Community Portal is Sakura 3’s resident identity hub: residents authenticate, complete an approval profile, and—once approved—reach the ecosystem app directory or return to the requesting app. Admin-facing mobile screens cover approvals, roles, and app-level access; the README also describes session sharing across subdomains. The workflow and auth/permission wiring are supported by sampled source. Several feature screens and integrations are represented from README claims and tree paths, so their internal call relationships are not inferred.

Main entry points: [`src/App.tsx`](https://github.com/sakura3id/community-portal/blob/master/src/App.tsx) (Portal Router), [`src/lib/supabase.ts`](https://github.com/sakura3id/community-portal/blob/master/src/lib/supabase.ts) (Supabase Client), [`src/hooks/useAuth.tsx`](https://github.com/sakura3id/community-portal/blob/master/src/hooks/useAuth.tsx) (Auth Context), [`src/components/LoginScreen.tsx`](https://github.com/sakura3id/community-portal/blob/master/src/components/LoginScreen.tsx) (Sign-in Screen)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Portal Entry"]
  node_app["Portal Router<br/>[App.tsx]"]
  node_login["Sign-in Screen<br/>[LoginScreen.tsx]"]
  node_hub_ui["Mobile Hub"]
end

subgraph group_identity["Identity Workflow"]
  node_pending["Profile Submission"]
  node_rejected["Rejected Access<br/>[RejectedScreen.tsx]"]
  node_landing["App Directory"]
  node_auth["Auth Context<br/>[useAuth.tsx]"]
  node_permissions["Permission Checks<br/>[usePermissions.tsx]"]
end

subgraph group_governance["Access Governance"]
  node_approval_ui["Approval Review"]
  node_roles_ui["Role Management"]
  node_app_rbac["App Access Rules"]
  node_logs_ui["Governance Logs"]
end

subgraph group_platform["Platform Services"]
  node_supabase_client["Supabase Client<br/>[supabase.ts]"]
  node_supabase[("Supabase Auth and DB")]
  node_oauth["Google OAuth"]
  node_predefined_login["Demo Login Function<br/>[index.ts]"]
  node_delete_users["User Deletion Function<br/>[index.ts]"]
  node_email_fn["Notification Function<br/>[index.ts]"]
  node_resend["Resend Email"]
  node_analytics["Analytics<br/>[analytics.ts]"]
end

node_resident(("Resident"))
node_requesting_app["Resident App"]
node_ecosystem_apps["Ecosystem Apps"]

node_resident -->|"opens portal"| node_app
node_app -->|"provides auth"| node_auth
node_app -->|"checks access"| node_permissions
node_app -->|"renders signed out"| node_login
node_app -->|"renders pending"| node_pending
node_app -->|"renders rejected"| node_rejected
node_app -->|"renders approved"| node_landing
node_login -->|"starts sign-in"| node_auth
node_auth -->|"uses client"| node_supabase_client
node_supabase_client -->|"auth and data"| node_supabase
node_supabase -->|"OAuth sign-in"| node_oauth
node_auth -.->|"invokes demo login"| node_predefined_login
node_pending -->|"reads and submits profile"| node_supabase_client
node_permissions -->|"reads roles and status"| node_supabase_client
node_app -->|"redirects after approval"| node_requesting_app
node_requesting_app -->|"requests authentication"| node_app
node_supabase -->|"shares session cookie"| node_ecosystem_apps
node_approval_ui -->|"manages approvals"| node_supabase_client
node_roles_ui -->|"manages roles"| node_supabase_client
node_app_rbac -->|"manages app access"| node_supabase_client
node_logs_ui -->|"reads governance logs"| node_supabase_client
node_delete_users -->|"verifies admin and deletes"| node_supabase
node_email_fn -->|"sends notifications"| node_resend
node_supabase -.->|"triggers notification"| node_email_fn
node_app -->|"tracks portal activity"| node_analytics

click node_app "https://github.com/sakura3id/community-portal/blob/master/src/App.tsx"
click node_login "https://github.com/sakura3id/community-portal/blob/master/src/components/LoginScreen.tsx"
click node_pending "https://github.com/sakura3id/community-portal/blob/master/src/components/PendingApprovalScreen.tsx"
click node_rejected "https://github.com/sakura3id/community-portal/blob/master/src/components/RejectedScreen.tsx"
click node_landing "https://github.com/sakura3id/community-portal/blob/master/src/components/EcosystemLandingScreen.tsx"
click node_auth "https://github.com/sakura3id/community-portal/blob/master/src/hooks/useAuth.tsx"
click node_permissions "https://github.com/sakura3id/community-portal/blob/master/src/hooks/usePermissions.tsx"
click node_approval_ui "https://github.com/sakura3id/community-portal/blob/master/src/components/mobile/MobileApprovalsScreen.tsx"
click node_roles_ui "https://github.com/sakura3id/community-portal/blob/master/src/components/mobile/MobileRolesScreen.tsx"
click node_app_rbac "https://github.com/sakura3id/community-portal/blob/master/src/components/mobile/MobileAppRbacScreen.tsx"
click node_logs_ui "https://github.com/sakura3id/community-portal/blob/master/src/components/mobile/MobileLogsScreen.tsx"
click node_hub_ui "https://github.com/sakura3id/community-portal/blob/master/src/components/mobile/MobileHubScreen.tsx"
click node_supabase_client "https://github.com/sakura3id/community-portal/blob/master/src/lib/supabase.ts"
click node_predefined_login "https://github.com/sakura3id/community-portal/blob/master/supabase/functions/predefined-login/index.ts"
click node_delete_users "https://github.com/sakura3id/community-portal/blob/master/supabase/functions/delete-users/index.ts"
click node_email_fn "https://github.com/sakura3id/community-portal/blob/master/supabase/functions/send-notification-email/index.ts"
click node_analytics "https://github.com/sakura3id/community-portal/blob/master/src/lib/analytics.ts"

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_app,node_login,node_hub_ui toneBlue
class node_pending,node_rejected,node_landing,node_auth,node_permissions toneAmber
class node_approval_ui,node_roles_ui,node_app_rbac,node_logs_ui toneMint
class node_supabase_client,node_supabase,node_oauth,node_predefined_login,node_delete_users,node_email_fn,node_resend,node_analytics toneRose
class node_resident,node_requesting_app,node_ecosystem_apps toneIndigo
```

## Components

### Portal Entry

- [Portal Router](https://github.com/sakura3id/community-portal/blob/master/src/App.tsx): `src/App.tsx`
- [Sign-in Screen](https://github.com/sakura3id/community-portal/blob/master/src/components/LoginScreen.tsx): `src/components/LoginScreen.tsx`
- [Mobile Hub](https://github.com/sakura3id/community-portal/blob/master/src/components/mobile/MobileHubScreen.tsx): `src/components/mobile/MobileHubScreen.tsx`

### Identity Workflow

- [Profile Submission](https://github.com/sakura3id/community-portal/blob/master/src/components/PendingApprovalScreen.tsx): `src/components/PendingApprovalScreen.tsx`
- [Rejected Access](https://github.com/sakura3id/community-portal/blob/master/src/components/RejectedScreen.tsx): `src/components/RejectedScreen.tsx`
- [App Directory](https://github.com/sakura3id/community-portal/blob/master/src/components/EcosystemLandingScreen.tsx): `src/components/EcosystemLandingScreen.tsx`
- [Auth Context](https://github.com/sakura3id/community-portal/blob/master/src/hooks/useAuth.tsx): `src/hooks/useAuth.tsx`
- [Permission Checks](https://github.com/sakura3id/community-portal/blob/master/src/hooks/usePermissions.tsx): `src/hooks/usePermissions.tsx`

### Access Governance

- [Approval Review](https://github.com/sakura3id/community-portal/blob/master/src/components/mobile/MobileApprovalsScreen.tsx): `src/components/mobile/MobileApprovalsScreen.tsx`
- [Role Management](https://github.com/sakura3id/community-portal/blob/master/src/components/mobile/MobileRolesScreen.tsx): `src/components/mobile/MobileRolesScreen.tsx`
- [App Access Rules](https://github.com/sakura3id/community-portal/blob/master/src/components/mobile/MobileAppRbacScreen.tsx): `src/components/mobile/MobileAppRbacScreen.tsx`
- [Governance Logs](https://github.com/sakura3id/community-portal/blob/master/src/components/mobile/MobileLogsScreen.tsx): `src/components/mobile/MobileLogsScreen.tsx`

### Platform Services

- [Supabase Client](https://github.com/sakura3id/community-portal/blob/master/src/lib/supabase.ts): `src/lib/supabase.ts`
- **Supabase Auth and DB**
- **Google OAuth**
- [Demo Login Function](https://github.com/sakura3id/community-portal/blob/master/supabase/functions/predefined-login/index.ts): `supabase/functions/predefined-login/index.ts`
- [User Deletion Function](https://github.com/sakura3id/community-portal/blob/master/supabase/functions/delete-users/index.ts): `supabase/functions/delete-users/index.ts`
- [Notification Function](https://github.com/sakura3id/community-portal/blob/master/supabase/functions/send-notification-email/index.ts): `supabase/functions/send-notification-email/index.ts`
- **Resend Email**
- [Analytics](https://github.com/sakura3id/community-portal/blob/master/src/lib/analytics.ts): `src/lib/analytics.ts`

### Other components

- **Resident**
- **Resident App**
- **Ecosystem Apps**

## Connections

- Resident → Portal Router: opens portal
- Portal Router → Auth Context: provides auth
- Portal Router → Permission Checks: checks access
- Portal Router → Sign-in Screen: renders signed out
- Portal Router → Profile Submission: renders pending
- Portal Router → Rejected Access: renders rejected
- Portal Router → App Directory: renders approved
- Sign-in Screen → Auth Context: starts sign-in
- Auth Context → Supabase Client: uses client
- Supabase Client → Supabase Auth and DB: auth and data
- Supabase Auth and DB → Google OAuth: OAuth sign-in
- Auth Context → Demo Login Function: invokes demo login
- Profile Submission → Supabase Client: reads and submits profile
- Permission Checks → Supabase Client: reads roles and status
- Portal Router → Resident App: redirects after approval
- Resident App → Portal Router: requests authentication
- Supabase Auth and DB → Ecosystem Apps: shares session cookie
- Approval Review → Supabase Client: manages approvals
- Role Management → Supabase Client: manages roles
- App Access Rules → Supabase Client: manages app access
- Governance Logs → Supabase Client: reads governance logs
- User Deletion Function → Supabase Auth and DB: verifies admin and deletes
- Notification Function → Resend Email: sends notifications
- Supabase Auth and DB → Notification Function: triggers notification
- Portal Router → Analytics: tracks portal activity
