# emn90909/strut architecture

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

- Interactive diagram: https://gitdiagram.com/emn90909/strut
- Repository: https://github.com/emn90909/strut

## Overview

#### Purpose and Runtime Entry Points
Struta is a multi-tenant funeral-services platform for bereaved families, funeral homes, vendors, staff, administrators, and developer API consumers. The primary runtime is a Vite React SPA plus a Node/TypeScript API server: `src/main.tsx`, `src/App.tsx`, and `server/index.ts`. `app/page.tsx` and `app/layout.tsx` indicate a parallel/minimal Next.js surface, but README-directed development uses Vite and the API together.

#### Portal and Role-Based Frontend
The SPA is organized by actor-specific feature areas rather than a single generic dashboard. Family memorial/request experiences, provider operations, funeral-home operations, marketplace, ERP, staff consoles, and admin functions are separate UI domains. Representative boundaries: `src/features/bereaved/pages/Dashboard.tsx`, `src/features/manager/pages/Dashboard.tsx`, `src/features/erp/pages/Dashboard.tsx`, `src/features/admin/pages/Dashboard.tsx`, and `src/developer/pages/Dashboard.tsx`. Shared portal framing and route-level entitlement controls sit in `src/components/layout/PortalLayout.tsx` and `src/components/ProFeatureRoute.tsx`.

#### Identity, Authorization, and Tenancy
Supabase is the identity and primary data boundary. The browser client is configured in `src/integrations/supabase/client.ts`; server-side privileged operations use `server/supabase-admin.ts`. Authentication UI/state and access decisions originate in `src/components/auth/AuthProvider.tsx`, `src/features/auth/pages/AuthCallback.tsx`, and server routes such as `server/routes/authSecurityRoutes.ts`. Database migrations encode roles, RLS, tenant isolation, account controls, staff access, and security policy, notably `supabase/migrations/0005_access_roles_rls_preferences.sql`, `supabase/migrations/0028_role_based_struta_erp.sql`, and `supabase/migrations/202606190003_fix_otp_and_pro_tenant_isolation.sql`.

#### Service Requests, Operations, and ERP Flow
Families can create and manage memorials and service requests; providers/homes receive, schedule, staff, and fulfill them. The request workflow spans UI components such as `src/components/RequestSender.tsx` and `src/components/ProviderRequests.tsx`, backend handling in `server/routes/paymentRequestRoutes.ts`, and operational workspaces in `src/features/manager/pages/TasksWorkspace.tsx` and `src/features/pro-erp/pages/Workspace.tsx`. Workflow automation is a distinct server boundary in `server/routes/workflowAutomationRoutes.ts`, backed by queue-oriented schema migrations including `supabase/migrations/202606191430_workflow_automation_queue.sql`.

#### Payments, Billing, and External Commerce
Billing supports subscriptions, payment requests, manual payments, refunds, disputes, and provider payout concerns. HTTP payment adapters are separated by gateway in `server/routes/paystackRoutes.ts`, `server/routes/paypalRoutes.ts`, and `server/routes/stripe-routes.ts`; domain orchestration is in `server/services/billing-service.ts`, `server/services/checkout-service.ts`, and `server/services/payment-capture-service.ts`. Paystack is explicitly configured for frontend checkout and server verification; PayPal and Stripe integrations are also present. Payment-sensitive persistence and RLS changes live under `supabase/migrations/0020_fix_payments_rls_and_admin_access.sql` and later Paystack hardening migrations.

#### Async, Realtime, Notifications, and AI
The API includes internal queue, cache, moderation, realtime, push, and scheduled-work layers: `server/jobs/queue.ts`, `server/performance/redisCache.ts`, `server/realtime/realtimeHub.ts`, `server/push-server/pushServer.ts`, and `server/moderation/moderationWorker.ts`. Browser push uses VAPID/web-push and `public/push-sw.js`, rather than Firebase. User-facing realtime notifications are represented by `src/components/RealtimeNotifications.tsx`. Jamila AI is exposed in the UI through `src/components/JamilaAssistant.tsx`; an additional Go API service includes AI-related logic in `go-services/api-backend/jamila.go`.

