# sudo-charan/guardgpt-majorproject architecture

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

- Interactive diagram: https://gitdiagram.com/sudo-charan/guardgpt-majorproject
- Repository: https://github.com/sudo-charan/guardgpt-majorproject

## Overview

GuardGPT is a local prompt-safety service whose canonical workflow accepts a prompt through the CLI/MCP client, runs layered input analysis and a safety decision, optionally generates and audits an answer, then returns a report. The README documents the complete pipeline and a separate LangGraph compatibility workflow; source excerpts verify the MCP entry point, adapters, and selected analysis behavior. Internal pipeline stages not excerpted are represented from the README, not inferred from inspected implementation. The listed tree omits the active dataset and FAISS index artifacts, so the loader is shown without a separate store node.

Main entry points: [`mcp_server/server.py`](https://github.com/sudo-charan/guardgpt-majorproject/blob/main/mcp_server/server.py) (MCP server), [`core/complete_pipeline.py`](https://github.com/sudo-charan/guardgpt-majorproject/blob/main/core/complete_pipeline.py) (Complete pipeline), [`core/safety_service.py`](https://github.com/sudo-charan/guardgpt-majorproject/blob/main/core/safety_service.py) (Safety service), [`core/intent_classifier.py`](https://github.com/sudo-charan/guardgpt-majorproject/blob/main/core/intent_classifier.py) (Intent classifier)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Request access"]
  node_cli["CLI<br/>[main.py]"]
  node_client["MCP client<br/>[mcp_client.py]"]
end

subgraph group_analysis["Safety analysis"]
  node_safety["Safety service<br/>[safety_service.py]"]
  node_classifier["Intent classifier"]
  node_dataset["Dataset evidence<br/>[dataset_loader.py]"]
  node_risk["Risk estimator<br/>[risk_estimator.py]"]
  node_patterns["Jailbreak patterns"]
  node_conversation["Conversation guard"]
  node_temporal["Temporal intent<br/>[temporal_intent.py]"]
end

subgraph group_pipeline["Decision and response"]
  node_pipeline["Complete pipeline"]
  node_decision["Decision engine<br/>[decision_engine.py]"]
  node_backend["Ollama backend<br/>[llama_backend.py]"]
  node_auditor["Output auditor<br/>[output_auditor.py]"]
  node_reporting["Audit and reports<br/>[audit_logger.py]"]
end

subgraph group_mcp["MCP interfaces"]
  node_server["MCP server<br/>[server.py]"]
  node_schemas["Tool schemas<br/>[schemas.py]"]
  node_prompt_tool["Prompt analysis<br/>[prompt_analysis.py]"]
  node_jailbreak_tool["Jailbreak detection"]
  node_moderation_tool["Content moderation"]
  node_decision_tool["Decision adapter<br/>[decision.py]"]
end

subgraph group_compat["Agent compatibility"]
  node_agent_manager["Server manager<br/>[server_manager.py]"]
  node_agent_graph["LangGraph workflow<br/>[graph.py]"]
  node_agent_nodes["MCP agent nodes<br/>[nodes.py]"]
end

node_user(("User or app"))
node_ollama(("Ollama service"))

node_user -->|"submits prompt"| node_cli
node_cli -->|"calls tool"| node_client
node_client -->|"invokes MCP"| node_server
node_server -->|"runs request"| node_pipeline
node_pipeline -->|"checks input"| node_safety
node_safety -->|"classifies intent"| node_classifier
node_safety -->|"queries evidence"| node_dataset
node_safety -->|"estimates risk"| node_risk
node_safety -->|"checks patterns"| node_patterns
node_pipeline -->|"tracks sessions"| node_conversation
node_conversation -->|"updates state"| node_temporal
node_pipeline -->|"decides action"| node_decision
node_pipeline -->|"generates answer"| node_backend
node_backend -->|"requests generation"| node_ollama
node_pipeline -->|"reviews answer"| node_auditor
node_pipeline -->|"persists reports"| node_reporting
node_server -->|"validates inputs"| node_schemas
node_server -->|"routes tool"| node_prompt_tool
node_server -->|"routes tool"| node_jailbreak_tool
node_server -->|"routes tool"| node_moderation_tool
node_server -->|"routes tool"| node_decision_tool
node_moderation_tool -->|"classifies prompt"| node_classifier
node_moderation_tool -->|"queries categories"| node_dataset
node_jailbreak_tool -->|"classifies prompt"| node_classifier
node_jailbreak_tool -->|"checks patterns"| node_patterns
node_prompt_tool -->|"classifies prompt"| node_classifier
node_prompt_tool -->|"queries evidence"| node_dataset
node_agent_manager -->|"starts server"| node_server
node_agent_graph -->|"dispatches nodes"| node_agent_nodes
node_agent_nodes -->|"calls MCP tools"| node_client

click node_cli "https://github.com/sudo-charan/guardgpt-majorproject/blob/main/main.py"
click node_client "https://github.com/sudo-charan/guardgpt-majorproject/blob/main/agent/mcp_client.py"
click node_server "https://github.com/sudo-charan/guardgpt-majorproject/blob/main/mcp_server/server.py"
click node_schemas "https://github.com/sudo-charan/guardgpt-majorproject/blob/main/mcp_server/models/schemas.py"
click node_pipeline "https://github.com/sudo-charan/guardgpt-majorproject/blob/main/core/complete_pipeline.py"
click node_safety "https://github.com/sudo-charan/guardgpt-majorproject/blob/main/core/safety_service.py"
click node_classifier "https://github.com/sudo-charan/guardgpt-majorproject/blob/main/core/intent_classifier.py"
click node_dataset "https://github.com/sudo-charan/guardgpt-majorproject/blob/main/core/dataset_loader.py"
click node_risk "https://github.com/sudo-charan/guardgpt-majorproject/blob/main/core/risk_estimator.py"
click node_patterns "https://github.com/sudo-charan/guardgpt-majorproject/blob/main/core/jailbreak_patterns.py"
click node_conversation "https://github.com/sudo-charan/guardgpt-majorproject/blob/main/core/conversation_guard.py"
click node_temporal "https://github.com/sudo-charan/guardgpt-majorproject/blob/main/core/temporal_intent.py"
click node_decision "https://github.com/sudo-charan/guardgpt-majorproject/blob/main/core/decision_engine.py"
click node_backend "https://github.com/sudo-charan/guardgpt-majorproject/blob/main/core/llama_backend.py"
click node_auditor "https://github.com/sudo-charan/guardgpt-majorproject/blob/main/core/output_auditor.py"
click node_reporting "https://github.com/sudo-charan/guardgpt-majorproject/blob/main/mcp_server/tools/audit_logger.py"
click node_prompt_tool "https://github.com/sudo-charan/guardgpt-majorproject/blob/main/mcp_server/tools/prompt_analysis.py"
click node_jailbreak_tool "https://github.com/sudo-charan/guardgpt-majorproject/blob/main/mcp_server/tools/jailbreak_detection.py"
click node_moderation_tool "https://github.com/sudo-charan/guardgpt-majorproject/blob/main/mcp_server/tools/content_moderation.py"
click node_decision_tool "https://github.com/sudo-charan/guardgpt-majorproject/blob/main/mcp_server/tools/decision.py"
click node_agent_manager "https://github.com/sudo-charan/guardgpt-majorproject/blob/main/agent/server_manager.py"
click node_agent_graph "https://github.com/sudo-charan/guardgpt-majorproject/blob/main/agent/graph.py"
click node_agent_nodes "https://github.com/sudo-charan/guardgpt-majorproject/blob/main/agent/nodes.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_cli,node_client,node_user toneBlue
class node_safety,node_classifier,node_dataset,node_risk,node_patterns,node_conversation,node_temporal toneAmber
class node_pipeline,node_decision,node_backend,node_auditor,node_reporting toneMint
class node_server,node_schemas,node_prompt_tool,node_jailbreak_tool,node_moderation_tool,node_decision_tool toneRose
class node_agent_manager,node_agent_graph,node_agent_nodes,node_ollama toneIndigo
```

## Components

### Request access

- [CLI](https://github.com/sudo-charan/guardgpt-majorproject/blob/main/main.py): `main.py`
- [MCP client](https://github.com/sudo-charan/guardgpt-majorproject/blob/main/agent/mcp_client.py): `agent/mcp_client.py`

### Safety analysis

- [Safety service](https://github.com/sudo-charan/guardgpt-majorproject/blob/main/core/safety_service.py): `core/safety_service.py`
- [Intent classifier](https://github.com/sudo-charan/guardgpt-majorproject/blob/main/core/intent_classifier.py): `core/intent_classifier.py`
- [Dataset evidence](https://github.com/sudo-charan/guardgpt-majorproject/blob/main/core/dataset_loader.py): `core/dataset_loader.py`
- [Risk estimator](https://github.com/sudo-charan/guardgpt-majorproject/blob/main/core/risk_estimator.py): `core/risk_estimator.py`
- [Jailbreak patterns](https://github.com/sudo-charan/guardgpt-majorproject/blob/main/core/jailbreak_patterns.py): `core/jailbreak_patterns.py`
- [Conversation guard](https://github.com/sudo-charan/guardgpt-majorproject/blob/main/core/conversation_guard.py): `core/conversation_guard.py`
- [Temporal intent](https://github.com/sudo-charan/guardgpt-majorproject/blob/main/core/temporal_intent.py): `core/temporal_intent.py`

### Decision and response

- [Complete pipeline](https://github.com/sudo-charan/guardgpt-majorproject/blob/main/core/complete_pipeline.py): `core/complete_pipeline.py`
- [Decision engine](https://github.com/sudo-charan/guardgpt-majorproject/blob/main/core/decision_engine.py): `core/decision_engine.py`
- [Ollama backend](https://github.com/sudo-charan/guardgpt-majorproject/blob/main/core/llama_backend.py): `core/llama_backend.py`
- [Output auditor](https://github.com/sudo-charan/guardgpt-majorproject/blob/main/core/output_auditor.py): `core/output_auditor.py`
- [Audit and reports](https://github.com/sudo-charan/guardgpt-majorproject/blob/main/mcp_server/tools/audit_logger.py): `mcp_server/tools/audit_logger.py`

### MCP interfaces

- [MCP server](https://github.com/sudo-charan/guardgpt-majorproject/blob/main/mcp_server/server.py): `mcp_server/server.py`
- [Tool schemas](https://github.com/sudo-charan/guardgpt-majorproject/blob/main/mcp_server/models/schemas.py): `mcp_server/models/schemas.py`
- [Prompt analysis](https://github.com/sudo-charan/guardgpt-majorproject/blob/main/mcp_server/tools/prompt_analysis.py): `mcp_server/tools/prompt_analysis.py`
- [Jailbreak detection](https://github.com/sudo-charan/guardgpt-majorproject/blob/main/mcp_server/tools/jailbreak_detection.py): `mcp_server/tools/jailbreak_detection.py`
- [Content moderation](https://github.com/sudo-charan/guardgpt-majorproject/blob/main/mcp_server/tools/content_moderation.py): `mcp_server/tools/content_moderation.py`
- [Decision adapter](https://github.com/sudo-charan/guardgpt-majorproject/blob/main/mcp_server/tools/decision.py): `mcp_server/tools/decision.py`

### Agent compatibility

- [Server manager](https://github.com/sudo-charan/guardgpt-majorproject/blob/main/agent/server_manager.py): `agent/server_manager.py`
- [LangGraph workflow](https://github.com/sudo-charan/guardgpt-majorproject/blob/main/agent/graph.py): `agent/graph.py`
- [MCP agent nodes](https://github.com/sudo-charan/guardgpt-majorproject/blob/main/agent/nodes.py): `agent/nodes.py`

### Other components

- **User or app**
- **Ollama service**

## Connections

- User or app → CLI: submits prompt (evidence: `README.md`)
- CLI → MCP client: calls tool (evidence: `main.py`)
- MCP client → MCP server: invokes MCP (evidence: `README.md`)
- MCP server → Complete pipeline: runs request (evidence: `mcp_server/server.py`)
- Complete pipeline → Safety service: checks input (evidence: `README.md`)
- Safety service → Intent classifier: classifies intent (evidence: `core/safety_service.py`)
- Safety service → Dataset evidence: queries evidence (evidence: `core/safety_service.py`)
- Safety service → Risk estimator: estimates risk (evidence: `core/safety_service.py`)
- Safety service → Jailbreak patterns: checks patterns (evidence: `core/safety_service.py`)
- Complete pipeline → Conversation guard: tracks sessions (evidence: `README.md`)
- Conversation guard → Temporal intent: updates state (evidence: `core/conversation_guard.py`)
- Complete pipeline → Decision engine: decides action (evidence: `README.md`)
- Complete pipeline → Ollama backend: generates answer (evidence: `README.md`)
- Ollama backend → Ollama service: requests generation (evidence: `README.md`)
- Complete pipeline → Output auditor: reviews answer (evidence: `README.md`)
- Complete pipeline → Audit and reports: persists reports (evidence: `README.md`)
- MCP server → Tool schemas: validates inputs (evidence: `mcp_server/server.py`)
- MCP server → Prompt analysis: routes tool (evidence: `mcp_server/server.py`)
- MCP server → Jailbreak detection: routes tool (evidence: `mcp_server/server.py`)
- MCP server → Content moderation: routes tool (evidence: `mcp_server/server.py`)
- MCP server → Decision adapter: routes tool (evidence: `mcp_server/server.py`)
- Content moderation → Intent classifier: classifies prompt (evidence: `mcp_server/tools/content_moderation.py`)
- Content moderation → Dataset evidence: queries categories (evidence: `mcp_server/tools/content_moderation.py`)
- Jailbreak detection → Intent classifier: classifies prompt (evidence: `mcp_server/tools/jailbreak_detection.py`)
- Jailbreak detection → Jailbreak patterns: checks patterns (evidence: `mcp_server/tools/jailbreak_detection.py`)
- Prompt analysis → Intent classifier: classifies prompt (evidence: `mcp_server/tools/prompt_analysis.py`)
- Prompt analysis → Dataset evidence: queries evidence (evidence: `mcp_server/tools/prompt_analysis.py`)
- Server manager → MCP server: starts server (evidence: `agent/server_manager.py`)
- LangGraph workflow → MCP agent nodes: dispatches nodes (evidence: `agent/graph.py`)
- MCP agent nodes → MCP client: calls MCP tools (evidence: `agent/nodes.py`)
