Skip to main content

Entity Extraction Schemas for Technical Codebases

A Pydantic and JSON Schema guide for software engineers on extracting nodes and relationships from GitHub repositories, Jira issues, and Slack threads.

Entity Extraction Schemas for Technical Codebases

Entity Extraction Schemas for Technical Codebases: Graph RAG Engineering

To construct a high-accuracy enterprise knowledge graph, Large Language Models (LLMs) must extract structured Entities (Nodes) and Relationships (Edges) from raw technical data streams (such as Git pull request diffs, Jira issue specifications, and Slack architecture discussions).

If an extraction schema is too loose, the knowledge graph becomes polluted with noisy, redundant nodes. If the schema is too rigid, critical implicit trade-offs are missed.

In this engineering guide, we share the exact Pydantic and JSON schemas used by Memora to extract structured graph topology from technical codebases.


πŸ’‘Key Insight

Schema Objective: Normalize raw text streams into typed entity nodes (Service, PullRequest, Developer, Bug) and semantic relationship edges (MODIFIED_BY, RESOLVES, DISCUSSED_IN, DEPENDS_ON).


Python Pydantic Extraction Schema

PYTHON
from enum import Enum
from typing import List, Dict, Any, Optional
from pydantic import BaseModel, Field

class NodeType(str, Enum):
    SERVICE = "Service"
    PULL_REQUEST = "PullRequest"
    DEVELOPER = "Developer"
    ISSUE = "Issue"
    DOCUMENT = "Document"
    SLACK_THREAD = "SlackThread"

class RelationType(str, Enum):
    MODIFIED_BY = "MODIFIED_BY"
    RESOLVES = "RESOLVES"
    DISCUSSED_IN = "DISCUSSED_IN"
    DEPENDS_ON = "DEPENDS_ON"
    AUTHORED_BY = "AUTHORED_BY"

class NodeSchema(BaseModel):
    id: str = Field(description="Normalized unique identifier (e.g., 'SRV_AUTH_API')")
    name: str = Field(description="Human readable name (e.g., 'Auth Service')")
    node_type: NodeType
    properties: Dict[str, Any] = Field(default_factory=dict, description="Metadata key-values")

class EdgeSchema(BaseModel):
    source_id: str = Field(description="Normalized ID of source node")
    target_id: str = Field(description="Normalized ID of target node")
    relation_type: RelationType
    confidence_score: float = Field(default=1.0, ge=0.0, le=1.0)
    timestamp: str = Field(description="ISO 8601 event timestamp")

class KnowledgeGraphExtractionPayload(BaseModel):
    extracted_nodes: List[NodeSchema]
    extracted_edges: List[EdgeSchema]

Essential Organizational Memory & AI Architecture

Explore Memora's foundational guides on Graph RAG, persistent AI memory, and automated knowledge discovery:

⚑ Token Cost & Savings Calculator β†’
Calculate 1M token context window waste vs Graph RAG
What is Organizational Memory? β†’
The complete enterprise context framework
Top 7 Glean Alternatives (2026) β†’
Compare enterprise AI search & Graph RAG platforms
MPC vs MCP in AI Explained β†’
Multi-Party Computation vs Model Context Protocol
LLM Memory Management Guide β†’
4-tier memory hierarchy for autonomous coding agents
Slack & Jira KM Automation β†’
Capture decisions passively with zero workflow friction
Model Context Protocol (MCP) Hub β†’
Connecting IDEs & AI agents to enterprise memory
Knowledge Loss ROI Calculator β†’
Calculate annual engineering context loss costs
MCP Server Security & CISO Guide β†’
Prevent prompt injection & tool privilege escalation
AI Screen Memory & Ambient Context β†’
Privacy-first local OCR capture for enterprise teams
Corporate Memory Glossary Definition β†’
Explicit vs tacit context & corporate amnesia prevention
Quick Knowledge Check

Why do standard vector search systems fail on complex technical context?

Was this article helpful?