#### Deployment and Auxiliary Services
The main application is containerized and deployable to Render, Docker, or Oracle through `Dockerfile`, `render.yaml`, and `oracle.yaml`; the Docker path runs migrations before starting. Supabase additionally hosts the JWT-protected provider-verification Edge Function at `supabase/functions/provider-verification/index.ts`, which calls Google Maps/Places and optionally Resend, then writes verification outcomes to platform records. The repository also contains independently runnable Go services for notifications, Paystack, SMTP mail, family AI, background work, and tribute handling, with examples at `go-services/notifications-service/main.go`, `go-services/paystack-service/main.go`, and `go-worker/main.go`; treat these as separate deployment units from the Node API.

Main entry points: [`src/integrations/supabase/client.ts`](https://github.com/emn90909/strut/blob/main/src/integrations/supabase/client.ts) (Supabase auth and data), [`server/index.ts`](https://github.com/emn90909/strut/blob/main/server/index.ts) (Node TypeScript API), [`src/main.tsx`](https://github.com/emn90909/strut/blob/main/src/main.tsx) (Vite React SPA), [`server/services/billing-service.ts`](https://github.com/emn90909/strut/blob/main/server/services/billing-service.ts) (Billing orchestration)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Web clients"]
  node_vite["Vite React SPA<br/>web client<br/>[main.tsx]"]
  node_portals["Role portals<br/>feature UI<br/>[Dashboard.tsx]"]
  node_portal_shell["Portal shell<br/>routing UI<br/>[PortalLayout.tsx]"]
  node_requests_ui["Request workflow UI<br/>feature UI<br/>[RequestSender.tsx]"]
  node_realtime_ui["Realtime and AI UI<br/>client components"]
  node_next_surface["Minimal Next surface<br/>alternate web UI<br/>[page.tsx]"]
end

subgraph group_api["Node API"]
  node_api_server["Node TypeScript API<br/>API runtime<br/>[index.ts]"]
  node_auth_routes["Auth and security routes<br/>HTTP routes"]
  node_request_routes["Payment request routes<br/>HTTP routes"]
  node_workflow["Workflow automation<br/>automation routes"]
  node_billing["Billing orchestration<br/>domain services<br/>[billing-service.ts]"]
  node_async_runtime["Async and realtime runtime<br/>server infrastructure<br/>[queue.ts]"]
end

subgraph group_platform["Supabase platform"]
  node_supabase[("Supabase auth and data<br/>identity database<br/>[client.ts]")]
  node_rls_schema["Roles and tenant RLS<br/>database migrations"]
  node_workflow_queue_schema["Workflow queue schema<br/>database migrations"]
  node_verification_function{{"Provider verification function<br/>Supabase Edge Function<br/>[index.ts]"}}
end

subgraph group_auxiliary["Auxiliary deployments"]
  node_go_services["Go service deployments<br/>independent services<br/>[main.go]"]
  node_go_worker["Go background worker<br/>worker runtime<br/>[main.go]"]
end

node_payment_gateways{{"Payment gateways<br/>external commerce<br/>[paystackRoutes.ts]"}}
node_external_verification{{"Maps and email providers<br/>external APIs"}}

node_vite -->|"renders"| node_portals
node_portals -->|"uses"| node_portal_shell
node_portals -->|"includes"| node_requests_ui
node_vite -->|"shows"| node_realtime_ui
node_vite -->|"browser auth and data"| node_supabase
node_vite -->|"API calls"| node_api_server
node_next_surface -.->|"uses"| node_supabase
node_api_server -->|"mounts"| node_auth_routes
node_api_server -->|"mounts"| node_request_routes
node_api_server -->|"mounts"| node_workflow
node_api_server -->|"uses"| node_billing
node_api_server -->|"uses"| node_async_runtime
node_auth_routes -->|"privileged auth access"| node_supabase
node_request_routes -->|"creates payment requests"| node_billing
node_request_routes -->|"persists requests"| node_supabase
node_workflow -->|"enqueues work"| node_async_runtime
node_workflow -->|"uses queue records"| node_workflow_queue_schema
node_billing -->|"charges and verifies"| node_payment_gateways
node_billing -->|"persists payment state"| node_supabase
node_async_runtime -->|"notifications and push"| node_realtime_ui
node_supabase -->|"enforces"| node_rls_schema
node_verification_function -->|"writes outcomes"| node_supabase
node_verification_function -->|"verifies providers"| node_external_verification
node_go_services -.->|"integrates independently"| node_supabase
node_go_worker -->|"background processing"| node_go_services

click node_vite "https://github.com/emn90909/strut/blob/main/src/main.tsx"
click node_portals "https://github.com/emn90909/strut/blob/main/src/features/bereaved/pages/Dashboard.tsx"
click node_portal_shell "https://github.com/emn90909/strut/blob/main/src/components/layout/PortalLayout.tsx"
click node_requests_ui "https://github.com/emn90909/strut/blob/main/src/components/RequestSender.tsx"
click node_realtime_ui "https://github.com/emn90909/strut/blob/main/src/components/RealtimeNotifications.tsx"
click node_next_surface "https://github.com/emn90909/strut/blob/main/app/page.tsx"
click node_api_server "https://github.com/emn90909/strut/blob/main/server/index.ts"
click node_auth_routes "https://github.com/emn90909/strut/blob/main/server/routes/authSecurityRoutes.ts"
click node_request_routes "https://github.com/emn90909/strut/blob/main/server/routes/paymentRequestRoutes.ts"
click node_workflow "https://github.com/emn90909/strut/blob/main/server/routes/workflowAutomationRoutes.ts"
click node_billing "https://github.com/emn90909/strut/blob/main/server/services/billing-service.ts"
click node_async_runtime "https://github.com/emn90909/strut/blob/main/server/jobs/queue.ts"
click node_supabase "https://github.com/emn90909/strut/blob/main/src/integrations/supabase/client.ts"
click node_rls_schema "https://github.com/emn90909/strut/blob/main/supabase/migrations/0005_access_roles_rls_preferences.sql"
click node_workflow_queue_schema "https://github.com/emn90909/strut/blob/main/supabase/migrations/202606191430_workflow_automation_queue.sql"
click node_verification_function "https://github.com/emn90909/strut/blob/main/supabase/functions/provider-verification/index.ts"
click node_payment_gateways "https://github.com/emn90909/strut/blob/main/server/routes/paystackRoutes.ts"
click node_go_services "https://github.com/emn90909/strut/blob/main/go-services/notifications-service/main.go"
click node_go_worker "https://github.com/emn90909/strut/blob/main/go-worker/main.go"

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,node_portals,node_portal_shell,node_requests_ui,node_realtime_ui,node_next_surface toneBlue
class node_api_server,node_auth_routes,node_request_routes,node_workflow,node_billing,node_async_runtime toneAmber
class node_supabase,node_rls_schema,node_workflow_queue_schema,node_verification_function toneMint
class node_go_services,node_go_worker toneRose
class node_payment_gateways,node_external_verification toneNeutral
```

## Components

### Web clients

- [Vite React SPA](https://github.com/emn90909/strut/blob/main/src/main.tsx): web client · Primary browser runtime. · `src/main.tsx`
- [Role portals](https://github.com/emn90909/strut/blob/main/src/features/bereaved/pages/Dashboard.tsx): feature UI · Family, provider, home, ERP, staff, admin, and developer experiences. · `src/features/bereaved/pages/Dashboard.tsx`
- [Portal shell](https://github.com/emn90909/strut/blob/main/src/components/layout/PortalLayout.tsx): routing UI · Shared framing and entitlement controls. · `src/components/layout/PortalLayout.tsx`
- [Request workflow UI](https://github.com/emn90909/strut/blob/main/src/components/RequestSender.tsx): feature UI · Creates requests and exposes provider operations. · `src/components/RequestSender.tsx`
- [Realtime and AI UI](https://github.com/emn90909/strut/blob/main/src/components/RealtimeNotifications.tsx): client components · Notifications and Jamila assistant. · `src/components/RealtimeNotifications.tsx`
- [Minimal Next surface](https://github.com/emn90909/strut/blob/main/app/page.tsx): alternate web UI · Parallel, non-primary application surface. · `app/page.tsx`

### Node API

- [Node TypeScript API](https://github.com/emn90909/strut/blob/main/server/index.ts): API runtime · Primary server for application and integration endpoints. · `server/index.ts`
- [Auth and security routes](https://github.com/emn90909/strut/blob/main/server/routes/authSecurityRoutes.ts): HTTP routes · `server/routes/authSecurityRoutes.ts`
- [Payment request routes](https://github.com/emn90909/strut/blob/main/server/routes/paymentRequestRoutes.ts): HTTP routes · `server/routes/paymentRequestRoutes.ts`
- [Workflow automation](https://github.com/emn90909/strut/blob/main/server/routes/workflowAutomationRoutes.ts): automation routes · Schedules operational workflow work. · `server/routes/workflowAutomationRoutes.ts`
- [Billing orchestration](https://github.com/emn90909/strut/blob/main/server/services/billing-service.ts): domain services · Checkout, capture, subscriptions, refunds, and disputes. · `server/services/billing-service.ts`
- [Async and realtime runtime](https://github.com/emn90909/strut/blob/main/server/jobs/queue.ts): server infrastructure · Queue, Redis cache, moderation, realtime hub, and push delivery. · `server/jobs/queue.ts`

### Supabase platform

- [Supabase auth and data](https://github.com/emn90909/strut/blob/main/src/integrations/supabase/client.ts): identity database · Primary identity, tenant data, and RLS boundary. · `src/integrations/supabase/client.ts`
- [Roles and tenant RLS](https://github.com/emn90909/strut/blob/main/supabase/migrations/0005_access_roles_rls_preferences.sql): database migrations · Roles, access controls, and tenant isolation policy. · `supabase/migrations/0005_access_roles_rls_preferences.sql`
- [Workflow queue schema](https://github.com/emn90909/strut/blob/main/supabase/migrations/202606191430_workflow_automation_queue.sql): database migrations · `supabase/migrations/202606191430_workflow_automation_queue.sql`
- [Provider verification function](https://github.com/emn90909/strut/blob/main/supabase/functions/provider-verification/index.ts): Supabase Edge Function · JWT-protected verification writes provider outcomes. · `supabase/functions/provider-verification/index.ts`

### Auxiliary deployments

- [Go service deployments](https://github.com/emn90909/strut/blob/main/go-services/notifications-service/main.go): independent services · Notifications, payments, mail, AI, tributes, and background work. · `go-services/notifications-service/main.go`
- [Go background worker](https://github.com/emn90909/strut/blob/main/go-worker/main.go): worker runtime · `go-worker/main.go`

### Other components

- [Payment gateways](https://github.com/emn90909/strut/blob/main/server/routes/paystackRoutes.ts): external commerce · Paystack, PayPal, and Stripe adapters. · `server/routes/paystackRoutes.ts`
- **Maps and email providers**: external APIs · Google Places/Maps and optional Resend.

## Connections

- Vite React SPA → Role portals: renders
- Role portals → Portal shell: uses
- Role portals → Request workflow UI: includes
- Vite React SPA → Realtime and AI UI: shows
- Vite React SPA → Supabase auth and data: browser auth and data
- Vite React SPA → Node TypeScript API: API calls
- Minimal Next surface → Supabase auth and data: uses
- Node TypeScript API → Auth and security routes: mounts
- Node TypeScript API → Payment request routes: mounts
- Node TypeScript API → Workflow automation: mounts
- Node TypeScript API → Billing orchestration: uses
- Node TypeScript API → Async and realtime runtime: uses
- Auth and security routes → Supabase auth and data: privileged auth access
- Payment request routes → Billing orchestration: creates payment requests
- Payment request routes → Supabase auth and data: persists requests
- Workflow automation → Async and realtime runtime: enqueues work
- Workflow automation → Workflow queue schema: uses queue records
- Billing orchestration → Payment gateways: charges and verifies
- Billing orchestration → Supabase auth and data: persists payment state
- Async and realtime runtime → Realtime and AI UI: notifications and push
- Supabase auth and data → Roles and tenant RLS: enforces
- Provider verification function → Supabase auth and data: writes outcomes
- Provider verification function → Maps and email providers: verifies providers
- Go service deployments → Supabase auth and data: integrates independently
- Go background worker → Go service deployments: background processing
