# huhuluwa/forgemind architecture

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

- Interactive diagram: https://gitdiagram.com/huhuluwa/forgemind
- Repository: https://github.com/huhuluwa/forgemind

## Overview

ForgeMind V4 is a local AI assistant built on MiniMind, with a chat/search interface, OpenAI-compatible API, expert knowledge, code-agent tools, and file export. The user-facing path is chat client → deployed server → agent/model and optional search or tools → response or exported artifact. The repository also contains a separate model-training and evaluation stack. Runtime links below follow README statements and SOURCE INDEX references; where implementations were not excerpted, those references establish module relationships but not internal behavior.

Main entry points: [`source/scripts/serve_forgemind_chat_web.py`](https://github.com/huhuluwa/forgemind/blob/main/source/scripts/serve_forgemind_chat_web.py) (Chat and API server), [`minimind/model/model_minimind.py`](https://github.com/huhuluwa/forgemind/blob/main/minimind/model/model_minimind.py) (MiniMind model), [`minimind/trainer/train_agent.py`](https://github.com/huhuluwa/forgemind/blob/main/minimind/trainer/train_agent.py) (Training workflows), [`minimind/eval_llm.py`](https://github.com/huhuluwa/forgemind/blob/main/minimind/eval_llm.py) (Model evaluation)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_product["Chat product"]
  node_web["Chat interface"]
  node_desktop["Desktop client<br/>[Program.cs]"]
  node_server["Chat and API server"]
  node_modelapi["OpenAI model API"]
  node_modelservice["Model API service"]
end

subgraph group_runtime["Assistant runtime"]
  node_agent["Conversation agent<br/>[openai_agent.py]"]
  node_prompts["Identity and prompts<br/>[prompts.py]"]
  node_search["Web search<br/>[search.py]"]
  node_expert[("Expert knowledge base<br/>[expert_kb.py]")]
  node_market["Market information<br/>[market.py]"]
  node_tools["Agent tools<br/>[tools.py]"]
  node_code["Code workspace tools<br/>[code_tools.py]"]
  node_artifacts["File exports<br/>[artifacts.py]"]
end

subgraph group_training["Model training"]
  node_training["Training workflows<br/>[train_agent.py]"]
  node_rollout["Generation rollouts<br/>[rollout_engine.py]"]
  node_trainerutils["Training utilities<br/>[trainer_utils.py]"]
  node_evaluation["Model evaluation<br/>[eval_llm.py]"]
end

subgraph group_model["Model and data"]
  node_dataset["Language datasets<br/>[lm_dataset.py]"]
  node_minimind["MiniMind model<br/>[model_minimind.py]"]
  node_profiles["Model profiles<br/>[model_profiles.py]"]
  node_lora["LoRA adapters<br/>[lora_adapter.py]"]
end

node_user(("User"))
node_internet(("Search providers"))

node_user -->|"uses"| node_web
node_user -->|"launches"| node_desktop
node_desktop -->|"opens"| node_web
node_web -.->|"sends chat"| node_server
node_server -->|"dispatches"| node_agent
node_server -->|"uses"| node_search
node_server -->|"uses"| node_market
node_server -->|"uses"| node_expert
node_server -->|"exports"| node_artifacts
node_server -->|"uses"| node_tools
node_agent -->|"uses"| node_prompts
node_expert -->|"queries"| node_search
node_search -->|"searches"| node_internet
node_tools -.->|"dispatches"| node_code
node_user -->|"requests inference"| node_modelapi
node_training -->|"loads"| node_dataset
node_training -->|"trains"| node_minimind
node_training -->|"generates with"| node_rollout
node_training -->|"uses"| node_trainerutils
node_rollout -->|"generates with"| node_minimind
node_profiles -->|"configures"| node_minimind
node_evaluation -->|"evaluates"| node_minimind
node_evaluation -->|"selects"| node_profiles
node_evaluation -.->|"loads adapters"| node_lora
node_modelapi -->|"serves"| node_minimind
node_modelapi -->|"configures"| node_profiles

click node_web "https://github.com/huhuluwa/forgemind/tree/main/web"
click node_desktop "https://github.com/huhuluwa/forgemind/blob/main/desktop/Program.cs"
click node_server "https://github.com/huhuluwa/forgemind/blob/main/source/scripts/serve_forgemind_chat_web.py"
click node_agent "https://github.com/huhuluwa/forgemind/blob/main/source/agent_runtime/openai_agent.py"
click node_prompts "https://github.com/huhuluwa/forgemind/blob/main/source/agent_runtime/prompts.py"
click node_modelapi "https://github.com/huhuluwa/forgemind/blob/main/minimind/scripts/serve_openai_api.py"
click node_search "https://github.com/huhuluwa/forgemind/blob/main/source/agent_runtime/search.py"
click node_expert "https://github.com/huhuluwa/forgemind/blob/main/source/agent_runtime/expert_kb.py"
click node_market "https://github.com/huhuluwa/forgemind/blob/main/source/agent_runtime/market.py"
click node_tools "https://github.com/huhuluwa/forgemind/blob/main/source/agent_runtime/tools.py"
click node_code "https://github.com/huhuluwa/forgemind/blob/main/source/agent_runtime/code_tools.py"
click node_artifacts "https://github.com/huhuluwa/forgemind/blob/main/source/agent_runtime/artifacts.py"
click node_training "https://github.com/huhuluwa/forgemind/blob/main/minimind/trainer/train_agent.py"
click node_rollout "https://github.com/huhuluwa/forgemind/blob/main/minimind/trainer/rollout_engine.py"
click node_trainerutils "https://github.com/huhuluwa/forgemind/blob/main/minimind/trainer/trainer_utils.py"
click node_dataset "https://github.com/huhuluwa/forgemind/blob/main/minimind/dataset/lm_dataset.py"
click node_minimind "https://github.com/huhuluwa/forgemind/blob/main/minimind/model/model_minimind.py"
click node_profiles "https://github.com/huhuluwa/forgemind/blob/main/minimind/model/model_profiles.py"
click node_lora "https://github.com/huhuluwa/forgemind/blob/main/minimind/model/lora_adapter.py"
click node_evaluation "https://github.com/huhuluwa/forgemind/blob/main/minimind/eval_llm.py"
click node_modelservice "https://github.com/huhuluwa/forgemind/blob/main/minimind/scripts/serve_openai_api.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_web,node_desktop,node_server,node_modelapi,node_modelservice,node_user toneBlue
class node_agent,node_prompts,node_search,node_expert,node_market,node_tools,node_code,node_artifacts toneAmber
class node_training,node_rollout,node_trainerutils,node_evaluation toneMint
class node_dataset,node_minimind,node_profiles,node_lora toneRose
class node_internet toneIndigo
```

## Components

### Chat product

- [Chat interface](https://github.com/huhuluwa/forgemind/tree/main/web): `web`
- [Desktop client](https://github.com/huhuluwa/forgemind/blob/main/desktop/Program.cs): `desktop/Program.cs`
- [Chat and API server](https://github.com/huhuluwa/forgemind/blob/main/source/scripts/serve_forgemind_chat_web.py): `source/scripts/serve_forgemind_chat_web.py`
- [OpenAI model API](https://github.com/huhuluwa/forgemind/blob/main/minimind/scripts/serve_openai_api.py): `minimind/scripts/serve_openai_api.py`
- [Model API service](https://github.com/huhuluwa/forgemind/blob/main/minimind/scripts/serve_openai_api.py): `minimind/scripts/serve_openai_api.py`

### Assistant runtime

- [Conversation agent](https://github.com/huhuluwa/forgemind/blob/main/source/agent_runtime/openai_agent.py): `source/agent_runtime/openai_agent.py`
- [Identity and prompts](https://github.com/huhuluwa/forgemind/blob/main/source/agent_runtime/prompts.py): `source/agent_runtime/prompts.py`
- [Web search](https://github.com/huhuluwa/forgemind/blob/main/source/agent_runtime/search.py): `source/agent_runtime/search.py`
- [Expert knowledge base](https://github.com/huhuluwa/forgemind/blob/main/source/agent_runtime/expert_kb.py): `source/agent_runtime/expert_kb.py`
- [Market information](https://github.com/huhuluwa/forgemind/blob/main/source/agent_runtime/market.py): `source/agent_runtime/market.py`
- [Agent tools](https://github.com/huhuluwa/forgemind/blob/main/source/agent_runtime/tools.py): `source/agent_runtime/tools.py`
- [Code workspace tools](https://github.com/huhuluwa/forgemind/blob/main/source/agent_runtime/code_tools.py): `source/agent_runtime/code_tools.py`
- [File exports](https://github.com/huhuluwa/forgemind/blob/main/source/agent_runtime/artifacts.py): `source/agent_runtime/artifacts.py`

### Model training

- [Training workflows](https://github.com/huhuluwa/forgemind/blob/main/minimind/trainer/train_agent.py): `minimind/trainer/train_agent.py`
- [Generation rollouts](https://github.com/huhuluwa/forgemind/blob/main/minimind/trainer/rollout_engine.py): `minimind/trainer/rollout_engine.py`
- [Training utilities](https://github.com/huhuluwa/forgemind/blob/main/minimind/trainer/trainer_utils.py): `minimind/trainer/trainer_utils.py`
- [Model evaluation](https://github.com/huhuluwa/forgemind/blob/main/minimind/eval_llm.py): `minimind/eval_llm.py`

### Model and data

- [Language datasets](https://github.com/huhuluwa/forgemind/blob/main/minimind/dataset/lm_dataset.py): `minimind/dataset/lm_dataset.py`
- [MiniMind model](https://github.com/huhuluwa/forgemind/blob/main/minimind/model/model_minimind.py): `minimind/model/model_minimind.py`
- [Model profiles](https://github.com/huhuluwa/forgemind/blob/main/minimind/model/model_profiles.py): `minimind/model/model_profiles.py`
- [LoRA adapters](https://github.com/huhuluwa/forgemind/blob/main/minimind/model/lora_adapter.py): `minimind/model/lora_adapter.py`

### Other components

- **User**
- **Search providers**

## Connections

- User → Chat interface: uses (evidence: `README.md`)
- User → Desktop client: launches (evidence: `README.md`)
- Desktop client → Chat interface: opens (evidence: `README.md`)
- Chat interface → Chat and API server: sends chat
- Chat and API server → Conversation agent: dispatches (evidence: `source/scripts/serve_forgemind_chat_web.py`)
- Chat and API server → Web search: uses (evidence: `source/scripts/serve_forgemind_chat_web.py`)
- Chat and API server → Market information: uses (evidence: `source/scripts/serve_forgemind_chat_web.py`)
- Chat and API server → Expert knowledge base: uses (evidence: `source/scripts/serve_forgemind_chat_web.py`)
- Chat and API server → File exports: exports (evidence: `source/scripts/serve_forgemind_chat_web.py`)
- Chat and API server → Agent tools: uses (evidence: `source/scripts/serve_forgemind_chat_web.py`)
- Conversation agent → Identity and prompts: uses (evidence: `source/agent_runtime/openai_agent.py`)
- Expert knowledge base → Web search: queries (evidence: `source/agent_runtime/expert_kb.py`)
- Web search → Search providers: searches (evidence: `source/agent_runtime/search.py`)
- Agent tools → Code workspace tools: dispatches
- User → OpenAI model API: requests inference (evidence: `README.md`)
- Training workflows → Language datasets: loads (evidence: `minimind/trainer/train_agent.py`)
- Training workflows → MiniMind model: trains (evidence: `minimind/trainer/train_agent.py`)
- Training workflows → Generation rollouts: generates with (evidence: `minimind/trainer/train_agent.py`)
- Training workflows → Training utilities: uses (evidence: `minimind/trainer/train_agent.py`)
- Generation rollouts → MiniMind model: generates with (evidence: `minimind/trainer/rollout_engine.py`)
- Model profiles → MiniMind model: configures (evidence: `minimind/model/model_profiles.py`)
- Model evaluation → MiniMind model: evaluates (evidence: `minimind/eval_llm.py`)
- Model evaluation → Model profiles: selects (evidence: `minimind/eval_llm.py`)
- Model evaluation → LoRA adapters: loads adapters
- OpenAI model API → MiniMind model: serves (evidence: `minimind/scripts/serve_openai_api.py`)
- OpenAI model API → Model profiles: configures (evidence: `minimind/scripts/serve_openai_api.py`)
