# modelengine-group/nexent architecture

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

- Interactive diagram: https://gitdiagram.com/modelengine-group/nexent
- Repository: https://github.com/modelengine-group/nexent

## Overview

#### Purpose and entry points
Nexent is a self-hosted, multi-tenant zero-code platform for creating, running, sharing, and evaluating AI agents. It combines an operator UI, Python backend APIs, reusable SDK runtime, and separately deployable processing/runtime/MCP services. Main application composition starts in `backend/apps/app_factory.py`; service-facing entry modules include `backend/runtime_service.py`, `backend/mcp_service.py`, and `backend/data_process_service.py`. The web UI is a Next.js application rooted at `frontend/app/[locale]/layout.tsx` and `frontend/app/[locale]/page.tsx`.

#### Web control plane
The frontend provides localized operator workflows for chat, agent configuration/versioning, knowledge bases, models, MCP services, skills, memory, evaluation, and tenant administration. Pages call a typed service layer rather than backend internals. Key interaction surfaces: `frontend/app/[locale]/newchat/page.tsx`, `frontend/app/[locale]/agents/page.tsx`, and `frontend/app/[locale]/knowledges/page.tsx`; API boundary clients include `frontend/services/api.ts`, `frontend/services/agentConfigService.ts`, and `frontend/services/conversationService.ts`.

#### Backend application and domain layer
`backend/apps/` is the HTTP/application boundary, with domain-oriented app modules delegating to `backend/services/`. Central workflows cover agent lifecycle, streamed conversations, agent repositories, evaluation, scheduling, models, MCP, files, and tenant administration. Representative paths are `backend/apps/agent_app.py`, `backend/services/agent_service.py`, and `backend/services/conversation_management_service.py`. Middleware centralizes error translation in `backend/middleware/exception_handler.py`.

#### Agent execution runtime
Agent runs are coordinated by backend managers and the SDK’s core-agent stack. The runtime assembles prompts, available skills/tools, memory, knowledge, history, external A2A agents, and guardrails into a bounded context before model/tool execution. Important execution paths: `backend/agents/agent_run_manager.py`, `sdk/nexent/core/agents/nexent_agent.py`, and `sdk/nexent/core/agents/context/manager.py`. Natural-language generation paths for agents and skills are `backend/services/nl2agent_service.py` and `backend/services/nl2skill_service.py`.

#### Extensibility and external integration boundary
Tools can be native SDK tools, LangChain tools, locally managed MCP servers, remote MCP services, or A2A collaborators. MCP management includes container lifecycle concerns; A2A supports client/server adapters and discovery. Core paths: `backend/services/mcp_management_service.py`, `backend/services/a2a_server_service.py`, and `sdk/nexent/core/agents/a2a_agent_proxy.py`. Model-provider adapters isolate vendor-specific integrations in `backend/services/providers/base.py`, with implementations such as `backend/services/providers/dashscope_provider.py`.

#### Knowledge, memory, and asynchronous processing
File/knowledge ingestion is separated into a data-process service, using Ray-oriented workers, document chunking/extraction, storage records, embeddings, and vector retrieval. Paths: `backend/data_process/worker.py`, `backend/data_process/tasks.py`, and `sdk/nexent/data_process/core.py`. Persistent memory has record, retrieval, long-term, and “dreaming”/summarization stages: `backend/services/memory_record_service.py`, `backend/services/memory_retrieval_service.py`, and `sdk/nexent/memory/dreaming/service.py`.

#### Persistence, infrastructure, and operations
PostgreSQL/Supabase stores identity, RBAC, tenancy, agents, conversations, assets, configurations, and evaluation data via `backend/database/client.py` and domain repositories such as `backend/database/agent_db.py`. Deployment provisions PostgreSQL, Redis, MinIO, Elasticsearch, Supabase Auth/Kong, runtime, MCP, web, and data-process components through `deploy/docker/compose/docker-compose.yml` or Helm chart `deploy/k8s/helm/nexent/Chart.yaml`. Observability supports OpenTelemetry collector configurations and Grafana/Tempo, with optional Langfuse, LangSmith, Phoenix, or Zipkin exporters under `deploy/docker/assets/monitoring/`.

