# danielg0798/instruct-ai_m2 architecture

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

- Interactive diagram: https://gitdiagram.com/danielg0798/instruct-ai_m2
- Repository: https://github.com/danielg0798/instruct-ai_m2

## Overview

CourseGuide AI is a prototype that guides students through course-specific questions while respecting instructor-defined help boundaries. A student question enters the agent, which is configured to classify the request and look up the course policy through MCP tools before producing a guided response; students can also ask which courses are available. The MCP server implements those tools, and policy lookup loads YAML configuration or falls back to a default. The sampled code also shows client setup and console tracing. The README documents these capabilities; unsampled runtime behavior is not inferred.

Main entry points: [`src/m2_agent.py`](https://github.com/danielg0798/instruct-ai_m2/blob/main/src/m2_agent.py) (CourseGuide Agent), [`mcp_servers/course_policy_mcp.py`](https://github.com/danielg0798/instruct-ai_m2/blob/main/mcp_servers/course_policy_mcp.py) (Policy MCP Server), [`src/shared/policy_loader.py`](https://github.com/danielg0798/instruct-ai_m2/blob/main/src/shared/policy_loader.py) (Policy Loader), [`config/physics_101.yaml`](https://github.com/danielg0798/instruct-ai_m2/blob/main/config/physics_101.yaml) (Physics Policy)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_agent["Student Agent"]
  node_agent_runtime["CourseGuide Agent<br/>[m2_agent.py]"]
  node_trace["Console Tracing<br/>[tracing.py]"]
end

subgraph group_tools["MCP Tools"]
  node_mcp_server["Policy MCP Server"]
  node_classifier["Help Classifier"]
  node_policy_lookup["Policy Lookup Tool"]
  node_course_listing["Course Listing Tool"]
end

subgraph group_policy["Course Policies"]
  node_policy_loader["Policy Loader<br/>[policy_loader.py]"]
  node_physics_policy["Physics Policy<br/>[physics_101.yaml]"]
  node_chemistry_policy["Chemistry Policy<br/>[chemistry_201.yaml]"]
  node_shared_config["Shared Configuration<br/>[config.py]"]
end

node_student(("Student"))
node_model_api["Model API"]

node_student -->|"asks question"| node_agent_runtime
node_agent_runtime -->|"connects via MCP"| node_mcp_server
node_mcp_server -->|"registers tool"| node_classifier
node_mcp_server -->|"registers tool"| node_policy_lookup
node_mcp_server -->|"registers tool"| node_course_listing
node_agent_runtime -->|"requests classification"| node_classifier
node_agent_runtime -->|"requests policy"| node_policy_lookup
node_agent_runtime -->|"requests course list"| node_course_listing
node_policy_lookup -->|"loads policy"| node_policy_loader
node_policy_loader -->|"reads YAML"| node_physics_policy
node_policy_loader -->|"reads YAML"| node_chemistry_policy
node_course_listing -->|"lists files"| node_physics_policy
node_course_listing -->|"lists files"| node_chemistry_policy
node_agent_runtime -->|"runs model"| node_model_api
node_agent_runtime -->|"configures tracing"| node_trace
node_agent_runtime -->|"returns response"| node_student

click node_agent_runtime "https://github.com/danielg0798/instruct-ai_m2/blob/main/src/m2_agent.py"
click node_trace "https://github.com/danielg0798/instruct-ai_m2/blob/main/src/shared/tracing.py"
click node_mcp_server "https://github.com/danielg0798/instruct-ai_m2/blob/main/mcp_servers/course_policy_mcp.py"
click node_classifier "https://github.com/danielg0798/instruct-ai_m2/blob/main/mcp_servers/course_policy_mcp.py"
click node_policy_lookup "https://github.com/danielg0798/instruct-ai_m2/blob/main/mcp_servers/course_policy_mcp.py"
click node_course_listing "https://github.com/danielg0798/instruct-ai_m2/blob/main/mcp_servers/course_policy_mcp.py"
click node_policy_loader "https://github.com/danielg0798/instruct-ai_m2/blob/main/src/shared/policy_loader.py"
click node_physics_policy "https://github.com/danielg0798/instruct-ai_m2/blob/main/config/physics_101.yaml"
click node_chemistry_policy "https://github.com/danielg0798/instruct-ai_m2/blob/main/config/chemistry_201.yaml"
click node_shared_config "https://github.com/danielg0798/instruct-ai_m2/blob/main/src/shared/config.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_agent_runtime,node_trace toneBlue
class node_mcp_server,node_classifier,node_policy_lookup,node_course_listing toneAmber
class node_policy_loader,node_physics_policy,node_chemistry_policy,node_shared_config,node_model_api toneMint
class node_student toneIndigo
```

## Components

### Student Agent

- [CourseGuide Agent](https://github.com/danielg0798/instruct-ai_m2/blob/main/src/m2_agent.py): `src/m2_agent.py`
- [Console Tracing](https://github.com/danielg0798/instruct-ai_m2/blob/main/src/shared/tracing.py): `src/shared/tracing.py`

### MCP Tools

- [Policy MCP Server](https://github.com/danielg0798/instruct-ai_m2/blob/main/mcp_servers/course_policy_mcp.py): `mcp_servers/course_policy_mcp.py`
- [Help Classifier](https://github.com/danielg0798/instruct-ai_m2/blob/main/mcp_servers/course_policy_mcp.py): `mcp_servers/course_policy_mcp.py`
- [Policy Lookup Tool](https://github.com/danielg0798/instruct-ai_m2/blob/main/mcp_servers/course_policy_mcp.py): `mcp_servers/course_policy_mcp.py`
- [Course Listing Tool](https://github.com/danielg0798/instruct-ai_m2/blob/main/mcp_servers/course_policy_mcp.py): `mcp_servers/course_policy_mcp.py`

### Course Policies

- [Policy Loader](https://github.com/danielg0798/instruct-ai_m2/blob/main/src/shared/policy_loader.py): `src/shared/policy_loader.py`
- [Physics Policy](https://github.com/danielg0798/instruct-ai_m2/blob/main/config/physics_101.yaml): `config/physics_101.yaml`
- [Chemistry Policy](https://github.com/danielg0798/instruct-ai_m2/blob/main/config/chemistry_201.yaml): `config/chemistry_201.yaml`
- [Shared Configuration](https://github.com/danielg0798/instruct-ai_m2/blob/main/src/shared/config.py): `src/shared/config.py`

### Other components

- **Student**
- **Model API**

## Connections

- Student → CourseGuide Agent: asks question (evidence: `README.md`)
- CourseGuide Agent → Policy MCP Server: connects via MCP (evidence: `src/m2_agent.py`)
- Policy MCP Server → Help Classifier: registers tool (evidence: `mcp_servers/course_policy_mcp.py`)
- Policy MCP Server → Policy Lookup Tool: registers tool (evidence: `mcp_servers/course_policy_mcp.py`)
- Policy MCP Server → Course Listing Tool: registers tool (evidence: `mcp_servers/course_policy_mcp.py`)
- CourseGuide Agent → Help Classifier: requests classification (evidence: `src/m2_agent.py`)
- CourseGuide Agent → Policy Lookup Tool: requests policy (evidence: `src/m2_agent.py`)
- CourseGuide Agent → Course Listing Tool: requests course list (evidence: `src/m2_agent.py`)
- Policy Lookup Tool → Policy Loader: loads policy (evidence: `mcp_servers/course_policy_mcp.py`)
- Policy Loader → Physics Policy: reads YAML (evidence: `src/shared/policy_loader.py`)
- Policy Loader → Chemistry Policy: reads YAML (evidence: `src/shared/policy_loader.py`)
- Course Listing Tool → Physics Policy: lists files (evidence: `mcp_servers/course_policy_mcp.py`)
- Course Listing Tool → Chemistry Policy: lists files (evidence: `mcp_servers/course_policy_mcp.py`)
- CourseGuide Agent → Model API: runs model (evidence: `README.md`)
- CourseGuide Agent → Console Tracing: configures tracing (evidence: `src/m2_agent.py`)
- CourseGuide Agent → Student: returns response (evidence: `README.md`)
