# shajeeve567/custodian---client-life-cycle-management-platform architecture

> Architecture diagram of the GitHub repository shajeeve567/custodian---client-life-cycle-management-platform, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-14). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/shajeeve567/custodian---client-life-cycle-management-platform
- Repository: https://github.com/shajeeve567/custodian---client-life-cycle-management-platform

## Overview

Custodian is a client lifecycle management platform. Users authenticate and work through client portals or staff workspaces to manage engagements, next actions, conditions, readiness, documents, and interventions; reporting and audit provide oversight. The backend separates identity, workflow, documents, and audit services, with a React frontend and shared contracts/messaging. Workflow owns engagement access and lifecycle decisions; Documents checks access through Workflow. README documents event messaging from Workflow and Documents through Kafka-compatible Event Hubs to Audit. Unsampled subsystems are shown where the tree or README establishes them; dashed links mark relationships not verified in excerpts.

Main entry points: [`backend/src/services/Documents/Controllers/DocumentsController.cs`](https://github.com/shajeeve567/custodian---client-life-cycle-management-platform/blob/main/backend/src/services/Documents/Controllers/DocumentsController.cs) (Document operations), [`frontend/src/services/api.ts`](https://github.com/shajeeve567/custodian---client-life-cycle-management-platform/blob/main/frontend/src/services/api.ts) (API client), [`backend/src/services/Workflow/Controllers/EngagementsController.cs`](https://github.com/shajeeve567/custodian---client-life-cycle-management-platform/blob/main/backend/src/services/Workflow/Controllers/EngagementsController.cs) (Engagement operations), [`frontend/src/App.tsx`](https://github.com/shajeeve567/custodian---client-life-cycle-management-platform/blob/main/frontend/src/App.tsx) (Application routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Frontend"]
  node_app["Application routes<br/>[App.tsx]"]
  node_authui["Login and registration<br/>[AuthPage.tsx]"]
  node_authctx["Session context<br/>[AuthContext.tsx]"]
  node_api["API client<br/>[api.ts]"]
  node_portal["Client portal"]
  node_workspace["Staff workspace<br/>[WorkspacePage.tsx]"]
end

subgraph group_identity["Identity"]
  node_identityapi["Identity endpoints<br/>[AuthController.cs]"]
  node_identitydata[("Identity and tenant data")]
end

subgraph group_workflow["Lifecycle workflow"]
  node_engagements["Engagement operations"]
  node_actions["Client actions"]
  node_nextaction["Next-action orchestration"]
  node_readiness["Readiness and gates"]
  node_stall["Stall management"]
  node_workflowdata[("Engagement records")]
end

subgraph group_documents["Documents"]
  node_docsapi["Document operations"]
  node_compliance["Compliance rules"]
  node_storage["Document storage"]
  node_docdata[("Document records")]
end

subgraph group_audit["Audit and shared"]
  node_auditapi["Audit event API"]
  node_auditconsumer["Event ingestion"]
  node_hashchain["Engagement hash chain"]
  node_auditdata[("Audit event store<br/>[AuditDbContext.cs]")]
  node_reports["Service reports"]
end

node_user(("Client or staff"))
node_broker["Kafka-compatible Event Hubs"]

node_user -->|"uses"| node_app
node_app -->|"routes to"| node_authui
node_app -->|"routes to"| node_portal
node_app -->|"routes to"| node_workspace
node_authui -->|"uses session"| node_authctx
node_authctx -->|"sets unauthorized handler"| node_api
node_portal -->|"requests data"| node_api
node_workspace -.->|"requests data"| node_api
node_api -->|"logs in"| node_identityapi
node_api -->|"calls workflow"| node_engagements
node_api -->|"uploads documents"| node_docsapi
node_identityapi -.->|"persists accounts"| node_identitydata
node_engagements -->|"reads engagements"| node_workflowdata
node_engagements -->|"gets next action"| node_nextaction
node_engagements -->|"gets readiness"| node_readiness
node_actions -->|"gets stall status"| node_stall
node_docsapi -.->|"checks engagement access"| node_workflowdata
node_docsapi -->|"stores files"| node_storage
node_docsapi -.->|"validates compliance"| node_compliance
node_docsapi -.->|"persists metadata"| node_docdata
node_engagements -->|"publishes events"| node_broker
node_docsapi -->|"publishes events"| node_broker
node_broker -->|"delivers events"| node_auditconsumer
node_auditconsumer -->|"adds hash chain"| node_hashchain
node_hashchain -.->|"stores chained events"| node_auditdata
node_auditapi -.->|"queries audit events"| node_auditdata
node_reports -.->|"reads report data"| node_auditdata

click node_app "https://github.com/shajeeve567/custodian---client-life-cycle-management-platform/blob/main/frontend/src/App.tsx"
click node_authui "https://github.com/shajeeve567/custodian---client-life-cycle-management-platform/blob/main/frontend/src/pages/AuthPage.tsx"
click node_authctx "https://github.com/shajeeve567/custodian---client-life-cycle-management-platform/blob/main/frontend/src/context/AuthContext.tsx"
click node_api "https://github.com/shajeeve567/custodian---client-life-cycle-management-platform/blob/main/frontend/src/services/api.ts"
click node_portal "https://github.com/shajeeve567/custodian---client-life-cycle-management-platform/blob/main/frontend/src/components/ClientPortalView.tsx"
click node_workspace "https://github.com/shajeeve567/custodian---client-life-cycle-management-platform/blob/main/frontend/src/pages/WorkspacePage.tsx"
click node_identityapi "https://github.com/shajeeve567/custodian---client-life-cycle-management-platform/blob/main/backend/src/services/Identity/Controllers/AuthController.cs"
click node_identitydata "https://github.com/shajeeve567/custodian---client-life-cycle-management-platform/blob/main/backend/src/services/Identity/Data/UsersData/UserAccountRepository.cs"
click node_engagements "https://github.com/shajeeve567/custodian---client-life-cycle-management-platform/blob/main/backend/src/services/Workflow/Controllers/EngagementsController.cs"
click node_actions "https://github.com/shajeeve567/custodian---client-life-cycle-management-platform/blob/main/backend/src/services/Workflow/Controllers/ClientActionsController.cs"
click node_nextaction "https://github.com/shajeeve567/custodian---client-life-cycle-management-platform/blob/main/backend/src/services/Workflow/Services/NextAction/NextActionService.cs"
click node_readiness "https://github.com/shajeeve567/custodian---client-life-cycle-management-platform/blob/main/backend/src/services/Workflow/Services/ReadinessService.cs"
click node_stall "https://github.com/shajeeve567/custodian---client-life-cycle-management-platform/blob/main/backend/src/services/Workflow/Services/StallDetectionService.cs"
click node_workflowdata "https://github.com/shajeeve567/custodian---client-life-cycle-management-platform/blob/main/backend/src/services/Workflow/Data/WorkflowDbContext.cs"
click node_docsapi "https://github.com/shajeeve567/custodian---client-life-cycle-management-platform/blob/main/backend/src/services/Documents/Controllers/DocumentsController.cs"
click node_compliance "https://github.com/shajeeve567/custodian---client-life-cycle-management-platform/blob/main/backend/src/services/Documents/Compliance/ComplianceRuleEngine.cs"
click node_storage "https://github.com/shajeeve567/custodian---client-life-cycle-management-platform/blob/main/backend/src/services/Documents/Services/BlobStorageService.cs"
click node_docdata "https://github.com/shajeeve567/custodian---client-life-cycle-management-platform/blob/main/backend/src/services/Documents/Data/DocumentDbContext.cs"
click node_auditapi "https://github.com/shajeeve567/custodian---client-life-cycle-management-platform/blob/main/backend/src/services/Audit/Controllers/AuditEventsController.cs"
click node_auditconsumer "https://github.com/shajeeve567/custodian---client-life-cycle-management-platform/blob/main/backend/src/services/Audit/Services/Kafka/KafkaAuditEventConsumer.cs"
click node_hashchain "https://github.com/shajeeve567/custodian---client-life-cycle-management-platform/blob/main/backend/src/services/Audit/Services/HashChain/HashChainService.cs"
click node_auditdata "https://github.com/shajeeve567/custodian---client-life-cycle-management-platform/blob/main/backend/src/services/Audit/Data/AuditDbContext.cs"
click node_reports "https://github.com/shajeeve567/custodian---client-life-cycle-management-platform/blob/main/backend/src/services/Audit/Services/Reports/ProofOfDeliveryReportService.cs"

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_authui,node_authctx,node_api,node_portal,node_workspace,node_user toneBlue
class node_identityapi,node_identitydata toneAmber
class node_engagements,node_actions,node_nextaction,node_readiness,node_stall,node_workflowdata toneMint
class node_docsapi,node_compliance,node_storage,node_docdata toneRose
class node_auditapi,node_auditconsumer,node_hashchain,node_auditdata,node_reports,node_broker toneIndigo
```

## Components

### Frontend

- [Application routes](https://github.com/shajeeve567/custodian---client-life-cycle-management-platform/blob/main/frontend/src/App.tsx): `frontend/src/App.tsx`
- [Login and registration](https://github.com/shajeeve567/custodian---client-life-cycle-management-platform/blob/main/frontend/src/pages/AuthPage.tsx): `frontend/src/pages/AuthPage.tsx`
- [Session context](https://github.com/shajeeve567/custodian---client-life-cycle-management-platform/blob/main/frontend/src/context/AuthContext.tsx): `frontend/src/context/AuthContext.tsx`
- [API client](https://github.com/shajeeve567/custodian---client-life-cycle-management-platform/blob/main/frontend/src/services/api.ts): `frontend/src/services/api.ts`
- [Client portal](https://github.com/shajeeve567/custodian---client-life-cycle-management-platform/blob/main/frontend/src/components/ClientPortalView.tsx): `frontend/src/components/ClientPortalView.tsx`
- [Staff workspace](https://github.com/shajeeve567/custodian---client-life-cycle-management-platform/blob/main/frontend/src/pages/WorkspacePage.tsx): `frontend/src/pages/WorkspacePage.tsx`

### Identity

- [Identity endpoints](https://github.com/shajeeve567/custodian---client-life-cycle-management-platform/blob/main/backend/src/services/Identity/Controllers/AuthController.cs): `backend/src/services/Identity/Controllers/AuthController.cs`
- [Identity and tenant data](https://github.com/shajeeve567/custodian---client-life-cycle-management-platform/blob/main/backend/src/services/Identity/Data/UsersData/UserAccountRepository.cs): `backend/src/services/Identity/Data/UsersData/UserAccountRepository.cs`

### Lifecycle workflow

- [Engagement operations](https://github.com/shajeeve567/custodian---client-life-cycle-management-platform/blob/main/backend/src/services/Workflow/Controllers/EngagementsController.cs): `backend/src/services/Workflow/Controllers/EngagementsController.cs`
- [Client actions](https://github.com/shajeeve567/custodian---client-life-cycle-management-platform/blob/main/backend/src/services/Workflow/Controllers/ClientActionsController.cs): `backend/src/services/Workflow/Controllers/ClientActionsController.cs`
- [Next-action orchestration](https://github.com/shajeeve567/custodian---client-life-cycle-management-platform/blob/main/backend/src/services/Workflow/Services/NextAction/NextActionService.cs): `backend/src/services/Workflow/Services/NextAction/NextActionService.cs`
- [Readiness and gates](https://github.com/shajeeve567/custodian---client-life-cycle-management-platform/blob/main/backend/src/services/Workflow/Services/ReadinessService.cs): `backend/src/services/Workflow/Services/ReadinessService.cs`
- [Stall management](https://github.com/shajeeve567/custodian---client-life-cycle-management-platform/blob/main/backend/src/services/Workflow/Services/StallDetectionService.cs): `backend/src/services/Workflow/Services/StallDetectionService.cs`
- [Engagement records](https://github.com/shajeeve567/custodian---client-life-cycle-management-platform/blob/main/backend/src/services/Workflow/Data/WorkflowDbContext.cs): `backend/src/services/Workflow/Data/WorkflowDbContext.cs`

### Documents

- [Document operations](https://github.com/shajeeve567/custodian---client-life-cycle-management-platform/blob/main/backend/src/services/Documents/Controllers/DocumentsController.cs): `backend/src/services/Documents/Controllers/DocumentsController.cs`
- [Compliance rules](https://github.com/shajeeve567/custodian---client-life-cycle-management-platform/blob/main/backend/src/services/Documents/Compliance/ComplianceRuleEngine.cs): `backend/src/services/Documents/Compliance/ComplianceRuleEngine.cs`
- [Document storage](https://github.com/shajeeve567/custodian---client-life-cycle-management-platform/blob/main/backend/src/services/Documents/Services/BlobStorageService.cs): `backend/src/services/Documents/Services/BlobStorageService.cs`
- [Document records](https://github.com/shajeeve567/custodian---client-life-cycle-management-platform/blob/main/backend/src/services/Documents/Data/DocumentDbContext.cs): `backend/src/services/Documents/Data/DocumentDbContext.cs`

### Audit and shared

- [Audit event API](https://github.com/shajeeve567/custodian---client-life-cycle-management-platform/blob/main/backend/src/services/Audit/Controllers/AuditEventsController.cs): `backend/src/services/Audit/Controllers/AuditEventsController.cs`
- [Event ingestion](https://github.com/shajeeve567/custodian---client-life-cycle-management-platform/blob/main/backend/src/services/Audit/Services/Kafka/KafkaAuditEventConsumer.cs): `backend/src/services/Audit/Services/Kafka/KafkaAuditEventConsumer.cs`
- [Engagement hash chain](https://github.com/shajeeve567/custodian---client-life-cycle-management-platform/blob/main/backend/src/services/Audit/Services/HashChain/HashChainService.cs): `backend/src/services/Audit/Services/HashChain/HashChainService.cs`
- [Audit event store](https://github.com/shajeeve567/custodian---client-life-cycle-management-platform/blob/main/backend/src/services/Audit/Data/AuditDbContext.cs): `backend/src/services/Audit/Data/AuditDbContext.cs`
- [Service reports](https://github.com/shajeeve567/custodian---client-life-cycle-management-platform/blob/main/backend/src/services/Audit/Services/Reports/ProofOfDeliveryReportService.cs): `backend/src/services/Audit/Services/Reports/ProofOfDeliveryReportService.cs`

### Other components

- **Client or staff**
- **Kafka-compatible Event Hubs**

## Connections

- Client or staff → Application routes: uses (evidence: `frontend/src/App.tsx`)
- Application routes → Login and registration: routes to (evidence: `frontend/src/App.tsx`)
- Application routes → Client portal: routes to (evidence: `frontend/src/App.tsx`)
- Application routes → Staff workspace: routes to (evidence: `frontend/src/App.tsx`)
- Login and registration → Session context: uses session (evidence: `frontend/src/pages/AuthPage.tsx`)
- Session context → API client: sets unauthorized handler (evidence: `frontend/src/context/AuthContext.tsx`)
- Client portal → API client: requests data (evidence: `frontend/src/components/ClientPortalView.tsx`)
- Staff workspace → API client: requests data
- API client → Identity endpoints: logs in (evidence: `frontend/src/services/api.ts`)
- API client → Engagement operations: calls workflow (evidence: `frontend/src/services/api.ts`)
- API client → Document operations: uploads documents (evidence: `frontend/src/services/api.ts`)
- Identity endpoints → Identity and tenant data: persists accounts
- Engagement operations → Engagement records: reads engagements (evidence: `backend/src/services/Workflow/Controllers/EngagementsController.cs`)
- Engagement operations → Next-action orchestration: gets next action (evidence: `backend/src/services/Workflow/Controllers/EngagementsController.cs`)
- Engagement operations → Readiness and gates: gets readiness (evidence: `backend/src/services/Workflow/Controllers/EngagementsController.cs`)
- Client actions → Stall management: gets stall status (evidence: `backend/src/services/Workflow/Controllers/ClientActionsController.cs`)
- Document operations → Engagement records: checks engagement access
- Document operations → Document storage: stores files (evidence: `backend/src/services/Documents/Controllers/DocumentsController.cs`)
- Document operations → Compliance rules: validates compliance
- Document operations → Document records: persists metadata
- Engagement operations → Kafka-compatible Event Hubs: publishes events
- Document operations → Kafka-compatible Event Hubs: publishes events
- Kafka-compatible Event Hubs → Event ingestion: delivers events
- Event ingestion → Engagement hash chain: adds hash chain
- Engagement hash chain → Audit event store: stores chained events
- Audit event API → Audit event store: queries audit events
- Service reports → Audit event store: reads report data
