# devgoswami04/enterprise-ai-operating-system architecture

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

- Interactive diagram: https://gitdiagram.com/devgoswami04/enterprise-ai-operating-system
- Repository: https://github.com/devgoswami04/enterprise-ai-operating-system

## Overview

Enterprise AI Operating System is a multi-tenant AI workspace for cited knowledge retrieval, agent-assisted chat, durable organizational memory, and approval-gated workflows. A typical chat request is authenticated and assessed, retrieves workspace evidence, generates and evaluates a response, then records run and evaluation data. Document ingestion, tool governance, security, and observability are additional product capabilities. A persistence facade selects in-memory mock storage or PostgreSQL/pgvector; optional Redis/BullMQ moves workflow execution to a worker. Evidence is limited to the README, source index, and excerpts provided; unsampled implementation details are not assumed.

Main entry points: [`src/lib/data/store.ts`](https://github.com/devgoswami04/enterprise-ai-operating-system/blob/main/src/lib/data/store.ts) (Persistence facade), [`src/lib/ai/orchestrator.ts`](https://github.com/devgoswami04/enterprise-ai-operating-system/blob/main/src/lib/ai/orchestrator.ts) (Agent orchestrator), [`src/lib/workflows/engine.ts`](https://github.com/devgoswami04/enterprise-ai-operating-system/blob/main/src/lib/workflows/engine.ts) (Workflow engine), [`src/app/api/chat/route.ts`](https://github.com/devgoswami04/enterprise-ai-operating-system/blob/main/src/app/api/chat/route.ts) (Chat endpoint)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["Workspace and API"]
  node_workspace["Workspace UI"]
  node_chat_api["Chat endpoint<br/>[route.ts]"]
  node_docs_api["Documents endpoint<br/>[route.ts]"]
  node_search_api["Search endpoint<br/>[route.ts]"]
  node_memory_api["Memory endpoint<br/>[route.ts]"]
  node_workflow_api["Workflow endpoint<br/>[route.ts]"]
  node_events_api["Run event stream<br/>[route.ts]"]
end

subgraph group_intelligence["AI and Knowledge"]
  node_orchestrator["Agent orchestrator<br/>[orchestrator.ts]"]
  node_agent_state["Agent state machine<br/>[state-machine.ts]"]
  node_providers["Model providers<br/>[providers.ts]"]
  node_retrieval["Knowledge retrieval<br/>[service.ts]"]
  node_documents["Document service<br/>[service.ts]"]
  node_chunking["Text chunking<br/>[chunking.ts]"]
  node_memory["Durable memory<br/>[service.ts]"]
end

subgraph group_operations["Workflow Operations"]
  node_workflow_service["Workflow service<br/>[service.ts]"]
  node_workflow_engine["Workflow engine<br/>[engine.ts]"]
  node_queue["Workflow queue<br/>[queue.ts]"]
  node_worker["Background worker<br/>[worker.ts]"]
  node_tool_service["Tool execution<br/>[service.ts]"]
end

subgraph group_governance["Security and Observability"]
  node_auth["Session auth<br/>[auth.ts]"]
  node_security["Security controls<br/>[controls.ts]"]
  node_rbac["Role access<br/>[rbac.ts]"]
  node_metrics["Metrics<br/>[metrics.ts]"]
end

subgraph group_persistence["Persistence"]
  node_store["Persistence facade<br/>[store.ts]"]
  node_memory_store[("Mock store<br/>[memory-store.ts]")]
  node_postgres[("Postgres repositories")]
end

node_user(("Team user"))

node_user -.->|"uses"| node_workspace
node_workspace -.->|"requests chat"| node_chat_api
node_chat_api -->|"authenticates"| node_auth
node_chat_api -->|"orchestrates"| node_orchestrator
node_chat_api -->|"rate limits"| node_security
node_orchestrator -->|"runs graph"| node_agent_state
node_orchestrator -->|"generates with"| node_providers
node_orchestrator -->|"assesses input"| node_security
node_orchestrator -->|"records and searches"| node_store
node_orchestrator -.->|"retrieves evidence"| node_retrieval
node_docs_api -->|"authenticates"| node_auth
node_docs_api -->|"checks role"| node_rbac
node_docs_api -->|"ingests documents"| node_documents
node_documents -->|"persists documents"| node_store
node_documents -.->|"uses chunking"| node_chunking
node_search_api -->|"searches"| node_retrieval
node_retrieval -->|"searches knowledge"| node_store
node_memory_api -->|"recalls or writes"| node_memory
node_memory -->|"reads and writes"| node_store
node_workflow_api -->|"starts runs"| node_workflow_service
node_workflow_service -->|"enqueues optionally"| node_queue
node_events_api -->|"streams execution"| node_workflow_engine
node_workflow_engine -->|"persists run state"| node_store
node_workflow_engine -->|"writes outcomes"| node_memory
node_worker -->|"processes jobs"| node_queue
node_worker -->|"executes runs"| node_workflow_engine
node_workflow_engine -.->|"creates gated calls"| node_tool_service
node_tool_service -->|"assesses payload"| node_security
node_tool_service -->|"resolves tool call"| node_store
node_store -->|"uses in mock mode"| node_memory_store
node_store -->|"routes in production"| node_postgres
node_workspace -.->|"views observability"| node_metrics

click node_workspace "https://github.com/devgoswami04/enterprise-ai-operating-system/tree/main/src/app/(workspace)/app"
click node_chat_api "https://github.com/devgoswami04/enterprise-ai-operating-system/blob/main/src/app/api/chat/route.ts"
click node_docs_api "https://github.com/devgoswami04/enterprise-ai-operating-system/blob/main/src/app/api/documents/route.ts"
click node_search_api "https://github.com/devgoswami04/enterprise-ai-operating-system/blob/main/src/app/api/search/route.ts"
click node_memory_api "https://github.com/devgoswami04/enterprise-ai-operating-system/blob/main/src/app/api/memory/route.ts"
click node_workflow_api "https://github.com/devgoswami04/enterprise-ai-operating-system/blob/main/src/app/api/workflows/%5Bid%5D/runs/route.ts"
click node_events_api "https://github.com/devgoswami04/enterprise-ai-operating-system/blob/main/src/app/api/runs/%5Bid%5D/events/route.ts"
click node_auth "https://github.com/devgoswami04/enterprise-ai-operating-system/blob/main/src/lib/auth.ts"
click node_orchestrator "https://github.com/devgoswami04/enterprise-ai-operating-system/blob/main/src/lib/ai/orchestrator.ts"
click node_agent_state "https://github.com/devgoswami04/enterprise-ai-operating-system/blob/main/src/modules/agents/state-machine.ts"
click node_providers "https://github.com/devgoswami04/enterprise-ai-operating-system/blob/main/src/lib/ai/providers.ts"
click node_retrieval "https://github.com/devgoswami04/enterprise-ai-operating-system/blob/main/src/modules/retrieval/service.ts"
click node_documents "https://github.com/devgoswami04/enterprise-ai-operating-system/blob/main/src/modules/documents/service.ts"
click node_chunking "https://github.com/devgoswami04/enterprise-ai-operating-system/blob/main/src/lib/ai/chunking.ts"
click node_memory "https://github.com/devgoswami04/enterprise-ai-operating-system/blob/main/src/modules/memory/service.ts"
click node_workflow_service "https://github.com/devgoswami04/enterprise-ai-operating-system/blob/main/src/modules/workflows/service.ts"
click node_workflow_engine "https://github.com/devgoswami04/enterprise-ai-operating-system/blob/main/src/lib/workflows/engine.ts"
click node_queue "https://github.com/devgoswami04/enterprise-ai-operating-system/blob/main/src/modules/workflows/queue.ts"
click node_worker "https://github.com/devgoswami04/enterprise-ai-operating-system/blob/main/src/worker.ts"
click node_tool_service "https://github.com/devgoswami04/enterprise-ai-operating-system/blob/main/src/modules/tools/service.ts"
click node_security "https://github.com/devgoswami04/enterprise-ai-operating-system/blob/main/src/lib/security/controls.ts"
click node_rbac "https://github.com/devgoswami04/enterprise-ai-operating-system/blob/main/src/lib/security/rbac.ts"
click node_metrics "https://github.com/devgoswami04/enterprise-ai-operating-system/blob/main/src/modules/observability/metrics.ts"
click node_store "https://github.com/devgoswami04/enterprise-ai-operating-system/blob/main/src/lib/data/store.ts"
click node_memory_store "https://github.com/devgoswami04/enterprise-ai-operating-system/blob/main/src/lib/data/memory-store.ts"
click node_postgres "https://github.com/devgoswami04/enterprise-ai-operating-system/tree/main/src/lib/db/repositories"

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_workspace,node_chat_api,node_docs_api,node_search_api,node_memory_api,node_workflow_api,node_events_api,node_user toneBlue
class node_orchestrator,node_agent_state,node_providers,node_retrieval,node_documents,node_chunking,node_memory toneAmber
class node_workflow_service,node_workflow_engine,node_queue,node_worker,node_tool_service toneMint
class node_auth,node_security,node_rbac,node_metrics toneRose
class node_store,node_memory_store,node_postgres toneIndigo
```

## Components

### Workspace and API

- [Workspace UI](https://github.com/devgoswami04/enterprise-ai-operating-system/tree/main/src/app/(workspace)/app): `src/app/(workspace)/app`
- [Chat endpoint](https://github.com/devgoswami04/enterprise-ai-operating-system/blob/main/src/app/api/chat/route.ts): `src/app/api/chat/route.ts`
- [Documents endpoint](https://github.com/devgoswami04/enterprise-ai-operating-system/blob/main/src/app/api/documents/route.ts): `src/app/api/documents/route.ts`
- [Search endpoint](https://github.com/devgoswami04/enterprise-ai-operating-system/blob/main/src/app/api/search/route.ts): `src/app/api/search/route.ts`
- [Memory endpoint](https://github.com/devgoswami04/enterprise-ai-operating-system/blob/main/src/app/api/memory/route.ts): `src/app/api/memory/route.ts`
- [Workflow endpoint](https://github.com/devgoswami04/enterprise-ai-operating-system/blob/main/src/app/api/workflows/%5Bid%5D/runs/route.ts): `src/app/api/workflows/[id]/runs/route.ts`
- [Run event stream](https://github.com/devgoswami04/enterprise-ai-operating-system/blob/main/src/app/api/runs/%5Bid%5D/events/route.ts): `src/app/api/runs/[id]/events/route.ts`

### AI and Knowledge

- [Agent orchestrator](https://github.com/devgoswami04/enterprise-ai-operating-system/blob/main/src/lib/ai/orchestrator.ts): `src/lib/ai/orchestrator.ts`
- [Agent state machine](https://github.com/devgoswami04/enterprise-ai-operating-system/blob/main/src/modules/agents/state-machine.ts): `src/modules/agents/state-machine.ts`
- [Model providers](https://github.com/devgoswami04/enterprise-ai-operating-system/blob/main/src/lib/ai/providers.ts): `src/lib/ai/providers.ts`
- [Knowledge retrieval](https://github.com/devgoswami04/enterprise-ai-operating-system/blob/main/src/modules/retrieval/service.ts): `src/modules/retrieval/service.ts`
- [Document service](https://github.com/devgoswami04/enterprise-ai-operating-system/blob/main/src/modules/documents/service.ts): `src/modules/documents/service.ts`
- [Text chunking](https://github.com/devgoswami04/enterprise-ai-operating-system/blob/main/src/lib/ai/chunking.ts): `src/lib/ai/chunking.ts`
- [Durable memory](https://github.com/devgoswami04/enterprise-ai-operating-system/blob/main/src/modules/memory/service.ts): `src/modules/memory/service.ts`

### Workflow Operations

- [Workflow service](https://github.com/devgoswami04/enterprise-ai-operating-system/blob/main/src/modules/workflows/service.ts): `src/modules/workflows/service.ts`
- [Workflow engine](https://github.com/devgoswami04/enterprise-ai-operating-system/blob/main/src/lib/workflows/engine.ts): `src/lib/workflows/engine.ts`
- [Workflow queue](https://github.com/devgoswami04/enterprise-ai-operating-system/blob/main/src/modules/workflows/queue.ts): `src/modules/workflows/queue.ts`
- [Background worker](https://github.com/devgoswami04/enterprise-ai-operating-system/blob/main/src/worker.ts): `src/worker.ts`
- [Tool execution](https://github.com/devgoswami04/enterprise-ai-operating-system/blob/main/src/modules/tools/service.ts): `src/modules/tools/service.ts`

### Security and Observability

- [Session auth](https://github.com/devgoswami04/enterprise-ai-operating-system/blob/main/src/lib/auth.ts): `src/lib/auth.ts`
- [Security controls](https://github.com/devgoswami04/enterprise-ai-operating-system/blob/main/src/lib/security/controls.ts): `src/lib/security/controls.ts`
- [Role access](https://github.com/devgoswami04/enterprise-ai-operating-system/blob/main/src/lib/security/rbac.ts): `src/lib/security/rbac.ts`
- [Metrics](https://github.com/devgoswami04/enterprise-ai-operating-system/blob/main/src/modules/observability/metrics.ts): `src/modules/observability/metrics.ts`

### Persistence

- [Persistence facade](https://github.com/devgoswami04/enterprise-ai-operating-system/blob/main/src/lib/data/store.ts): `src/lib/data/store.ts`
- [Mock store](https://github.com/devgoswami04/enterprise-ai-operating-system/blob/main/src/lib/data/memory-store.ts): `src/lib/data/memory-store.ts`
- [Postgres repositories](https://github.com/devgoswami04/enterprise-ai-operating-system/tree/main/src/lib/db/repositories): `src/lib/db/repositories`

### Other components

- **Team user**

## Connections

- Team user → Workspace UI: uses (evidence: `README.md`)
- Workspace UI → Chat endpoint: requests chat (evidence: `README.md`)
- Chat endpoint → Session auth: authenticates (evidence: `src/app/api/chat/route.ts`)
- Chat endpoint → Agent orchestrator: orchestrates (evidence: `src/app/api/chat/route.ts`)
- Chat endpoint → Security controls: rate limits (evidence: `src/app/api/chat/route.ts`)
- Agent orchestrator → Agent state machine: runs graph (evidence: `src/lib/ai/orchestrator.ts`)
- Agent orchestrator → Model providers: generates with (evidence: `src/lib/ai/orchestrator.ts`)
- Agent orchestrator → Security controls: assesses input (evidence: `src/lib/ai/orchestrator.ts`)
- Agent orchestrator → Persistence facade: records and searches (evidence: `src/lib/ai/orchestrator.ts`)
- Agent orchestrator → Knowledge retrieval: retrieves evidence
- Documents endpoint → Session auth: authenticates (evidence: `src/app/api/documents/route.ts`)
- Documents endpoint → Role access: checks role (evidence: `src/app/api/documents/route.ts`)
- Documents endpoint → Document service: ingests documents (evidence: `src/app/api/documents/route.ts`)
- Document service → Persistence facade: persists documents (evidence: `src/modules/documents/service.ts`)
- Document service → Text chunking: uses chunking
- Search endpoint → Knowledge retrieval: searches (evidence: `src/app/api/search/route.ts`)
- Knowledge retrieval → Persistence facade: searches knowledge (evidence: `src/modules/retrieval/service.ts`)
- Memory endpoint → Durable memory: recalls or writes (evidence: `src/app/api/memory/route.ts`)
- Durable memory → Persistence facade: reads and writes (evidence: `src/modules/memory/service.ts`)
- Workflow endpoint → Workflow service: starts runs (evidence: `src/app/api/workflows/[id]/runs/route.ts`)
- Workflow service → Workflow queue: enqueues optionally (evidence: `src/modules/workflows/service.ts`)
- Run event stream → Workflow engine: streams execution (evidence: `src/app/api/runs/[id]/events/route.ts`)
- Workflow engine → Persistence facade: persists run state (evidence: `src/lib/workflows/engine.ts`)
- Workflow engine → Durable memory: writes outcomes (evidence: `src/lib/workflows/engine.ts`)
- Background worker → Workflow queue: processes jobs (evidence: `src/worker.ts`)
- Background worker → Workflow engine: executes runs (evidence: `src/worker.ts`)
- Workflow engine → Tool execution: creates gated calls
- Tool execution → Security controls: assesses payload (evidence: `src/modules/tools/service.ts`)
- Tool execution → Persistence facade: resolves tool call (evidence: `src/modules/tools/service.ts`)
- Persistence facade → Mock store: uses in mock mode (evidence: `src/lib/data/store.ts`)
- Persistence facade → Postgres repositories: routes in production (evidence: `src/lib/data/store.ts`)
- Workspace UI → Metrics: views observability (evidence: `README.md`)
