# jahfeelautomation/openlevel architecture

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

- Interactive diagram: https://gitdiagram.com/jahfeelautomation/openlevel
- Repository: https://github.com/jahfeelautomation/openlevel

## Overview

OpenLevel is a multi-tenant, AI-oriented CRM with a web SPA, an Expo mobile client, and a Hono API. The operator workflow is to sign in, work within a location, and manage CRM records and business operations through the clients and API. The backend also supports public-facing pages, integrations, and agent/workflow automation. Several domain branches are documented or routed in the sampled files, but their internal calls were not sampled; those links are therefore omitted. Source evidence for mobile covers pipeline and review screens, not every mobile capability.

Main entry points: [`server/index.ts`](https://github.com/jahfeelautomation/openlevel/blob/master/server/index.ts) (API server), [`server/routes`](https://github.com/jahfeelautomation/openlevel/tree/master/server/routes) (CRM and domain routes), [`src/lib/api.ts`](https://github.com/jahfeelautomation/openlevel/blob/master/src/lib/api.ts) (Typed API client), [`server/repos/base-repo.ts`](https://github.com/jahfeelautomation/openlevel/blob/master/server/repos/base-repo.ts) (Location-scoped repository)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_clients["Operator clients"]
  node_web["Web application<br/>[App.tsx]"]
  node_webfeatures["CRM and business screens"]
  node_webapi["Typed API client<br/>[api.ts]"]
  node_mobile["Mobile application"]
  node_mobilecontext["Mobile API context<br/>[ctx.tsx]"]
  node_pipelinescreen["Pipeline settings"]
end

subgraph group_api["API and access"]
  node_server["API server<br/>[index.ts]"]
  node_auth["Authentication<br/>[auth.ts]"]
end

subgraph group_crm["CRM and operations"]
  node_crmroutes["CRM and domain routes"]
  node_pipelinesapi["Pipeline routes<br/>[pipelines.ts]"]
  node_pipelinerepo["Pipeline repository<br/>[pipelines-repo.ts]"]
  node_domainrepos["Domain repositories"]
  node_publicpages["Public pages<br/>[public-funnels.ts]"]
  node_integrations["External integrations"]
end

subgraph group_automation["AI and automation"]
  node_agentworker["Agent reply worker<br/>[agent-reply.ts]"]
  node_agentengine["Agent engine<br/>[agent-engine.ts]"]
  node_agentmodel["Anthropic client<br/>[anthropic.ts]"]
  node_workflowdispatch["Workflow dispatcher"]
  node_workflowrunner["Workflow runner<br/>[workflow-runner.ts]"]
end

subgraph group_storage["Persistence"]
  node_database["Database interface<br/>[database.ts]"]
  node_postgres[("Postgres database<br/>[database.ts]")]
  node_baserepo["Location-scoped repository<br/>[base-repo.ts]"]
  node_timelinerepo["Contact timeline<br/>[timeline-repo.ts]"]
end

node_operator(("Operator"))

node_operator -->|"uses"| node_web
node_web -->|"routes to"| node_webfeatures
node_webfeatures -->|"requests data"| node_webapi
node_operator -.->|"uses"| node_mobile
node_mobile -->|"uses context"| node_mobilecontext
node_mobilecontext -->|"uses API"| node_webapi
node_webapi -->|"calls API"| node_server
node_server -->|"applies"| node_auth
node_server -->|"mounts routes"| node_crmroutes
node_webfeatures -->|"includes settings"| node_pipelinescreen
node_pipelinescreen -->|"requests data"| node_webapi
node_crmroutes -.->|"includes"| node_pipelinesapi
node_pipelinesapi -->|"calls"| node_pipelinerepo
node_pipelinerepo -->|"extends"| node_baserepo
node_crmroutes -->|"mounts public pages"| node_publicpages
node_crmroutes -->|"mounts webhook"| node_integrations
node_integrations -->|"updates records"| node_domainrepos
node_server -->|"enqueues replies"| node_agentworker
node_agentworker -->|"generates reply"| node_agentengine
node_agentengine -->|"runs model"| node_agentmodel
node_agentengine -->|"reads history"| node_timelinerepo
node_agentworker -->|"dispatches events"| node_workflowdispatch
node_workflowdispatch -->|"starts runs"| node_workflowrunner
node_pipelinerepo -->|"queries through"| node_baserepo
node_baserepo -->|"queries"| node_database
node_database -->|"implemented by"| node_postgres
node_timelinerepo -->|"extends"| node_baserepo

click node_web "https://github.com/jahfeelautomation/openlevel/blob/master/src/App.tsx"
click node_webfeatures "https://github.com/jahfeelautomation/openlevel/tree/master/src/features"
click node_webapi "https://github.com/jahfeelautomation/openlevel/blob/master/src/lib/api.ts"
click node_mobile "https://github.com/jahfeelautomation/openlevel/tree/master/openconnector/app"
click node_mobilecontext "https://github.com/jahfeelautomation/openlevel/blob/master/openconnector/app/ctx.tsx"
click node_server "https://github.com/jahfeelautomation/openlevel/blob/master/server/index.ts"
click node_auth "https://github.com/jahfeelautomation/openlevel/blob/master/server/middleware/auth.ts"
click node_crmroutes "https://github.com/jahfeelautomation/openlevel/tree/master/server/routes"
click node_pipelinescreen "https://github.com/jahfeelautomation/openlevel/blob/master/src/features/settings/PipelinesSettingsPage.tsx"
click node_pipelinesapi "https://github.com/jahfeelautomation/openlevel/blob/master/server/routes/pipelines.ts"
click node_pipelinerepo "https://github.com/jahfeelautomation/openlevel/blob/master/server/repos/pipelines-repo.ts"
click node_domainrepos "https://github.com/jahfeelautomation/openlevel/tree/master/server/repos"
click node_publicpages "https://github.com/jahfeelautomation/openlevel/blob/master/server/routes/public-funnels.ts"
click node_integrations "https://github.com/jahfeelautomation/openlevel/blob/master/server/routes/webhooks-chatwoot.ts"
click node_agentworker "https://github.com/jahfeelautomation/openlevel/blob/master/server/jobs/agent-reply.ts"
click node_agentengine "https://github.com/jahfeelautomation/openlevel/blob/master/server/lib/agent-engine.ts"
click node_agentmodel "https://github.com/jahfeelautomation/openlevel/blob/master/server/lib/anthropic.ts"
click node_workflowdispatch "https://github.com/jahfeelautomation/openlevel/blob/master/server/jobs/workflow-dispatcher.ts"
click node_workflowrunner "https://github.com/jahfeelautomation/openlevel/blob/master/server/jobs/workflow-runner.ts"
click node_database "https://github.com/jahfeelautomation/openlevel/blob/master/server/db/database.ts"
click node_postgres "https://github.com/jahfeelautomation/openlevel/blob/master/server/db/database.ts"
click node_baserepo "https://github.com/jahfeelautomation/openlevel/blob/master/server/repos/base-repo.ts"
click node_timelinerepo "https://github.com/jahfeelautomation/openlevel/blob/master/server/repos/timeline-repo.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_web,node_webfeatures,node_webapi,node_mobile,node_mobilecontext,node_pipelinescreen toneBlue
class node_server,node_auth toneAmber
class node_crmroutes,node_pipelinesapi,node_pipelinerepo,node_domainrepos,node_publicpages,node_integrations toneMint
class node_agentworker,node_agentengine,node_agentmodel,node_workflowdispatch,node_workflowrunner toneRose
class node_database,node_postgres,node_baserepo,node_timelinerepo,node_operator toneIndigo
```

## Components

### Operator clients

- [Web application](https://github.com/jahfeelautomation/openlevel/blob/master/src/App.tsx): `src/App.tsx`
- [CRM and business screens](https://github.com/jahfeelautomation/openlevel/tree/master/src/features): `src/features`
- [Typed API client](https://github.com/jahfeelautomation/openlevel/blob/master/src/lib/api.ts): `src/lib/api.ts`
- [Mobile application](https://github.com/jahfeelautomation/openlevel/tree/master/openconnector/app): `openconnector/app`
- [Mobile API context](https://github.com/jahfeelautomation/openlevel/blob/master/openconnector/app/ctx.tsx): `openconnector/app/ctx.tsx`
- [Pipeline settings](https://github.com/jahfeelautomation/openlevel/blob/master/src/features/settings/PipelinesSettingsPage.tsx): `src/features/settings/PipelinesSettingsPage.tsx`

### API and access

- [API server](https://github.com/jahfeelautomation/openlevel/blob/master/server/index.ts): `server/index.ts`
- [Authentication](https://github.com/jahfeelautomation/openlevel/blob/master/server/middleware/auth.ts): `server/middleware/auth.ts`

### CRM and operations

- [CRM and domain routes](https://github.com/jahfeelautomation/openlevel/tree/master/server/routes): `server/routes`
- [Pipeline routes](https://github.com/jahfeelautomation/openlevel/blob/master/server/routes/pipelines.ts): `server/routes/pipelines.ts`
- [Pipeline repository](https://github.com/jahfeelautomation/openlevel/blob/master/server/repos/pipelines-repo.ts): `server/repos/pipelines-repo.ts`
- [Domain repositories](https://github.com/jahfeelautomation/openlevel/tree/master/server/repos): `server/repos`
- [Public pages](https://github.com/jahfeelautomation/openlevel/blob/master/server/routes/public-funnels.ts): `server/routes/public-funnels.ts`
- [External integrations](https://github.com/jahfeelautomation/openlevel/blob/master/server/routes/webhooks-chatwoot.ts): `server/routes/webhooks-chatwoot.ts`

### AI and automation

- [Agent reply worker](https://github.com/jahfeelautomation/openlevel/blob/master/server/jobs/agent-reply.ts): `server/jobs/agent-reply.ts`
- [Agent engine](https://github.com/jahfeelautomation/openlevel/blob/master/server/lib/agent-engine.ts): `server/lib/agent-engine.ts`
- [Anthropic client](https://github.com/jahfeelautomation/openlevel/blob/master/server/lib/anthropic.ts): `server/lib/anthropic.ts`
- [Workflow dispatcher](https://github.com/jahfeelautomation/openlevel/blob/master/server/jobs/workflow-dispatcher.ts): `server/jobs/workflow-dispatcher.ts`
- [Workflow runner](https://github.com/jahfeelautomation/openlevel/blob/master/server/jobs/workflow-runner.ts): `server/jobs/workflow-runner.ts`

### Persistence

- [Database interface](https://github.com/jahfeelautomation/openlevel/blob/master/server/db/database.ts): `server/db/database.ts`
- [Postgres database](https://github.com/jahfeelautomation/openlevel/blob/master/server/db/database.ts): `server/db/database.ts`
- [Location-scoped repository](https://github.com/jahfeelautomation/openlevel/blob/master/server/repos/base-repo.ts): `server/repos/base-repo.ts`
- [Contact timeline](https://github.com/jahfeelautomation/openlevel/blob/master/server/repos/timeline-repo.ts): `server/repos/timeline-repo.ts`

### Other components

- **Operator**

## Connections

- Operator → Web application: uses (evidence: `src/App.tsx`)
- Web application → CRM and business screens: routes to (evidence: `src/App.tsx`)
- CRM and business screens → Typed API client: requests data (evidence: `src/features/tasks/TasksPage.tsx`)
- Operator → Mobile application: uses (evidence: `README.md`)
- Mobile application → Mobile API context: uses context (evidence: `openconnector/app/(tabs)/pipelines.tsx`)
- Mobile API context → Typed API client: uses API (evidence: `openconnector/app/ctx.tsx`)
- Typed API client → API server: calls API (evidence: `src/lib/api.ts`)
- API server → Authentication: applies (evidence: `server/index.ts`)
- API server → CRM and domain routes: mounts routes (evidence: `server/index.ts`)
- CRM and business screens → Pipeline settings: includes settings (evidence: `src/App.tsx`)
- Pipeline settings → Typed API client: requests data (evidence: `src/features/settings/PipelinesSettingsPage.tsx`)
- CRM and domain routes → Pipeline routes: includes
- Pipeline routes → Pipeline repository: calls (evidence: `server/routes/pipelines.ts`)
- Pipeline repository → Location-scoped repository: extends (evidence: `server/repos/pipelines-repo.ts`)
- CRM and domain routes → Public pages: mounts public pages
- CRM and domain routes → External integrations: mounts webhook
- External integrations → Domain repositories: updates records (evidence: `server/routes/webhooks-chatwoot.ts`)
- API server → Agent reply worker: enqueues replies (evidence: `server/index.ts`)
- Agent reply worker → Agent engine: generates reply (evidence: `server/jobs/agent-reply.ts`)
- Agent engine → Anthropic client: runs model (evidence: `server/lib/agent-engine.ts`)
- Agent engine → Contact timeline: reads history (evidence: `server/lib/agent-engine.ts`)
- Agent reply worker → Workflow dispatcher: dispatches events (evidence: `server/jobs/agent-reply.ts`)
- Workflow dispatcher → Workflow runner: starts runs (evidence: `server/jobs/workflow-dispatcher.ts`)
- Pipeline repository → Location-scoped repository: queries through (evidence: `server/repos/pipelines-repo.ts`)
- Location-scoped repository → Database interface: queries (evidence: `server/repos/base-repo.ts`)
- Database interface → Postgres database: implemented by (evidence: `server/db/database.ts`)
- Contact timeline → Location-scoped repository: extends (evidence: `server/repos/timeline-repo.ts`)
