# fjdvm/brenraphaels-authentication-microservice architecture

> Architecture diagram of the GitHub repository fjdvm/brenraphaels-authentication-microservice, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-12-04). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/fjdvm/brenraphaels-authentication-microservice
- Repository: https://github.com/fjdvm/brenraphaels-authentication-microservice

## Overview

This is a staff access portal: users authenticate centrally, see systems and modules they may access, and launch connected business systems through a one-time-code/handle handoff. Administrators manage users, access, account requests and audit logs; members can review activity. Separate integration endpoints support authorization, validation, exchange and payment-account reads. The graph preserves these documented capabilities and the sampled audit, payment and provisioning layers. Several routes and UI areas were not sampled, so their internal call relationships are omitted rather than inferred.

Main entry points: [`lib/db/prisma.ts`](https://github.com/fjdvm/brenraphaels-authentication-microservice/blob/main/lib/db/prisma.ts) (Portal database), [`app/page.tsx`](https://github.com/fjdvm/brenraphaels-authentication-microservice/blob/main/app/page.tsx) (Staff portal home), [`lib/auth/session.ts`](https://github.com/fjdvm/brenraphaels-authentication-microservice/blob/main/lib/auth/session.ts) (Session and guards), [`app/api/integrations/payment-details/route.ts`](https://github.com/fjdvm/brenraphaels-authentication-microservice/blob/main/app/api/integrations/payment-details/route.ts) (Payment account APIs)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_identity["Identity and access"]
  node_login["Login experience<br/>[page.tsx]"]
  node_session["Session and guards<br/>[session.ts]"]
  node_auth_provider["Auth provider<br/>[server.ts]"]
  node_webhook["Password reset webhook<br/>[route.ts]"]
end

subgraph group_portal["Portal experience"]
  node_portal_home["Staff portal home<br/>[page.tsx]"]
  node_accessible_systems["Accessible systems"]
  node_portal_shell["Portal shell<br/>[portal-shell.tsx]"]
  node_system_cards["System launch cards"]
end

subgraph group_admin["Administration"]
  node_admin_access["Admin access overview<br/>[page.tsx]"]
  node_user_admin["User and access management"]
  node_account_requests["Account request fulfillment"]
end

subgraph group_integration["System integrations"]
  node_integration_routes["Integration API routes"]
  node_handoff["System handoff<br/>[handoff.ts]"]
  node_integration_ports["Handoff persistence ports"]
  node_payment_routes["Payment account APIs<br/>[route.ts]"]
  node_payment_accounts["Payment account rules"]
  node_payment_store["Payment account persistence"]
end

subgraph group_services["Audit and services"]
  node_system_logs["System logs view"]
  node_audit_service["Audit log access"]
  node_audit_queries["Audit queries"]
  node_member_logs["Member activity log<br/>[page.tsx]"]
  node_database[("Portal database<br/>[prisma.ts]")]
end

node_user(("Portal user"))
node_business_system(("Business system"))
node_neon["Neon Auth"]
node_audit_store["Audit log service"]
node_email["SMTP email"]

node_user -->|"signs in"| node_login
node_login -->|"checks session"| node_session
node_session -->|"checks identity"| node_auth_provider
node_auth_provider -->|"uses"| node_neon
node_session -->|"reads user"| node_database
node_user -->|"opens portal"| node_portal_home
node_portal_home -->|"requires user"| node_session
node_portal_home -->|"loads access"| node_accessible_systems
node_portal_home -->|"renders"| node_portal_shell
node_portal_home -->|"renders"| node_system_cards
node_accessible_systems -->|"reads systems"| node_database
node_user -->|"opens admin"| node_admin_access
node_admin_access -->|"requires user"| node_session
node_admin_access -->|"loads activity"| node_audit_service
node_account_requests -->|"updates requests"| node_database
node_account_requests -->|"provisions user"| node_user_admin
node_member_logs -->|"loads activity"| node_audit_service
node_member_logs -->|"parses date range"| node_audit_queries
node_member_logs -->|"renders admin view"| node_system_logs
node_audit_service -->|"reads and writes"| node_audit_store
node_system_logs -->|"uses filters"| node_audit_queries
node_integration_routes -->|"routes handoff"| node_handoff
node_integration_routes -->|"uses persistence"| node_integration_ports
node_integration_ports -->|"reads and writes"| node_database
node_business_system -.->|"calls APIs"| node_integration_routes
node_payment_routes -->|"checks system"| node_integration_ports
node_payment_routes -->|"loads active accounts"| node_payment_store
node_payment_routes -->|"selects settings"| node_payment_accounts
node_payment_store -->|"reads and persists"| node_database
node_neon -.->|"sends reset event"| node_webhook
node_webhook -->|"checks user"| node_database
node_webhook -->|"sends reset email"| node_email

click node_login "https://github.com/fjdvm/brenraphaels-authentication-microservice/blob/main/app/(auth)/login/page.tsx"
click node_session "https://github.com/fjdvm/brenraphaels-authentication-microservice/blob/main/lib/auth/session.ts"
click node_auth_provider "https://github.com/fjdvm/brenraphaels-authentication-microservice/blob/main/lib/auth/server.ts"
click node_portal_home "https://github.com/fjdvm/brenraphaels-authentication-microservice/blob/main/app/page.tsx"
click node_accessible_systems "https://github.com/fjdvm/brenraphaels-authentication-microservice/blob/main/lib/portal/accessible-systems.ts"
click node_portal_shell "https://github.com/fjdvm/brenraphaels-authentication-microservice/blob/main/components/layout/portal-shell.tsx"
click node_system_cards "https://github.com/fjdvm/brenraphaels-authentication-microservice/blob/main/components/portal/system-launch-cards.tsx"
click node_admin_access "https://github.com/fjdvm/brenraphaels-authentication-microservice/blob/main/app/(protected)/admin/access/page.tsx"
click node_user_admin "https://github.com/fjdvm/brenraphaels-authentication-microservice/tree/main/lib/admin"
click node_account_requests "https://github.com/fjdvm/brenraphaels-authentication-microservice/blob/main/lib/account-requests/fulfillment.server.ts"
click node_system_logs "https://github.com/fjdvm/brenraphaels-authentication-microservice/blob/main/components/admin/system-logs-view.tsx"
click node_audit_service "https://github.com/fjdvm/brenraphaels-authentication-microservice/blob/main/lib/audit/audit-logs.server.ts"
click node_audit_queries "https://github.com/fjdvm/brenraphaels-authentication-microservice/blob/main/lib/audit/system-logs-query.ts"
click node_member_logs "https://github.com/fjdvm/brenraphaels-authentication-microservice/blob/main/app/(protected)/my-logs/page.tsx"
click node_integration_routes "https://github.com/fjdvm/brenraphaels-authentication-microservice/tree/main/app/api/integrations"
click node_handoff "https://github.com/fjdvm/brenraphaels-authentication-microservice/blob/main/lib/integrations/handoff.ts"
click node_integration_ports "https://github.com/fjdvm/brenraphaels-authentication-microservice/blob/main/lib/integrations/prisma-ports.server.ts"
click node_payment_routes "https://github.com/fjdvm/brenraphaels-authentication-microservice/blob/main/app/api/integrations/payment-details/route.ts"
click node_payment_accounts "https://github.com/fjdvm/brenraphaels-authentication-microservice/blob/main/lib/settings/payment-accounts.ts"
click node_payment_store "https://github.com/fjdvm/brenraphaels-authentication-microservice/blob/main/lib/settings/payment-accounts.server.ts"
click node_database "https://github.com/fjdvm/brenraphaels-authentication-microservice/blob/main/lib/db/prisma.ts"
click node_webhook "https://github.com/fjdvm/brenraphaels-authentication-microservice/blob/main/app/api/webhooks/neon-auth/route.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_login,node_session,node_auth_provider,node_webhook,node_user toneBlue
class node_portal_home,node_accessible_systems,node_portal_shell,node_system_cards toneAmber
class node_admin_access,node_user_admin,node_account_requests toneMint
class node_integration_routes,node_handoff,node_integration_ports,node_payment_routes,node_payment_accounts,node_payment_store toneRose
class node_system_logs,node_audit_service,node_audit_queries,node_member_logs,node_database,node_business_system,node_neon,node_audit_store,node_email toneIndigo
```

## Components

### Identity and access

- [Login experience](https://github.com/fjdvm/brenraphaels-authentication-microservice/blob/main/app/(auth)/login/page.tsx): `app/(auth)/login/page.tsx`
- [Session and guards](https://github.com/fjdvm/brenraphaels-authentication-microservice/blob/main/lib/auth/session.ts): `lib/auth/session.ts`
- [Auth provider](https://github.com/fjdvm/brenraphaels-authentication-microservice/blob/main/lib/auth/server.ts): `lib/auth/server.ts`
- [Password reset webhook](https://github.com/fjdvm/brenraphaels-authentication-microservice/blob/main/app/api/webhooks/neon-auth/route.ts): `app/api/webhooks/neon-auth/route.ts`

### Portal experience

- [Staff portal home](https://github.com/fjdvm/brenraphaels-authentication-microservice/blob/main/app/page.tsx): `app/page.tsx`
- [Accessible systems](https://github.com/fjdvm/brenraphaels-authentication-microservice/blob/main/lib/portal/accessible-systems.ts): `lib/portal/accessible-systems.ts`
- [Portal shell](https://github.com/fjdvm/brenraphaels-authentication-microservice/blob/main/components/layout/portal-shell.tsx): `components/layout/portal-shell.tsx`
- [System launch cards](https://github.com/fjdvm/brenraphaels-authentication-microservice/blob/main/components/portal/system-launch-cards.tsx): `components/portal/system-launch-cards.tsx`

### Administration

- [Admin access overview](https://github.com/fjdvm/brenraphaels-authentication-microservice/blob/main/app/(protected)/admin/access/page.tsx): `app/(protected)/admin/access/page.tsx`
- [User and access management](https://github.com/fjdvm/brenraphaels-authentication-microservice/tree/main/lib/admin): `lib/admin`
- [Account request fulfillment](https://github.com/fjdvm/brenraphaels-authentication-microservice/blob/main/lib/account-requests/fulfillment.server.ts): `lib/account-requests/fulfillment.server.ts`

### System integrations

- [Integration API routes](https://github.com/fjdvm/brenraphaels-authentication-microservice/tree/main/app/api/integrations): `app/api/integrations`
- [System handoff](https://github.com/fjdvm/brenraphaels-authentication-microservice/blob/main/lib/integrations/handoff.ts): `lib/integrations/handoff.ts`
- [Handoff persistence ports](https://github.com/fjdvm/brenraphaels-authentication-microservice/blob/main/lib/integrations/prisma-ports.server.ts): `lib/integrations/prisma-ports.server.ts`
- [Payment account APIs](https://github.com/fjdvm/brenraphaels-authentication-microservice/blob/main/app/api/integrations/payment-details/route.ts): `app/api/integrations/payment-details/route.ts`
- [Payment account rules](https://github.com/fjdvm/brenraphaels-authentication-microservice/blob/main/lib/settings/payment-accounts.ts): `lib/settings/payment-accounts.ts`
- [Payment account persistence](https://github.com/fjdvm/brenraphaels-authentication-microservice/blob/main/lib/settings/payment-accounts.server.ts): `lib/settings/payment-accounts.server.ts`

### Audit and services

- [System logs view](https://github.com/fjdvm/brenraphaels-authentication-microservice/blob/main/components/admin/system-logs-view.tsx): `components/admin/system-logs-view.tsx`
- [Audit log access](https://github.com/fjdvm/brenraphaels-authentication-microservice/blob/main/lib/audit/audit-logs.server.ts): `lib/audit/audit-logs.server.ts`
- [Audit queries](https://github.com/fjdvm/brenraphaels-authentication-microservice/blob/main/lib/audit/system-logs-query.ts): `lib/audit/system-logs-query.ts`
- [Member activity log](https://github.com/fjdvm/brenraphaels-authentication-microservice/blob/main/app/(protected)/my-logs/page.tsx): `app/(protected)/my-logs/page.tsx`
- [Portal database](https://github.com/fjdvm/brenraphaels-authentication-microservice/blob/main/lib/db/prisma.ts): `lib/db/prisma.ts`

### Other components

- **Portal user**
- **Business system**
- **Neon Auth**
- **Audit log service**
- **SMTP email**

## Connections

- Portal user → Login experience: signs in (evidence: `app/(auth)/login/page.tsx`)
- Login experience → Session and guards: checks session (evidence: `app/(auth)/login/page.tsx`)
- Session and guards → Auth provider: checks identity (evidence: `lib/auth/session.ts`)
- Auth provider → Neon Auth: uses (evidence: `lib/auth/server.ts`)
- Session and guards → Portal database: reads user (evidence: `lib/auth/session.ts`)
- Portal user → Staff portal home: opens portal (evidence: `app/page.tsx`)
- Staff portal home → Session and guards: requires user (evidence: `app/page.tsx`)
- Staff portal home → Accessible systems: loads access (evidence: `app/page.tsx`)
- Staff portal home → Portal shell: renders (evidence: `app/page.tsx`)
- Staff portal home → System launch cards: renders (evidence: `app/page.tsx`)
- Accessible systems → Portal database: reads systems (evidence: `lib/portal/accessible-systems.ts`)
- Portal user → Admin access overview: opens admin (evidence: `app/(protected)/admin/access/page.tsx`)
- Admin access overview → Session and guards: requires user (evidence: `app/(protected)/admin/access/page.tsx`)
- Admin access overview → Audit log access: loads activity (evidence: `app/(protected)/admin/access/page.tsx`)
- Account request fulfillment → Portal database: updates requests (evidence: `lib/account-requests/fulfillment.server.ts`)
- Account request fulfillment → User and access management: provisions user (evidence: `lib/account-requests/fulfillment.server.ts`)
- Member activity log → Audit log access: loads activity (evidence: `app/(protected)/my-logs/page.tsx`)
- Member activity log → Audit queries: parses date range (evidence: `app/(protected)/my-logs/page.tsx`)
- Member activity log → System logs view: renders admin view (evidence: `app/(protected)/my-logs/page.tsx`)
- Audit log access → Audit log service: reads and writes (evidence: `lib/audit/audit-logs.server.ts`)
- System logs view → Audit queries: uses filters (evidence: `components/admin/system-logs-view.tsx`)
- Integration API routes → System handoff: routes handoff (evidence: `app/api/integrations/authorize/route.ts`)
- Integration API routes → Handoff persistence ports: uses persistence (evidence: `app/api/integrations/authorize/route.ts`)
- Handoff persistence ports → Portal database: reads and writes (evidence: `lib/integrations/prisma-ports.server.ts`)
- Business system → Integration API routes: calls APIs
- Payment account APIs → Handoff persistence ports: checks system (evidence: `app/api/integrations/payment-details/route.ts`)
- Payment account APIs → Payment account persistence: loads active accounts (evidence: `app/api/integrations/payment-details/route.ts`)
- Payment account APIs → Payment account rules: selects settings (evidence: `app/api/integrations/payment-details/route.ts`)
- Payment account persistence → Portal database: reads and persists (evidence: `lib/settings/payment-accounts.server.ts`)
- Neon Auth → Password reset webhook: sends reset event
- Password reset webhook → Portal database: checks user (evidence: `app/api/webhooks/neon-auth/route.ts`)
- Password reset webhook → SMTP email: sends reset email (evidence: `app/api/webhooks/neon-auth/route.ts`)
