The Code Graph System uses a property graph model with typed nodes and relationships. Each node represents a code entity (file, class, function, etc.), and edges represent relationships between them (imports, calls, renders, etc.).
Represents a source code file.
(:File {
id: String, // Unique identifier
path: String, // Absolute file path
name: String, // Filename with extension
extension: String, // File extension (.ts, .tsx, .php, etc.)
size: Integer // File size in bytes
})Represents a filesystem directory.
(:Directory {
id: String, // Unique identifier
path: String, // Absolute directory path
name: String // Directory name
})React functional or class component.
(:ReactComponent {
id: String, // Unique identifier
name: String, // Component name
file_path: String, // Source file path
line_number: Integer,// Definition line
type: "ReactComponent",
is_default_export: Boolean,
has_props: Boolean,
has_state: Boolean
})TypeScript/JavaScript function.
(:TSFunction {
id: String,
name: String,
file_path: String,
line_number: Integer,
type: "TSFunction",
is_async: Boolean,
is_generator: Boolean,
is_arrow: Boolean,
parameters_count: Integer
})TypeScript interface definition.
(:TSInterface {
id: String,
name: String,
file_path: String,
line_number: Integer,
type: "TSInterface",
is_exported: Boolean,
extends: String[] // Parent interfaces
})TypeScript type alias.
(:TSType {
id: String,
name: String,
file_path: String,
line_number: Integer,
type: "TSType",
is_exported: Boolean
})TypeScript/JavaScript class.
(:TSClass {
id: String,
name: String,
file_path: String,
line_number: Integer,
type: "TSClass",
is_abstract: Boolean,
extends: String, // Parent class
implements: String[] // Implemented interfaces
})Next.js API route handler.
(:APIRoute {
id: String,
name: String,
file_path: String,
line_number: Integer,
type: "APIRoute",
method: String, // GET, POST, PUT, DELETE, etc.
path: String // API endpoint path
})JSX/HTML element in React code.
(:JSXElement {
id: String,
name: String, // Element/Component name
file_path: String,
line_number: Integer,
type: "JSXElement",
is_component: Boolean // True if custom component
})PHP class definition.
(:PHPClass {
id: String,
name: String,
namespace: String,
file_path: String,
line_number: Integer,
type: "class",
is_abstract: Boolean,
is_final: Boolean
})PHP class method.
(:PHPMethod {
id: String,
name: String,
class_name: String,
file_path: String,
line_number: Integer,
type: "method",
visibility: String, // public, private, protected
is_static: Boolean
})Directory contains file or subdirectory.
(:Directory)-[:CONTAINS]->(:File|:Directory)One module imports another.
(:File|:Component)-[:IMPORTS {
alias: String, // Import alias if renamed
is_default: Boolean, // Default import
specifiers: String[] // Named imports
}]->(:File|:Component|:Function)Module exports a symbol.
(:File|:Component)-[:EXPORTS {
is_default: Boolean,
name: String
}]->(:Component|:Function|:Type)Component renders JSX element or another component.
(:ReactComponent)-[:RENDERS {
is_conditional: Boolean, // Inside if/ternary
is_mapped: Boolean // Inside map/loop
}]->(:JSXElement|:ReactComponent)Component has a prop type definition.
(:ReactComponent)-[:HAS_PROP {
name: String,
type: String, // TypeScript type
is_required: Boolean,
has_default: Boolean
}]->(:TSInterface|:TSType)Component uses state variable.
(:ReactComponent)-[:HAS_STATE {
name: String,
initial_value: String,
setter_name: String
}]->(:Variable)Function calls another function.
(:Function)-[:CALLS {
is_async_await: Boolean,
argument_count: Integer
}]->(:Function)Function returns a type or component.
(:Function)-[:RETURNS]->(:Type|:Component)General usage relationship.
(:Component|:Function)-[:USES]->(:Variable|:Constant|:Type)Class/interface extends another.
(:Class|:Interface)-[:EXTENDS]->(:Class|:Interface)Class implements interface.
(:Class)-[:IMPLEMENTS]->(:Interface)Creates instance of class.
(:Method)-[:INSTANTIATES]->(:Class)File defines a class/function.
(:File)-[:DEFINES]->(:Class|:Function)MATCH (c:ReactComponent)-[:RENDERS*1..3]->(e:JSXElement {name: 'Button'})
RETURN c.name, c.file_pathMATCH path = (m1)-[:IMPORTS*2..5]->(m1)
RETURN pathMATCH (c:ReactComponent)-[:EXPORTS]->()
WHERE NOT EXISTS(()-[:IMPORTS]->(c))
RETURN c.name, c.file_pathMATCH (c:ReactComponent)
WITH c, COUNT {(c)-[:RENDERS|USES|CALLS]->()} as dependencies
WHERE dependencies > 15
RETURN c.name, dependencies
ORDER BY dependencies DESCCurrent schema version: 1.0.0
- 1.0.0 - Initial schema with TypeScript/React/PHP support
When schema changes:
- Increment version in config
- Add migration script in
migrations/ - Update this documentation
- Test with existing databases