# soha-nabi/relay architecture

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

- Interactive diagram: https://gitdiagram.com/soha-nabi/relay
- Repository: https://github.com/soha-nabi/relay

## Overview

Relay is a payment-recovery platform for merchants and customers. A merchant or administrator signs in, reviews recovery and payment analytics, and can upload transaction data or configure automations; failed payments are analyzed and recovery actions are coordinated, while customers can choose a payment method and complete recovery. Dashboards expose performance and role-specific views. The graph preserves documented analytics and workflow capabilities even where their UI or implementation was not sampled. Edges reflect shown imports/calls or README statements; unsampled links are omitted.

Main entry points: [`frontend/src/components/MerchantShell.tsx`](https://github.com/soha-nabi/relay/blob/main/frontend/src/components/MerchantShell.tsx) (Merchant dashboard), [`frontend/src/lib/api.ts`](https://github.com/soha-nabi/relay/blob/main/frontend/src/lib/api.ts) (Frontend API client), [`main.py`](https://github.com/soha-nabi/relay/blob/main/main.py) (FastAPI application), [`frontend/src/components/LoginView.tsx`](https://github.com/soha-nabi/relay/blob/main/frontend/src/components/LoginView.tsx) (Login view)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_access["Access and roles"]
  node_auth_ui["Authentication context<br/>[AuthContext.tsx]"]
  node_auth_view["Login view<br/>[LoginView.tsx]"]
end

subgraph group_experience["Dashboards and customer experience"]
  node_admin_ui["Admin dashboard<br/>[AdminShell.tsx]"]
  node_merchant_ui["Merchant dashboard<br/>[MerchantShell.tsx]"]
  node_merchant_overview["Recovery overview"]
  node_analytics["Recovery analytics<br/>[Analytics.tsx]"]
  node_user_ui["User dashboard<br/>[UserShell.tsx]"]
  node_mobile_drawer["Mobile navigation<br/>[MobileDrawer.tsx]"]
  node_payment_experience["Customer payment"]
end

subgraph group_recovery["Recovery operations"]
  node_recovery_workflow["Recovery workflow"]
  node_automation_ui["Automation console"]
  node_webhook_demo["Webhook simulator"]
  node_recovery_engine["Recovery engine<br/>[recovery_engine.py]"]
  node_automation_engine["Automation engine"]
end

subgraph group_platform["API and persistence"]
  node_api_client["Frontend API client<br/>[api.ts]"]
  node_api_server["FastAPI application<br/>[main.py]"]
  node_database[("MongoDB persistence<br/>[db.py]")]
end

subgraph group_integrations["Communications"]
  node_voice_ui["Voice recovery agent"]
  node_voice_service["Voice service"]
  node_email_service["Email service<br/>[email_service.py]"]
  node_email_logs["Email log repository"]
end

node_merchant(("Merchant"))
node_customer(("Customer"))
node_admin(("Administrator"))

node_merchant -->|"signs in"| node_auth_view
node_customer -->|"signs in"| node_auth_view
node_admin -->|"signs in"| node_auth_view
node_auth_view -->|"uses"| node_auth_ui
node_auth_ui -->|"calls"| node_api_client
node_api_client -->|"requests"| node_api_server
node_merchant -->|"reviews"| node_merchant_ui
node_admin -->|"reviews"| node_admin_ui
node_customer -->|"accesses"| node_user_ui
node_merchant_ui -->|"renders"| node_merchant_overview
node_merchant_ui -->|"renders"| node_recovery_workflow
node_merchant_ui -->|"renders"| node_automation_ui
node_merchant_ui -->|"renders"| node_payment_experience
node_merchant_ui -->|"renders"| node_mobile_drawer
node_admin_ui -->|"renders"| node_mobile_drawer
node_user_ui -->|"renders"| node_mobile_drawer
node_user_ui -->|"renders"| node_payment_experience
node_merchant_ui -->|"requests data"| node_api_client
node_recovery_workflow -->|"requests"| node_api_client
node_automation_ui -->|"manages workflows"| node_api_client
node_payment_experience -->|"processes payment"| node_api_client
node_webhook_demo -->|"sends event"| node_api_client
node_api_server -->|"delegates"| node_recovery_engine
node_api_server -->|"delegates"| node_automation_engine
node_api_server -->|"persists data"| node_database
node_automation_engine -->|"delegates actions"| node_recovery_engine
node_automation_engine -->|"reads and writes"| node_database
node_recovery_engine -->|"records sessions"| node_database
node_api_server -->|"sends recovery email"| node_email_service
node_email_service -->|"checks and marks sends"| node_recovery_engine
node_email_service -->|"records email"| node_email_logs
node_email_logs -->|"writes logs"| node_database
node_merchant_ui -.->|"shows reporting"| node_analytics
node_voice_ui -.->|"connects agent"| node_voice_service

click node_auth_ui "https://github.com/soha-nabi/relay/blob/main/frontend/src/contexts/AuthContext.tsx"
click node_auth_view "https://github.com/soha-nabi/relay/blob/main/frontend/src/components/LoginView.tsx"
click node_admin_ui "https://github.com/soha-nabi/relay/blob/main/frontend/src/components/AdminShell.tsx"
click node_merchant_ui "https://github.com/soha-nabi/relay/blob/main/frontend/src/components/MerchantShell.tsx"
click node_merchant_overview "https://github.com/soha-nabi/relay/blob/main/frontend/src/components/MerchantOverview.tsx"
click node_analytics "https://github.com/soha-nabi/relay/blob/main/frontend/src/components/Analytics.tsx"
click node_user_ui "https://github.com/soha-nabi/relay/blob/main/frontend/src/components/UserShell.tsx"
click node_mobile_drawer "https://github.com/soha-nabi/relay/blob/main/frontend/src/components/MobileDrawer.tsx"
click node_payment_experience "https://github.com/soha-nabi/relay/blob/main/frontend/src/components/CustomerPaymentExperience.tsx"
click node_recovery_workflow "https://github.com/soha-nabi/relay/blob/main/frontend/src/components/RecoveryWorkflow.tsx"
click node_automation_ui "https://github.com/soha-nabi/relay/blob/main/frontend/src/components/AutomationsCenter.tsx"
click node_webhook_demo "https://github.com/soha-nabi/relay/blob/main/frontend/src/components/WebhookDemoWidget.tsx"
click node_api_client "https://github.com/soha-nabi/relay/blob/main/frontend/src/lib/api.ts"
click node_api_server "https://github.com/soha-nabi/relay/blob/main/main.py"
click node_recovery_engine "https://github.com/soha-nabi/relay/blob/main/backend/recovery_engine.py"
click node_automation_engine "https://github.com/soha-nabi/relay/blob/main/backend/automation_engine.py"
click node_database "https://github.com/soha-nabi/relay/blob/main/backend/db.py"
click node_voice_ui "https://github.com/soha-nabi/relay/blob/main/frontend/src/components/RelayVoiceAgent.tsx"
click node_voice_service "https://github.com/soha-nabi/relay/blob/main/backend/elevenlabs_service.py"
click node_email_service "https://github.com/soha-nabi/relay/blob/main/backend/email_service.py"
click node_email_logs "https://github.com/soha-nabi/relay/blob/main/backend/email_log_repository.py"

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_auth_ui,node_auth_view toneBlue
class node_admin_ui,node_merchant_ui,node_merchant_overview,node_analytics,node_user_ui,node_mobile_drawer,node_payment_experience toneAmber
class node_recovery_workflow,node_automation_ui,node_webhook_demo,node_recovery_engine,node_automation_engine toneMint
class node_api_client,node_api_server,node_database toneRose
class node_voice_ui,node_voice_service,node_email_service,node_email_logs,node_merchant,node_customer,node_admin toneIndigo
```

## Components

### Access and roles

- [Authentication context](https://github.com/soha-nabi/relay/blob/main/frontend/src/contexts/AuthContext.tsx): `frontend/src/contexts/AuthContext.tsx`
- [Login view](https://github.com/soha-nabi/relay/blob/main/frontend/src/components/LoginView.tsx): `frontend/src/components/LoginView.tsx`

### Dashboards and customer experience

- [Admin dashboard](https://github.com/soha-nabi/relay/blob/main/frontend/src/components/AdminShell.tsx): `frontend/src/components/AdminShell.tsx`
- [Merchant dashboard](https://github.com/soha-nabi/relay/blob/main/frontend/src/components/MerchantShell.tsx): `frontend/src/components/MerchantShell.tsx`
- [Recovery overview](https://github.com/soha-nabi/relay/blob/main/frontend/src/components/MerchantOverview.tsx): `frontend/src/components/MerchantOverview.tsx`
- [Recovery analytics](https://github.com/soha-nabi/relay/blob/main/frontend/src/components/Analytics.tsx): `frontend/src/components/Analytics.tsx`
- [User dashboard](https://github.com/soha-nabi/relay/blob/main/frontend/src/components/UserShell.tsx): `frontend/src/components/UserShell.tsx`
- [Mobile navigation](https://github.com/soha-nabi/relay/blob/main/frontend/src/components/MobileDrawer.tsx): `frontend/src/components/MobileDrawer.tsx`
- [Customer payment](https://github.com/soha-nabi/relay/blob/main/frontend/src/components/CustomerPaymentExperience.tsx): `frontend/src/components/CustomerPaymentExperience.tsx`

### Recovery operations

- [Recovery workflow](https://github.com/soha-nabi/relay/blob/main/frontend/src/components/RecoveryWorkflow.tsx): `frontend/src/components/RecoveryWorkflow.tsx`
- [Automation console](https://github.com/soha-nabi/relay/blob/main/frontend/src/components/AutomationsCenter.tsx): `frontend/src/components/AutomationsCenter.tsx`
- [Webhook simulator](https://github.com/soha-nabi/relay/blob/main/frontend/src/components/WebhookDemoWidget.tsx): `frontend/src/components/WebhookDemoWidget.tsx`
- [Recovery engine](https://github.com/soha-nabi/relay/blob/main/backend/recovery_engine.py): `backend/recovery_engine.py`
- [Automation engine](https://github.com/soha-nabi/relay/blob/main/backend/automation_engine.py): `backend/automation_engine.py`

### API and persistence

- [Frontend API client](https://github.com/soha-nabi/relay/blob/main/frontend/src/lib/api.ts): `frontend/src/lib/api.ts`
- [FastAPI application](https://github.com/soha-nabi/relay/blob/main/main.py): `main.py`
- [MongoDB persistence](https://github.com/soha-nabi/relay/blob/main/backend/db.py): `backend/db.py`

### Communications

- [Voice recovery agent](https://github.com/soha-nabi/relay/blob/main/frontend/src/components/RelayVoiceAgent.tsx): `frontend/src/components/RelayVoiceAgent.tsx`
- [Voice service](https://github.com/soha-nabi/relay/blob/main/backend/elevenlabs_service.py): `backend/elevenlabs_service.py`
- [Email service](https://github.com/soha-nabi/relay/blob/main/backend/email_service.py): `backend/email_service.py`
- [Email log repository](https://github.com/soha-nabi/relay/blob/main/backend/email_log_repository.py): `backend/email_log_repository.py`

### Other components

- **Merchant**
- **Customer**
- **Administrator**

## Connections

- Merchant → Login view: signs in (evidence: `README.md`)
- Customer → Login view: signs in (evidence: `README.md`)
- Administrator → Login view: signs in (evidence: `README.md`)
- Login view → Authentication context: uses (evidence: `frontend/src/components/LoginView.tsx`)
- Authentication context → Frontend API client: calls (evidence: `frontend/src/contexts/AuthContext.tsx`)
- Frontend API client → FastAPI application: requests (evidence: `README.md`)
- Merchant → Merchant dashboard: reviews (evidence: `README.md`)
- Administrator → Admin dashboard: reviews (evidence: `README.md`)
- Customer → User dashboard: accesses (evidence: `README.md`)
- Merchant dashboard → Recovery overview: renders (evidence: `frontend/src/components/MerchantShell.tsx`)
- Merchant dashboard → Recovery workflow: renders (evidence: `frontend/src/components/MerchantShell.tsx`)
- Merchant dashboard → Automation console: renders (evidence: `frontend/src/components/MerchantShell.tsx`)
- Merchant dashboard → Customer payment: renders (evidence: `frontend/src/components/MerchantShell.tsx`)
- Merchant dashboard → Mobile navigation: renders (evidence: `frontend/src/components/MerchantShell.tsx`)
- Admin dashboard → Mobile navigation: renders (evidence: `frontend/src/components/AdminShell.tsx`)
- User dashboard → Mobile navigation: renders (evidence: `frontend/src/components/UserShell.tsx`)
- User dashboard → Customer payment: renders (evidence: `frontend/src/components/UserShell.tsx`)
- Merchant dashboard → Frontend API client: requests data (evidence: `frontend/src/components/MerchantShell.tsx`)
- Recovery workflow → Frontend API client: requests (evidence: `frontend/src/components/RecoveryWorkflow.tsx`)
- Automation console → Frontend API client: manages workflows (evidence: `frontend/src/components/AutomationsCenter.tsx`)
- Customer payment → Frontend API client: processes payment (evidence: `frontend/src/components/CustomerPaymentExperience.tsx`)
- Webhook simulator → Frontend API client: sends event (evidence: `frontend/src/components/WebhookDemoWidget.tsx`)
- FastAPI application → Recovery engine: delegates (evidence: `main.py`)
- FastAPI application → Automation engine: delegates (evidence: `main.py`)
- FastAPI application → MongoDB persistence: persists data (evidence: `main.py`)
- Automation engine → Recovery engine: delegates actions (evidence: `backend/automation_engine.py`)
- Automation engine → MongoDB persistence: reads and writes (evidence: `backend/automation_engine.py`)
- Recovery engine → MongoDB persistence: records sessions (evidence: `backend/recovery_engine.py`)
- FastAPI application → Email service: sends recovery email (evidence: `main.py`)
- Email service → Recovery engine: checks and marks sends (evidence: `backend/email_service.py`)
- Email service → Email log repository: records email (evidence: `backend/email_service.py`)
- Email log repository → MongoDB persistence: writes logs (evidence: `backend/email_log_repository.py`)
- Merchant dashboard → Recovery analytics: shows reporting
- Voice recovery agent → Voice service: connects agent
