# aigc-open/tender-cli architecture

> Architecture diagram of the GitHub repository aigc-open/tender-cli, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-04-15). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/aigc-open/tender-cli
- Repository: https://github.com/aigc-open/tender-cli

## Overview

1. **Repository purpose**
   Tender CLI is a Python command-line assistant for end-to-end tender/bid document work: analyze source tender files, plan tasks, generate section content, and export a final Word/PDF deliverable. The architecture is centered on a conversational AI orchestrator rather than a traditional CRUD application.

2. **Top-level runtime entrypoint**
   `src/tender_cli/main.py` is the CLI entry. It likely boots the interactive shell, loads configuration, initializes logging, and hands control to the main AI workflow. From there, the user stays in a conversation loop rather than moving through discrete screens.

3. **Core orchestration layer**
   `src/tender_cli/core/tender_ai.py` is the main application brain. It coordinates:
   - user intent parsing,
   - task planning,
   - tool invocation,
   - progress updates,
   - and final response assembly.
   This module sits above the rest of the system and acts as the integration point between AI, project state, and MCP tools.

4. **Conversation and state management**
   `core/conversation.py` manages multi-turn dialog context, so the assistant can remember prior turns and incremental decisions. This is important because the workflow is iterative: analysis leads to planning, planning leads to chapter generation, and later user corrections feed back into the same project state.

5. **Project/workspace boundary**
   `core/project_manager.py` encapsulates the bid/project lifecycle: creating projects, selecting active projects, managing directory structure, backups, and assembling chapter files into outputs. The repository treats each tender as a workspace with persistent artifacts on disk:
   sections, assets, temp files, backups, and final exports.

6. **Configuration boundary**
   `core/config.py` centralizes configuration loading and precedence. The README shows config coming from environment variables, `.env` files, YAML config, and interactive setup. This module is the boundary between runtime behavior and deployment-specific settings such as AI provider, model name, API base URL, workspace path, and debug mode.

7. **AI integration layer**
   `utils/ai_client.py` is the abstraction over the model provider. It connects the assistant to OpenAI-compatible endpoints or custom model servers, using config values from the configuration layer. In the architecture diagram, this is the outbound external dependency for generation and reasoning.

8. **Prompt subsystem**
   `prompts/prompt_library.py` stores reusable prompt templates for the different phases of the workflow: analysis, outlining, chapter drafting, refinement, and possibly tool-selection behavior. This is a pure application-layer dependency consumed by the orchestrator and AI client, not by the file/document tools directly.

9. **MCP tool subsystem**
   The `mcp_tools/` package is the execution layer for concrete operations. It is split into focused tool groups:
   - `file_tools.py` for reading/writing content and directory structure management
   - `tender_tools.py` for tender document parsing and requirement extraction
   - `content_tools.py` for outline and section generation
   - `document_tools.py` for Word/PDF export and formatting
   - `base.py` as the shared tool abstraction
   - `mcp_server.py` as the server-facing registry/dispatcher
   - `mcp_agent.py` for agent-side integration
   These tools are the bridge between AI decisions and filesystem/document side effects.

10. **Data flow through the system**
   The main flow is: user command in CLI → `TenderAI` interprets intent → conversation state updates → prompt is assembled → AI client requests model output → model selects a plan or tool action → MCP tool executes file/document work in the project workspace → results are fed back into the conversation and surfaced to the user. The final output is usually persistent files under the project workspace, not just console text.

11. **Document assembly model**
   The README’s project structure shows a chapter-oriented content model: each third-level heading is a separate markdown file, grouped under section folders. This enables parallel generation and granular editing. The document export layer then merges these modular content files into a single formatted deliverable, typically a `.docx` in the project `output/` directory.

12. **External interfaces and deployment assumptions**
   The system depends on an OpenAI-compatible API endpoint, but the README also allows custom local model endpoints. The project is therefore architecture-agnostic at the model layer: the same AI client can target a hosted API or a self-hosted service as long as it speaks the expected interface.

13. **Examples and test surface**
   `examples/` demonstrates the main integration points: basic usage, custom tools, math client/server, and MCP base usage. This suggests the repo is designed to support both internal CLI operation and standalone MCP-style tool experimentation. `tests/test_basic.py` indicates the test suite is currently lightweight and likely focused on smoke-level validation rather than deep tool integration.

