# openshiporg/openfront-law-firm architecture

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

- Interactive diagram: https://gitdiagram.com/openshiporg/openfront-law-firm
- Repository: https://github.com/openshiporg/openfront-law-firm

## Overview

Openfront Law Firm is a self-hostable legal-practice and client-collaboration application. Visitors discover attorneys and practice areas and can request consultations; firm staff then manage intake, conflicts, matters, deadlines, documents, communications, time, expenses, billing, and trust records, while clients use scoped sharing. The dashboard’s Keystone-backed data layer supports those workflows, with payment-provider webhooks handling payment settlement. The graph preserves documented product areas, but the excerpts show only selected routes and calls; links without direct source evidence are omitted.

Main entry points: [`app/api/payment-webhooks/[providerId]/route.ts`](https://github.com/openshiporg/openfront-law-firm/blob/master/app/api/payment-webhooks/%5BproviderId%5D/route.ts) (Payment webhook), [`features/keystone/index.ts`](https://github.com/openshiporg/openfront-law-firm/blob/master/features/keystone/index.ts) (Keystone configuration), [`features/storefront/screens/ServicePages.tsx`](https://github.com/openshiporg/openfront-law-firm/blob/master/features/storefront/screens/ServicePages.tsx) (Public site), [`features/dashboard/hooks/useQueryFactory.ts`](https://github.com/openshiporg/openfront-law-firm/blob/master/features/dashboard/hooks/useQueryFactory.ts) (Dashboard queries)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_public["Public and client experience"]
  node_public_site["Public site<br/>[ServicePages.tsx]"]
  node_consultation["Consultation booking<br/>[ServicePages.tsx]"]
  node_client_portal["Client portal<br/>[actions.ts]"]
end

subgraph group_dashboard["Firm dashboard"]
  node_dashboard_ui["Dashboard interface"]
  node_dashboard_queries["Dashboard queries<br/>[useQueryFactory.ts]"]
  node_admin_data["Admin data actions"]
  node_query_factory["Query factory<br/>[useQueryFactory.ts]"]
  node_query_cache["Query cache<br/>[queryClient.ts]"]
end

subgraph group_domain["Legal practice operations"]
  node_intake_conflicts["Intake and conflicts<br/>[intakeWorkflows.ts]"]
  node_matters_work["Matters and work"]
  node_documents_comms["Documents and communications<br/>[documents.ts]"]
  node_billing_trust["Billing and trust"]
end

subgraph group_platform["Platform services"]
  node_ai_research["AI and legal research<br/>[completion.ts]"]
  node_accounting["Accounting<br/>[AccountingPage.tsx]"]
  node_payment_webhook["Payment webhook<br/>[route.ts]"]
  node_payment_adapter["Provider adapter"]
  node_payment_workflows["Payment workflows<br/>[portalPayments.ts]"]
  node_consultation_payments["Consultation payments"]
end

subgraph group_data["Application data layer"]
  node_keystone["Keystone configuration<br/>[index.ts]"]
  node_models["Domain models"]
  node_database[("PostgreSQL database<br/>[database-url.ts]")]
end

node_visitors(("Visitors"))
node_clients(("Clients"))
node_staff(("Firm staff"))

node_visitors -->|"explore"| node_public_site
node_public_site -->|"request consultation"| node_consultation
node_clients -->|"use sharing"| node_client_portal
node_staff -->|"manage practice"| node_dashboard_ui
node_staff -->|"manage intake"| node_intake_conflicts
node_staff -->|"manage matters"| node_matters_work
node_staff -->|"manage records"| node_documents_comms
node_staff -->|"manage finances"| node_billing_trust
node_staff -->|"manage accounting"| node_accounting
node_staff -->|"use AI tools"| node_ai_research
node_dashboard_queries -->|"uses"| node_query_factory
node_query_factory -->|"queries"| node_admin_data
node_admin_data -->|"uses client"| node_keystone
node_keystone -->|"registers"| node_models
node_keystone -->|"configures"| node_database
node_payment_webhook -->|"verifies event"| node_payment_adapter
node_payment_webhook -->|"reconciles payment"| node_payment_workflows
node_payment_webhook -->|"settles consultation"| node_consultation_payments
node_clients -->|"pay invoices"| node_billing_trust
node_query_cache -.->|"caches queries"| node_dashboard_queries

click node_public_site "https://github.com/openshiporg/openfront-law-firm/blob/master/features/storefront/screens/ServicePages.tsx"
click node_consultation "https://github.com/openshiporg/openfront-law-firm/blob/master/features/storefront/screens/ServicePages.tsx"
click node_client_portal "https://github.com/openshiporg/openfront-law-firm/blob/master/features/portal/actions.ts"
click node_dashboard_ui "https://github.com/openshiporg/openfront-law-firm/tree/master/features/dashboard/screens"
click node_dashboard_queries "https://github.com/openshiporg/openfront-law-firm/blob/master/features/dashboard/hooks/useQueryFactory.ts"
click node_admin_data "https://github.com/openshiporg/openfront-law-firm/blob/master/features/dashboard/actions/getAdminMetaAction.ts"
click node_intake_conflicts "https://github.com/openshiporg/openfront-law-firm/blob/master/features/keystone/mutations/intakeWorkflows.ts"
click node_matters_work "https://github.com/openshiporg/openfront-law-firm/blob/master/features/keystone/mutations/practiceWorkflows.ts"
click node_documents_comms "https://github.com/openshiporg/openfront-law-firm/blob/master/features/keystone/models/documents.ts"
click node_billing_trust "https://github.com/openshiporg/openfront-law-firm/blob/master/features/keystone/mutations/billingWorkflows.ts"
click node_ai_research "https://github.com/openshiporg/openfront-law-firm/blob/master/features/platform/ai/api/completion.ts"
click node_accounting "https://github.com/openshiporg/openfront-law-firm/blob/master/features/platform/accounting/screens/AccountingPage.tsx"
click node_payment_webhook "https://github.com/openshiporg/openfront-law-firm/blob/master/app/api/payment-webhooks/%5BproviderId%5D/route.ts"
click node_payment_adapter "https://github.com/openshiporg/openfront-law-firm/blob/master/features/keystone/utils/paymentProviderAdapter.ts"
click node_payment_workflows "https://github.com/openshiporg/openfront-law-firm/blob/master/features/keystone/mutations/portalPayments.ts"
click node_consultation_payments "https://github.com/openshiporg/openfront-law-firm/blob/master/features/keystone/mutations/consultationPayments.ts"
click node_keystone "https://github.com/openshiporg/openfront-law-firm/blob/master/features/keystone/index.ts"
click node_models "https://github.com/openshiporg/openfront-law-firm/tree/master/features/keystone/models"
click node_database "https://github.com/openshiporg/openfront-law-firm/blob/master/features/keystone/database-url.ts"
click node_query_factory "https://github.com/openshiporg/openfront-law-firm/blob/master/features/dashboard/hooks/useQueryFactory.ts"
click node_query_cache "https://github.com/openshiporg/openfront-law-firm/blob/master/features/dashboard/lib/queryClient.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_public_site,node_consultation,node_client_portal,node_clients toneBlue
class node_dashboard_ui,node_dashboard_queries,node_admin_data,node_query_factory,node_query_cache toneAmber
class node_intake_conflicts,node_matters_work,node_documents_comms,node_billing_trust toneMint
class node_ai_research,node_accounting,node_payment_webhook,node_payment_adapter,node_payment_workflows,node_consultation_payments toneRose
class node_keystone,node_models,node_database,node_visitors,node_staff toneIndigo
```

## Components

### Public and client experience

- [Public site](https://github.com/openshiporg/openfront-law-firm/blob/master/features/storefront/screens/ServicePages.tsx): `features/storefront/screens/ServicePages.tsx`
- [Consultation booking](https://github.com/openshiporg/openfront-law-firm/blob/master/features/storefront/screens/ServicePages.tsx): `features/storefront/screens/ServicePages.tsx`
- [Client portal](https://github.com/openshiporg/openfront-law-firm/blob/master/features/portal/actions.ts): `features/portal/actions.ts`

### Firm dashboard

- [Dashboard interface](https://github.com/openshiporg/openfront-law-firm/tree/master/features/dashboard/screens): `features/dashboard/screens`
- [Dashboard queries](https://github.com/openshiporg/openfront-law-firm/blob/master/features/dashboard/hooks/useQueryFactory.ts): `features/dashboard/hooks/useQueryFactory.ts`
- [Admin data actions](https://github.com/openshiporg/openfront-law-firm/blob/master/features/dashboard/actions/getAdminMetaAction.ts): `features/dashboard/actions/getAdminMetaAction.ts`
- [Query factory](https://github.com/openshiporg/openfront-law-firm/blob/master/features/dashboard/hooks/useQueryFactory.ts): `features/dashboard/hooks/useQueryFactory.ts`
- [Query cache](https://github.com/openshiporg/openfront-law-firm/blob/master/features/dashboard/lib/queryClient.ts): `features/dashboard/lib/queryClient.ts`

### Legal practice operations

- [Intake and conflicts](https://github.com/openshiporg/openfront-law-firm/blob/master/features/keystone/mutations/intakeWorkflows.ts): `features/keystone/mutations/intakeWorkflows.ts`
- [Matters and work](https://github.com/openshiporg/openfront-law-firm/blob/master/features/keystone/mutations/practiceWorkflows.ts): `features/keystone/mutations/practiceWorkflows.ts`
- [Documents and communications](https://github.com/openshiporg/openfront-law-firm/blob/master/features/keystone/models/documents.ts): `features/keystone/models/documents.ts`
- [Billing and trust](https://github.com/openshiporg/openfront-law-firm/blob/master/features/keystone/mutations/billingWorkflows.ts): `features/keystone/mutations/billingWorkflows.ts`

### Platform services

- [AI and legal research](https://github.com/openshiporg/openfront-law-firm/blob/master/features/platform/ai/api/completion.ts): `features/platform/ai/api/completion.ts`
- [Accounting](https://github.com/openshiporg/openfront-law-firm/blob/master/features/platform/accounting/screens/AccountingPage.tsx): `features/platform/accounting/screens/AccountingPage.tsx`
- [Payment webhook](https://github.com/openshiporg/openfront-law-firm/blob/master/app/api/payment-webhooks/%5BproviderId%5D/route.ts): `app/api/payment-webhooks/[providerId]/route.ts`
- [Provider adapter](https://github.com/openshiporg/openfront-law-firm/blob/master/features/keystone/utils/paymentProviderAdapter.ts): `features/keystone/utils/paymentProviderAdapter.ts`
- [Payment workflows](https://github.com/openshiporg/openfront-law-firm/blob/master/features/keystone/mutations/portalPayments.ts): `features/keystone/mutations/portalPayments.ts`
- [Consultation payments](https://github.com/openshiporg/openfront-law-firm/blob/master/features/keystone/mutations/consultationPayments.ts): `features/keystone/mutations/consultationPayments.ts`

### Application data layer

- [Keystone configuration](https://github.com/openshiporg/openfront-law-firm/blob/master/features/keystone/index.ts): `features/keystone/index.ts`
- [Domain models](https://github.com/openshiporg/openfront-law-firm/tree/master/features/keystone/models): `features/keystone/models`
- [PostgreSQL database](https://github.com/openshiporg/openfront-law-firm/blob/master/features/keystone/database-url.ts): `features/keystone/database-url.ts`

### Other components

- **Visitors**
- **Clients**
- **Firm staff**

## Connections

- Visitors → Public site: explore (evidence: `README.md`)
- Public site → Consultation booking: request consultation (evidence: `features/storefront/screens/ServicePages.tsx`)
- Clients → Client portal: use sharing (evidence: `README.md`)
- Firm staff → Dashboard interface: manage practice (evidence: `README.md`)
- Firm staff → Intake and conflicts: manage intake (evidence: `README.md`)
- Firm staff → Matters and work: manage matters (evidence: `README.md`)
- Firm staff → Documents and communications: manage records (evidence: `README.md`)
- Firm staff → Billing and trust: manage finances (evidence: `README.md`)
- Firm staff → Accounting: manage accounting
- Firm staff → AI and legal research: use AI tools
- Dashboard queries → Query factory: uses (evidence: `features/dashboard/hooks/useAdminMeta.query.ts`)
- Query factory → Admin data actions: queries (evidence: `features/dashboard/hooks/useAdminMeta.query.ts`)
- Admin data actions → Keystone configuration: uses client (evidence: `features/dashboard/actions/getAdminMetaAction.ts`)
- Keystone configuration → Domain models: registers (evidence: `features/keystone/index.ts`)
- Keystone configuration → PostgreSQL database: configures (evidence: `features/keystone/index.ts`)
- Payment webhook → Provider adapter: verifies event (evidence: `app/api/payment-webhooks/[providerId]/route.ts`)
- Payment webhook → Payment workflows: reconciles payment (evidence: `app/api/payment-webhooks/[providerId]/route.ts`)
- Payment webhook → Consultation payments: settles consultation (evidence: `app/api/payment-webhooks/[providerId]/route.ts`)
- Clients → Billing and trust: pay invoices (evidence: `README.md`)
- Query cache → Dashboard queries: caches queries
