# tomleelive/flowelement-ai-m_flow architecture

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

- Interactive diagram: https://gitdiagram.com/tomleelive/flowelement-ai-m_flow
- Repository: https://github.com/tomleelive/flowelement-ai-m_flow

## Overview

M-flow is a cognitive-memory and GraphRAG product: users ingest material, the system constructs structured memory, and search follows evidence paths to return episode bundles. The graph includes the documented management, procedural-memory, and integration surfaces. Some subsystem links are documented only at the product level; unsampled implementation details are not assumed.

Main entry points: [`m_flow/api/v1/memorize/memorize.py`](https://github.com/tomleelive/flowelement-ai-m_flow/blob/main/m_flow/api/v1/memorize/memorize.py) (Memory construction), [`m_flow/api/v1/ingest/routers/get_ingest_router.py`](https://github.com/tomleelive/flowelement-ai-m_flow/blob/main/m_flow/api/v1/ingest/routers/get_ingest_router.py) (REST API), [`m_flow/api/v1/ingest/ingest.py`](https://github.com/tomleelive/flowelement-ai-m_flow/blob/main/m_flow/api/v1/ingest/ingest.py) (Ingest orchestration), [`m_flow/api/v1/search/search.py`](https://github.com/tomleelive/flowelement-ai-m_flow/blob/main/m_flow/api/v1/search/search.py) (Search API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["User surfaces"]
  node_frontend["Web console<br/>[page.tsx]"]
  node_mcp["MCP server<br/>[server.py]"]
  node_mcpclient["M-flow client<br/>[m_flow_client.py]"]
  node_api["REST API"]
end

subgraph group_ingest["Ingestion and memory"]
  node_ingest["Ingest orchestration<br/>[ingest.py]"]
  node_storage["Input storage"]
  node_add["Raw data add<br/>[add.py]"]
  node_memorize["Memory construction<br/>[memorize.py]"]
  node_episode["Episode modeling<br/>[models.py]"]
  node_coreference["Coreference processing<br/>[session_manager.py]"]
  node_corefengine["Coreference engine<br/>[coreference.py]"]
  node_englishcoref["English coreference<br/>[coreference.py]"]
end

subgraph group_retrieve["Graph retrieval"]
  node_search["Search API<br/>[search.py]"]
  node_retrieval["Graph-routed retrieval"]
  node_querytime["Time parsing"]
end

subgraph group_platform["Platform services"]
  node_auth["Authentication"]
  node_graphstore[("Graph store adapters")]
  node_vectorstore[("Vector store adapters")]
  node_embed["Embedding engine"]
  node_llm["LLM providers<br/>[get_llm_client.py]"]
  node_relational[("Relational storage<br/>[config.py]")]
  node_cache[("Cache interface")]
  node_pipelines[("Pipeline tracking")]
end

node_user(("User"))
node_external{{"LLM service"}}

node_user -.->|"uses"| node_frontend
node_user -.->|"connects"| node_mcp
node_frontend -.->|"requests"| node_api
node_mcp -->|"uses"| node_mcpclient
node_mcpclient -.->|"calls"| node_api
node_api -->|"authenticates"| node_auth
node_api -->|"invokes"| node_ingest
node_ingest -.->|"stores inputs"| node_storage
node_ingest -->|"adds raw data"| node_add
node_ingest -->|"builds memory"| node_memorize
node_memorize -->|"constructs episodes"| node_episode
node_memorize -.->|"resolves references"| node_coreference
node_coreference -->|"uses"| node_corefengine
node_coreference -->|"uses"| node_englishcoref
node_user -->|"queries"| node_search
node_search -->|"retrieves"| node_retrieval
node_retrieval -->|"finds anchors"| node_vectorstore
node_retrieval -->|"propagates evidence"| node_graphstore
node_search -.->|"parses time"| node_querytime
node_memorize -.->|"writes memory"| node_graphstore
node_memorize -.->|"indexes memory"| node_vectorstore
node_vectorstore -->|"embeds text"| node_embed
node_embed -->|"requests vectors"| node_external
node_memorize -.->|"extracts knowledge"| node_llm
node_search -->|"composes answer"| node_llm
node_api -.->|"manages records"| node_relational
node_api -.->|"may cache"| node_cache
node_ingest -.->|"tracks runs"| node_pipelines

click node_frontend "https://github.com/tomleelive/flowelement-ai-m_flow/blob/main/m_flow-frontend/src/app/page.tsx"
click node_mcp "https://github.com/tomleelive/flowelement-ai-m_flow/blob/main/m_flow-mcp/src/server.py"
click node_mcpclient "https://github.com/tomleelive/flowelement-ai-m_flow/blob/main/m_flow-mcp/src/m_flow_client.py"
click node_api "https://github.com/tomleelive/flowelement-ai-m_flow/blob/main/m_flow/api/v1/ingest/routers/get_ingest_router.py"
click node_auth "https://github.com/tomleelive/flowelement-ai-m_flow/blob/main/m_flow/api/v1/ingest/routers/get_ingest_router.py"
click node_ingest "https://github.com/tomleelive/flowelement-ai-m_flow/blob/main/m_flow/api/v1/ingest/ingest.py"
click node_storage "https://github.com/tomleelive/flowelement-ai-m_flow/blob/main/m_flow/ingestion/pipeline_tasks/save_data_item_to_storage.py"
click node_add "https://github.com/tomleelive/flowelement-ai-m_flow/blob/main/m_flow/api/v1/add/add.py"
click node_memorize "https://github.com/tomleelive/flowelement-ai-m_flow/blob/main/m_flow/api/v1/memorize/memorize.py"
click node_episode "https://github.com/tomleelive/flowelement-ai-m_flow/blob/main/m_flow/memory/episodic/models.py"
click node_coreference "https://github.com/tomleelive/flowelement-ai-m_flow/blob/main/m_flow/preprocessing/coreference/session_manager.py"
click node_corefengine "https://github.com/tomleelive/flowelement-ai-m_flow/blob/main/coreference/coreference_module/coreference.py"
click node_englishcoref "https://github.com/tomleelive/flowelement-ai-m_flow/blob/main/coreference/english_coreference/coreference.py"
click node_search "https://github.com/tomleelive/flowelement-ai-m_flow/blob/main/m_flow/api/v1/search/search.py"
click node_retrieval "https://github.com/tomleelive/flowelement-ai-m_flow/blob/main/m_flow/retrieval/cypher_search_retriever.py"
click node_querytime "https://github.com/tomleelive/flowelement-ai-m_flow/blob/main/m_flow/retrieval/time/query_time_parser.py"
click node_graphstore "https://github.com/tomleelive/flowelement-ai-m_flow/blob/main/m_flow/adapters/graph/use_graph_adapter.py"
click node_vectorstore "https://github.com/tomleelive/flowelement-ai-m_flow/blob/main/m_flow/adapters/vector/create_vector_engine.py"
click node_embed "https://github.com/tomleelive/flowelement-ai-m_flow/blob/main/m_flow/adapters/vector/embeddings/LiteLLMEmbeddingEngine.py"
click node_llm "https://github.com/tomleelive/flowelement-ai-m_flow/blob/main/m_flow/llm/backends/litellm_instructor/llm/get_llm_client.py"
click node_relational "https://github.com/tomleelive/flowelement-ai-m_flow/blob/main/m_flow/adapters/relational/config.py"
click node_cache "https://github.com/tomleelive/flowelement-ai-m_flow/blob/main/m_flow/adapters/cache/cache_db_interface.py"
click node_pipelines "https://github.com/tomleelive/flowelement-ai-m_flow/blob/main/m_flow/pipeline/methods/get_active_pipeline_runs.py"

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_frontend,node_mcp,node_mcpclient,node_api,node_user toneBlue
class node_ingest,node_storage,node_add,node_memorize,node_episode,node_coreference,node_corefengine,node_englishcoref toneAmber
class node_search,node_retrieval,node_querytime toneMint
class node_auth,node_graphstore,node_vectorstore,node_embed,node_llm,node_relational,node_cache,node_pipelines toneRose
class node_external toneIndigo
```

## Components

### User surfaces

- [Web console](https://github.com/tomleelive/flowelement-ai-m_flow/blob/main/m_flow-frontend/src/app/page.tsx): `m_flow-frontend/src/app/page.tsx`
- [MCP server](https://github.com/tomleelive/flowelement-ai-m_flow/blob/main/m_flow-mcp/src/server.py): `m_flow-mcp/src/server.py`
- [M-flow client](https://github.com/tomleelive/flowelement-ai-m_flow/blob/main/m_flow-mcp/src/m_flow_client.py): `m_flow-mcp/src/m_flow_client.py`
- [REST API](https://github.com/tomleelive/flowelement-ai-m_flow/blob/main/m_flow/api/v1/ingest/routers/get_ingest_router.py): `m_flow/api/v1/ingest/routers/get_ingest_router.py`

### Ingestion and memory

- [Ingest orchestration](https://github.com/tomleelive/flowelement-ai-m_flow/blob/main/m_flow/api/v1/ingest/ingest.py): `m_flow/api/v1/ingest/ingest.py`
- [Input storage](https://github.com/tomleelive/flowelement-ai-m_flow/blob/main/m_flow/ingestion/pipeline_tasks/save_data_item_to_storage.py): `m_flow/ingestion/pipeline_tasks/save_data_item_to_storage.py`
- [Raw data add](https://github.com/tomleelive/flowelement-ai-m_flow/blob/main/m_flow/api/v1/add/add.py): `m_flow/api/v1/add/add.py`
- [Memory construction](https://github.com/tomleelive/flowelement-ai-m_flow/blob/main/m_flow/api/v1/memorize/memorize.py): `m_flow/api/v1/memorize/memorize.py`
- [Episode modeling](https://github.com/tomleelive/flowelement-ai-m_flow/blob/main/m_flow/memory/episodic/models.py): `m_flow/memory/episodic/models.py`
- [Coreference processing](https://github.com/tomleelive/flowelement-ai-m_flow/blob/main/m_flow/preprocessing/coreference/session_manager.py): `m_flow/preprocessing/coreference/session_manager.py`
- [Coreference engine](https://github.com/tomleelive/flowelement-ai-m_flow/blob/main/coreference/coreference_module/coreference.py): `coreference/coreference_module/coreference.py`
- [English coreference](https://github.com/tomleelive/flowelement-ai-m_flow/blob/main/coreference/english_coreference/coreference.py): `coreference/english_coreference/coreference.py`

### Graph retrieval

- [Search API](https://github.com/tomleelive/flowelement-ai-m_flow/blob/main/m_flow/api/v1/search/search.py): `m_flow/api/v1/search/search.py`
- [Graph-routed retrieval](https://github.com/tomleelive/flowelement-ai-m_flow/blob/main/m_flow/retrieval/cypher_search_retriever.py): `m_flow/retrieval/cypher_search_retriever.py`
- [Time parsing](https://github.com/tomleelive/flowelement-ai-m_flow/blob/main/m_flow/retrieval/time/query_time_parser.py): `m_flow/retrieval/time/query_time_parser.py`

### Platform services

- [Authentication](https://github.com/tomleelive/flowelement-ai-m_flow/blob/main/m_flow/api/v1/ingest/routers/get_ingest_router.py): `m_flow/api/v1/ingest/routers/get_ingest_router.py`
- [Graph store adapters](https://github.com/tomleelive/flowelement-ai-m_flow/blob/main/m_flow/adapters/graph/use_graph_adapter.py): `m_flow/adapters/graph/use_graph_adapter.py`
- [Vector store adapters](https://github.com/tomleelive/flowelement-ai-m_flow/blob/main/m_flow/adapters/vector/create_vector_engine.py): `m_flow/adapters/vector/create_vector_engine.py`
- [Embedding engine](https://github.com/tomleelive/flowelement-ai-m_flow/blob/main/m_flow/adapters/vector/embeddings/LiteLLMEmbeddingEngine.py): `m_flow/adapters/vector/embeddings/LiteLLMEmbeddingEngine.py`
- [LLM providers](https://github.com/tomleelive/flowelement-ai-m_flow/blob/main/m_flow/llm/backends/litellm_instructor/llm/get_llm_client.py): `m_flow/llm/backends/litellm_instructor/llm/get_llm_client.py`
- [Relational storage](https://github.com/tomleelive/flowelement-ai-m_flow/blob/main/m_flow/adapters/relational/config.py): `m_flow/adapters/relational/config.py`
- [Cache interface](https://github.com/tomleelive/flowelement-ai-m_flow/blob/main/m_flow/adapters/cache/cache_db_interface.py): `m_flow/adapters/cache/cache_db_interface.py`
- [Pipeline tracking](https://github.com/tomleelive/flowelement-ai-m_flow/blob/main/m_flow/pipeline/methods/get_active_pipeline_runs.py): `m_flow/pipeline/methods/get_active_pipeline_runs.py`

### Other components

- **User**
- **LLM service**

## Connections

- User → Web console: uses
- User → MCP server: connects
- Web console → REST API: requests
- MCP server → M-flow client: uses (evidence: `m_flow-mcp/src/server.py`)
- M-flow client → REST API: calls
- REST API → Authentication: authenticates (evidence: `m_flow/api/v1/ingest/routers/get_ingest_router.py`)
- REST API → Ingest orchestration: invokes (evidence: `m_flow/api/v1/ingest/routers/get_ingest_router.py`)
- Ingest orchestration → Input storage: stores inputs
- Ingest orchestration → Raw data add: adds raw data
- Ingest orchestration → Memory construction: builds memory
- Memory construction → Episode modeling: constructs episodes
- Memory construction → Coreference processing: resolves references
- Coreference processing → Coreference engine: uses (evidence: `m_flow/preprocessing/coreference/session_manager.py`)
- Coreference processing → English coreference: uses (evidence: `m_flow/preprocessing/coreference/session_manager.py`)
- User → Search API: queries
- Search API → Graph-routed retrieval: retrieves
- Graph-routed retrieval → Vector store adapters: finds anchors
- Graph-routed retrieval → Graph store adapters: propagates evidence
- Search API → Time parsing: parses time
- Memory construction → Graph store adapters: writes memory
- Memory construction → Vector store adapters: indexes memory
- Vector store adapters → Embedding engine: embeds text (evidence: `m_flow/adapters/vector/create_vector_engine.py`)
- Embedding engine → LLM service: requests vectors (evidence: `m_flow/adapters/vector/embeddings/LiteLLMEmbeddingEngine.py`)
- Memory construction → LLM providers: extracts knowledge
- Search API → LLM providers: composes answer
- REST API → Relational storage: manages records
- REST API → Cache interface: may cache
- Ingest orchestration → Pipeline tracking: tracks runs