14. **What to show in an architecture diagram**
   A clear diagram should depict:
   - the CLI entrypoint,
   - the core AI orchestrator,
   - configuration and conversation state,
   - the AI model endpoint,
   - the MCP tool layer split into file/content/tender/document capabilities,
   - and the workspace filesystem where projects, chapter files, backups, and exported documents live.
   The key architectural boundary is between “reasoning/planning” and “filesystem/document side effects.”

Main entry points: [`src/tender_cli/core/tender_ai.py`](https://github.com/aigc-open/tender-cli/blob/main/src/tender_cli/core/tender_ai.py) (Tender AI), [`src/tender_cli/mcp_tools/mcp_server.py`](https://github.com/aigc-open/tender-cli/blob/main/src/tender_cli/mcp_tools/mcp_server.py) (MCP Server), [`src/tender_cli/core/project_manager.py`](https://github.com/aigc-open/tender-cli/blob/main/src/tender_cli/core/project_manager.py) (Project Manager), [`src/tender_cli/mcp_tools/file_tools.py`](https://github.com/aigc-open/tender-cli/blob/main/src/tender_cli/mcp_tools/file_tools.py) (File Tools)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Runtime"]
  node_src_tender_cli_main(("CLI<br/>entrypoint<br/>[main.py]"))
end

subgraph group_core["Core"]
  node_src_tender_cli_core_tender_ai{{"Tender AI<br/>orchestrator<br/>[tender_ai.py]"}}
  node_src_tender_cli_core_conversation[("Conversation<br/>dialog state<br/>[conversation.py]")]
  node_src_tender_cli_core_project_manager["Project Manager<br/>workspace manager<br/>[project_manager.py]"]
  node_src_tender_cli_core_config["Config<br/>settings boundary<br/>[config.py]"]
end

subgraph group_tools["MCP Tools"]
  node_src_tender_cli_mcp_tools_base["Tool Base<br/>tool abstraction<br/>[base.py]"]
  node_src_tender_cli_mcp_tools_mcp_server["MCP Server<br/>tool registry<br/>[mcp_server.py]"]
  node_src_tender_cli_mcp_tools_mcp_agent["MCP Agent<br/>tool bridge<br/>[mcp_agent.py]"]
  node_src_tender_cli_mcp_tools_file_tools["File Tools<br/>filesystem tools<br/>[file_tools.py]"]
  node_src_tender_cli_mcp_tools_tender_tools["Tender Tools<br/>analysis tools<br/>[tender_tools.py]"]
  node_src_tender_cli_mcp_tools_content_tools["Content Tools<br/>drafting tools<br/>[content_tools.py]"]
  node_src_tender_cli_mcp_tools_document_tools["Document Tools<br/>export tools<br/>[document_tools.py]"]
end

subgraph group_ai["AI Layer"]
  node_src_tender_cli_utils_ai_client{{"AI Client<br/>model adapter<br/>[ai_client.py]"}}
  node_src_tender_cli_prompts_prompt_library["Prompts<br/>template library<br/>[prompt_library.py]"]
end

subgraph group_workspace["Workspace"]
  node_workspace_files[("Workspace Files<br/>project artifacts")]
end

node_src_tender_cli_main -->|"bootstraps"| node_src_tender_cli_core_tender_ai
node_src_tender_cli_core_tender_ai -->|"reads/writes"| node_src_tender_cli_core_conversation
node_src_tender_cli_core_tender_ai -->|"loads"| node_src_tender_cli_core_config
node_src_tender_cli_core_tender_ai -->|"calls model"| node_src_tender_cli_utils_ai_client
node_src_tender_cli_core_tender_ai -->|"assembles prompts"| node_src_tender_cli_prompts_prompt_library
node_src_tender_cli_core_tender_ai -->|"invokes tools"| node_src_tender_cli_mcp_tools_mcp_agent
node_src_tender_cli_core_project_manager -->|"manages"| node_workspace_files
node_src_tender_cli_mcp_tools_mcp_agent -->|"dispatches"| node_src_tender_cli_mcp_tools_mcp_server
node_src_tender_cli_mcp_tools_mcp_server -->|"exposes"| node_src_tender_cli_mcp_tools_base
node_src_tender_cli_mcp_tools_mcp_server -->|"registers"| node_src_tender_cli_mcp_tools_file_tools
node_src_tender_cli_mcp_tools_mcp_server -->|"registers"| node_src_tender_cli_mcp_tools_tender_tools
node_src_tender_cli_mcp_tools_mcp_server -->|"registers"| node_src_tender_cli_mcp_tools_content_tools
node_src_tender_cli_mcp_tools_mcp_server -->|"registers"| node_src_tender_cli_mcp_tools_document_tools
node_src_tender_cli_mcp_tools_file_tools -->|"reads/writes"| node_workspace_files
node_src_tender_cli_mcp_tools_content_tools -->|"produces"| node_workspace_files
node_src_tender_cli_mcp_tools_document_tools -->|"exports"| node_workspace_files
node_src_tender_cli_mcp_tools_tender_tools -->|"analyzes"| node_workspace_files
node_src_tender_cli_core_project_manager -->|"coordinates"| node_src_tender_cli_mcp_tools_file_tools
node_src_tender_cli_core_tender_ai -->|"orchestrates"| node_src_tender_cli_core_project_manager

click node_src_tender_cli_main "https://github.com/aigc-open/tender-cli/blob/main/src/tender_cli/main.py"
click node_src_tender_cli_core_tender_ai "https://github.com/aigc-open/tender-cli/blob/main/src/tender_cli/core/tender_ai.py"
click node_src_tender_cli_core_conversation "https://github.com/aigc-open/tender-cli/blob/main/src/tender_cli/core/conversation.py"
click node_src_tender_cli_core_project_manager "https://github.com/aigc-open/tender-cli/blob/main/src/tender_cli/core/project_manager.py"
click node_src_tender_cli_core_config "https://github.com/aigc-open/tender-cli/blob/main/src/tender_cli/core/config.py"
click node_src_tender_cli_utils_ai_client "https://github.com/aigc-open/tender-cli/blob/main/src/tender_cli/utils/ai_client.py"
click node_src_tender_cli_prompts_prompt_library "https://github.com/aigc-open/tender-cli/blob/main/src/tender_cli/prompts/prompt_library.py"
click node_src_tender_cli_mcp_tools_base "https://github.com/aigc-open/tender-cli/blob/main/src/tender_cli/mcp_tools/base.py"
click node_src_tender_cli_mcp_tools_mcp_server "https://github.com/aigc-open/tender-cli/blob/main/src/tender_cli/mcp_tools/mcp_server.py"
click node_src_tender_cli_mcp_tools_mcp_agent "https://github.com/aigc-open/tender-cli/blob/main/src/tender_cli/mcp_tools/mcp_agent.py"
click node_src_tender_cli_mcp_tools_file_tools "https://github.com/aigc-open/tender-cli/blob/main/src/tender_cli/mcp_tools/file_tools.py"
click node_src_tender_cli_mcp_tools_tender_tools "https://github.com/aigc-open/tender-cli/blob/main/src/tender_cli/mcp_tools/tender_tools.py"
click node_src_tender_cli_mcp_tools_content_tools "https://github.com/aigc-open/tender-cli/blob/main/src/tender_cli/mcp_tools/content_tools.py"
click node_src_tender_cli_mcp_tools_document_tools "https://github.com/aigc-open/tender-cli/blob/main/src/tender_cli/mcp_tools/document_tools.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_src_tender_cli_main toneBlue
class node_src_tender_cli_core_tender_ai,node_src_tender_cli_core_conversation,node_src_tender_cli_core_project_manager,node_src_tender_cli_core_config toneAmber
class node_src_tender_cli_mcp_tools_base,node_src_tender_cli_mcp_tools_mcp_server,node_src_tender_cli_mcp_tools_mcp_agent,node_src_tender_cli_mcp_tools_file_tools,node_src_tender_cli_mcp_tools_tender_tools,node_src_tender_cli_mcp_tools_content_tools,node_src_tender_cli_mcp_tools_document_tools toneMint
class node_src_tender_cli_utils_ai_client,node_src_tender_cli_prompts_prompt_library toneRose
class node_workspace_files toneIndigo
```

## Components

### Runtime

CLI entrypoint and interactive application flow

- [CLI](https://github.com/aigc-open/tender-cli/blob/main/src/tender_cli/main.py): entrypoint · Starts the command-line assistant and hands control to the AI workflow · `src/tender_cli/main.py`

### Core

Conversation, configuration, project lifecycle, and orchestration

- [Tender AI](https://github.com/aigc-open/tender-cli/blob/main/src/tender_cli/core/tender_ai.py): orchestrator · Main application brain for intent parsing, planning, tool use, and response assembly · `src/tender_cli/core/tender_ai.py`
- [Conversation](https://github.com/aigc-open/tender-cli/blob/main/src/tender_cli/core/conversation.py): dialog state · Maintains multi-turn context and incremental decisions · `src/tender_cli/core/conversation.py`
- [Project Manager](https://github.com/aigc-open/tender-cli/blob/main/src/tender_cli/core/project_manager.py): workspace manager · Creates and selects projects, manages directories, backups, and assembled outputs · `src/tender_cli/core/project_manager.py`
- [Config](https://github.com/aigc-open/tender-cli/blob/main/src/tender_cli/core/config.py): settings boundary · Loads configuration from env, .env, YAML, and interactive setup · `src/tender_cli/core/config.py`

### MCP Tools

Execution layer for file, tender, content, and document actions

- [Tool Base](https://github.com/aigc-open/tender-cli/blob/main/src/tender_cli/mcp_tools/base.py): tool abstraction · Shared base layer for MCP-style tool definitions and invocation · `src/tender_cli/mcp_tools/base.py`
- [MCP Server](https://github.com/aigc-open/tender-cli/blob/main/src/tender_cli/mcp_tools/mcp_server.py): tool registry · Server-facing dispatcher and registry for exposed tools · `src/tender_cli/mcp_tools/mcp_server.py`
- [MCP Agent](https://github.com/aigc-open/tender-cli/blob/main/src/tender_cli/mcp_tools/mcp_agent.py): tool bridge · Agent-side integration for tool execution and coordination · `src/tender_cli/mcp_tools/mcp_agent.py`
- [File Tools](https://github.com/aigc-open/tender-cli/blob/main/src/tender_cli/mcp_tools/file_tools.py): filesystem tools · Reads, writes, and manages project files and directories · `src/tender_cli/mcp_tools/file_tools.py`
- [Tender Tools](https://github.com/aigc-open/tender-cli/blob/main/src/tender_cli/mcp_tools/tender_tools.py): analysis tools · Parses tender documents and extracts requirements · `src/tender_cli/mcp_tools/tender_tools.py`
- [Content Tools](https://github.com/aigc-open/tender-cli/blob/main/src/tender_cli/mcp_tools/content_tools.py): drafting tools · Generates outlines and section content for tender chapters · `src/tender_cli/mcp_tools/content_tools.py`
- [Document Tools](https://github.com/aigc-open/tender-cli/blob/main/src/tender_cli/mcp_tools/document_tools.py): export tools · Formats and exports final Word/PDF deliverables · `src/tender_cli/mcp_tools/document_tools.py`

### AI Layer

Model client and prompt templates

- [AI Client](https://github.com/aigc-open/tender-cli/blob/main/src/tender_cli/utils/ai_client.py): model adapter · Abstraction over OpenAI-compatible and custom model endpoints · `src/tender_cli/utils/ai_client.py`
- [Prompts](https://github.com/aigc-open/tender-cli/blob/main/src/tender_cli/prompts/prompt_library.py): template library · Reusable prompt templates for analysis, outlining, drafting, and refinement · `src/tender_cli/prompts/prompt_library.py`

### Workspace

Persistent project files and exports

- **Workspace Files**: project artifacts · Persistent tender projects, sections, backups, temp files, and exports

## Connections

- CLI → Tender AI: bootstraps · CLI hands control to the conversational orchestrator
- Tender AI → Conversation: reads/writes · Maintains turn context and iterative decisions
- Tender AI → Config: loads · Uses runtime settings for model and workspace behavior
- Tender AI → AI Client: calls model · Requests generation and reasoning from the AI endpoint
- Tender AI → Prompts: assembles prompts · Builds phase-specific prompts for analysis and drafting
- Tender AI → MCP Agent: invokes tools · Delegates concrete operations to the MCP execution layer
- Project Manager → Workspace Files: manages · Creates project structure, backups, and output locations
- MCP Agent → MCP Server: dispatches · Routes tool requests through the server registry
- MCP Server → Tool Base: exposes · Uses the shared abstraction for tool definitions
- MCP Server → File Tools: registers · File and directory operations
- MCP Server → Tender Tools: registers · Tender analysis and requirement extraction
- MCP Server → Content Tools: registers · Outline and section drafting
- MCP Server → Document Tools: registers · Word/PDF formatting and export
- File Tools → Workspace Files: reads/writes · Persists chapter files and supporting assets
- Content Tools → Workspace Files: produces · Creates modular section content in the project workspace
- Document Tools → Workspace Files: exports · Assembles final deliverables from workspace artifacts
- Tender Tools → Workspace Files: analyzes · Consumes source tender documents from the project workspace
- Project Manager → File Tools: coordinates · Relies on file operations for workspace lifecycle actions
- Tender AI → Project Manager: orchestrates · Coordinates project selection and artifact lifecycle