Main entry points: [`sdk/nexent/core/agents/nexent_agent.py`](https://github.com/modelengine-group/nexent/blob/develop/sdk/nexent/core/agents/nexent_agent.py) (Core agent), [`backend/apps/app_factory.py`](https://github.com/modelengine-group/nexent/blob/develop/backend/apps/app_factory.py) (Application composition), [`backend/database/client.py`](https://github.com/modelengine-group/nexent/blob/develop/backend/database/client.py) (PostgreSQL / Supabase data), [`deploy/docker/compose/docker-compose.yml`](https://github.com/modelengine-group/nexent/blob/develop/deploy/docker/compose/docker-compose.yml) (Deployment stack)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web control plane"]
  node_ui["Localized operator UI<br/>Next.js<br/>[layout.tsx]"]
  node_web_pages["Chat, agent, knowledge pages<br/>Next.js pages<br/>[page.tsx]"]
  node_web_api["Typed API clients<br/>frontend service layer<br/>[api.ts]"]
end

subgraph group_backend["Backend APIs"]
  node_app_factory["Application composition<br/>Python app factory<br/>[app_factory.py]"]
  node_agent_api["Agent application API<br/>HTTP app module<br/>[agent_app.py]"]
  node_exception_handler["Exception translation<br/>middleware"]
  node_agent_service["Agent lifecycle service<br/>domain service<br/>[agent_service.py]"]
  node_conversation_service["Conversation service<br/>domain service"]
end

subgraph group_runtime["Agent runtime"]
  node_agent_run_manager["Agent run coordinator<br/>execution manager"]
  node_core_agent["Core agent<br/>SDK runtime<br/>[nexent_agent.py]"]
  node_context_manager["Context assembly<br/>SDK context layer<br/>[manager.py]"]
  node_provider_adapter["Model provider adapters<br/>provider abstraction<br/>[base.py]"]
  node_a2a_proxy["A2A collaborators<br/>SDK agent proxy<br/>[a2a_agent_proxy.py]"]
end

subgraph group_processing["Knowledge and memory"]
  node_data_process_service["Data-process service<br/>service entry point"]
  node_process_workers["Ingestion workers and tasks<br/>Ray processing<br/>[worker.py]"]
  node_data_core["Document processing core<br/>SDK pipeline<br/>[core.py]"]
  node_memory["Long-term memory dreaming<br/>memory service<br/>[service.py]"]
end

subgraph group_platform["Platform services"]
  node_mcp_management["MCP management<br/>integration service"]
  node_database[("PostgreSQL / Supabase data<br/>persistence<br/>[client.py]")]
  node_deployment{{"Deployment stack<br/>Docker Compose<br/>[docker-compose.yml]"}}
end

node_ui -->|"renders"| node_web_pages
node_web_pages -->|"uses"| node_web_api
node_web_api -->|"HTTP API"| node_app_factory
node_app_factory -->|"mounts"| node_agent_api
node_app_factory -->|"applies"| node_exception_handler
node_agent_api -->|"delegates"| node_agent_service
node_agent_api -->|"delegates"| node_conversation_service
node_agent_service -->|"starts runs"| node_agent_run_manager
node_conversation_service -->|"streams runs"| node_agent_run_manager
node_agent_service -->|"stores agents"| node_database
node_conversation_service -->|"stores conversations"| node_database
node_agent_run_manager -->|"coordinates"| node_core_agent
node_core_agent -->|"builds context"| node_context_manager
node_core_agent -->|"invokes models"| node_provider_adapter
node_core_agent -->|"uses MCP tools"| node_mcp_management
node_core_agent -->|"delegates to agents"| node_a2a_proxy
node_core_agent -->|"reads and records memory"| node_memory
node_context_manager -->|"retrieves knowledge"| node_data_core
node_data_process_service -->|"dispatches ingestion"| node_process_workers
node_process_workers -->|"processes documents"| node_data_core
node_process_workers -->|"writes records"| node_database
node_deployment -.->|"deploys backend"| node_app_factory
node_deployment -.->|"deploys processor"| node_data_process_service
node_deployment -.->|"provisions"| node_database

click node_ui "https://github.com/modelengine-group/nexent/blob/develop/frontend/app/%5Blocale%5D/layout.tsx"
click node_web_pages "https://github.com/modelengine-group/nexent/blob/develop/frontend/app/%5Blocale%5D/newchat/page.tsx"
click node_web_api "https://github.com/modelengine-group/nexent/blob/develop/frontend/services/api.ts"
click node_app_factory "https://github.com/modelengine-group/nexent/blob/develop/backend/apps/app_factory.py"
click node_agent_api "https://github.com/modelengine-group/nexent/blob/develop/backend/apps/agent_app.py"
click node_exception_handler "https://github.com/modelengine-group/nexent/blob/develop/backend/middleware/exception_handler.py"
click node_agent_service "https://github.com/modelengine-group/nexent/blob/develop/backend/services/agent_service.py"
click node_conversation_service "https://github.com/modelengine-group/nexent/blob/develop/backend/services/conversation_management_service.py"
click node_agent_run_manager "https://github.com/modelengine-group/nexent/blob/develop/backend/agents/agent_run_manager.py"
click node_core_agent "https://github.com/modelengine-group/nexent/blob/develop/sdk/nexent/core/agents/nexent_agent.py"
click node_context_manager "https://github.com/modelengine-group/nexent/blob/develop/sdk/nexent/core/agents/context/manager.py"
click node_provider_adapter "https://github.com/modelengine-group/nexent/blob/develop/backend/services/providers/base.py"
click node_mcp_management "https://github.com/modelengine-group/nexent/blob/develop/backend/services/mcp_management_service.py"
click node_a2a_proxy "https://github.com/modelengine-group/nexent/blob/develop/sdk/nexent/core/agents/a2a_agent_proxy.py"
click node_data_process_service "https://github.com/modelengine-group/nexent/blob/develop/backend/data_process_service.py"
click node_process_workers "https://github.com/modelengine-group/nexent/blob/develop/backend/data_process/worker.py"
click node_data_core "https://github.com/modelengine-group/nexent/blob/develop/sdk/nexent/data_process/core.py"
click node_memory "https://github.com/modelengine-group/nexent/blob/develop/sdk/nexent/memory/dreaming/service.py"
click node_database "https://github.com/modelengine-group/nexent/blob/develop/backend/database/client.py"
click node_deployment "https://github.com/modelengine-group/nexent/blob/develop/deploy/docker/compose/docker-compose.yml"

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_ui,node_web_pages,node_web_api toneBlue
class node_app_factory,node_agent_api,node_exception_handler,node_agent_service,node_conversation_service toneAmber
class node_agent_run_manager,node_core_agent,node_context_manager,node_provider_adapter,node_a2a_proxy toneMint
class node_data_process_service,node_process_workers,node_data_core,node_memory toneRose
class node_mcp_management,node_database,node_deployment toneIndigo
```

## Components

### Web control plane

- [Localized operator UI](https://github.com/modelengine-group/nexent/blob/develop/frontend/app/%5Blocale%5D/layout.tsx): Next.js · Chat, agents, knowledge, evaluation, and tenant workflows. · `frontend/app/[locale]/layout.tsx`
- [Chat, agent, knowledge pages](https://github.com/modelengine-group/nexent/blob/develop/frontend/app/%5Blocale%5D/newchat/page.tsx): Next.js pages · `frontend/app/[locale]/newchat/page.tsx`
- [Typed API clients](https://github.com/modelengine-group/nexent/blob/develop/frontend/services/api.ts): frontend service layer · `frontend/services/api.ts`

### Backend APIs

- [Application composition](https://github.com/modelengine-group/nexent/blob/develop/backend/apps/app_factory.py): Python app factory · `backend/apps/app_factory.py`
- [Agent application API](https://github.com/modelengine-group/nexent/blob/develop/backend/apps/agent_app.py): HTTP app module · `backend/apps/agent_app.py`
- [Exception translation](https://github.com/modelengine-group/nexent/blob/develop/backend/middleware/exception_handler.py): middleware · `backend/middleware/exception_handler.py`
- [Agent lifecycle service](https://github.com/modelengine-group/nexent/blob/develop/backend/services/agent_service.py): domain service · `backend/services/agent_service.py`
- [Conversation service](https://github.com/modelengine-group/nexent/blob/develop/backend/services/conversation_management_service.py): domain service · Coordinates streamed conversations. · `backend/services/conversation_management_service.py`

### Agent runtime

- [Agent run coordinator](https://github.com/modelengine-group/nexent/blob/develop/backend/agents/agent_run_manager.py): execution manager · `backend/agents/agent_run_manager.py`
- [Core agent](https://github.com/modelengine-group/nexent/blob/develop/sdk/nexent/core/agents/nexent_agent.py): SDK runtime · Executes bounded agent runs with model and tools. · `sdk/nexent/core/agents/nexent_agent.py`
- [Context assembly](https://github.com/modelengine-group/nexent/blob/develop/sdk/nexent/core/agents/context/manager.py): SDK context layer · Combines prompts, history, skills, memory, knowledge, and guardrails. · `sdk/nexent/core/agents/context/manager.py`
- [Model provider adapters](https://github.com/modelengine-group/nexent/blob/develop/backend/services/providers/base.py): provider abstraction · `backend/services/providers/base.py`
- [A2A collaborators](https://github.com/modelengine-group/nexent/blob/develop/sdk/nexent/core/agents/a2a_agent_proxy.py): SDK agent proxy · Connects discovered external agents. · `sdk/nexent/core/agents/a2a_agent_proxy.py`

### Knowledge and memory

- [Data-process service](https://github.com/modelengine-group/nexent/blob/develop/backend/data_process_service.py): service entry point · `backend/data_process_service.py`
- [Ingestion workers and tasks](https://github.com/modelengine-group/nexent/blob/develop/backend/data_process/worker.py): Ray processing · Extracts, chunks, embeds, and records documents. · `backend/data_process/worker.py`
- [Document processing core](https://github.com/modelengine-group/nexent/blob/develop/sdk/nexent/data_process/core.py): SDK pipeline · `sdk/nexent/data_process/core.py`
- [Long-term memory dreaming](https://github.com/modelengine-group/nexent/blob/develop/sdk/nexent/memory/dreaming/service.py): memory service · Summarizes and consolidates persistent memory. · `sdk/nexent/memory/dreaming/service.py`

### Platform services

- [MCP management](https://github.com/modelengine-group/nexent/blob/develop/backend/services/mcp_management_service.py): integration service · Manages local containers and remote MCP services. · `backend/services/mcp_management_service.py`
- [PostgreSQL / Supabase data](https://github.com/modelengine-group/nexent/blob/develop/backend/database/client.py): persistence · Identity, tenancy, agents, conversations, assets, and evaluation data. · `backend/database/client.py`
- [Deployment stack](https://github.com/modelengine-group/nexent/blob/develop/deploy/docker/compose/docker-compose.yml): Docker Compose · Provisions application services, data stores, and observability. · `deploy/docker/compose/docker-compose.yml`

## Connections

- Localized operator UI → Chat, agent, knowledge pages: renders
- Chat, agent, knowledge pages → Typed API clients: uses
- Typed API clients → Application composition: HTTP API
- Application composition → Agent application API: mounts
- Application composition → Exception translation: applies
- Agent application API → Agent lifecycle service: delegates
- Agent application API → Conversation service: delegates
- Agent lifecycle service → Agent run coordinator: starts runs
- Conversation service → Agent run coordinator: streams runs
- Agent lifecycle service → PostgreSQL / Supabase data: stores agents
- Conversation service → PostgreSQL / Supabase data: stores conversations
- Agent run coordinator → Core agent: coordinates
- Core agent → Context assembly: builds context
- Core agent → Model provider adapters: invokes models
- Core agent → MCP management: uses MCP tools
- Core agent → A2A collaborators: delegates to agents
- Core agent → Long-term memory dreaming: reads and records memory
- Context assembly → Document processing core: retrieves knowledge
- Data-process service → Ingestion workers and tasks: dispatches ingestion
- Ingestion workers and tasks → Document processing core: processes documents
- Ingestion workers and tasks → PostgreSQL / Supabase data: writes records
- Deployment stack → Application composition: deploys backend
- Deployment stack → Data-process service: deploys processor
- Deployment stack → PostgreSQL / Supabase data: provisions
