Hello to the Jsonnet community,
I would like to share an experimental project for creating a "live" architectural model called ProjectGraphAgent, and I think this is a fascinating example of using Jsonnet. What makes the system interesting for this group is that Jsonnet was chosen as the base technology based on direct recommendations from several LLMs (Gemini, Claude, GPT-4, Perplexity, Grok, DeeplSeek, Qwen) when I was thinking about this system and consulted with various LLMs.
The repository on GitHub:
https://github.com/LebedevIV/ProjectGraphAgentThe goal was to create a "living" architectural model of a software project — a single source of reliability that could be used primarily by AI agents to maintain architectural integrity. The system needed to identify the components, their relationships, and policies, and then audit the actual codebase according to that definition.
Why Jsonnet? Justification of AI.
I have familiarized AIs with the system requirements, requesting the best configuration language for this task, which will be used exclusively by AI agents without human intervention (or with minimal participation to fill in some input data). They invariably pointed to Jsonnet in comparison with YAML, XAML, Dhall, CUE, or even just JSON and other variants. In their reasoning, they identified several key advantages that make it ideal for this task.:
Declarative in nature: Ideal for determining the desired state or "fundamental truth" for the architecture of a project, without getting bogged down in imperative logic.
Modularity: The ability to import and structure a graph into logical parts (entities.jsonnet, relations.jsonnet, policies.jsonnet) was crucial for managing complexity.
Data Templating: Functions and templates are widely used to reduce boilerplate when defining hundreds of files and components, ensuring consistency.
Guaranteed JSON output: The important thing is that it compiles into pure, machine-readable JSON. This output is used directly by AI assistants and automation scripts that perform audits and commits.
How it works: Declared or not. Observed
The core of ProjectGraphAgent is the "Declared and Observed" paradigm:
Declared state: The entire architecture of the project is defined in files.jsonnet. This is a man-made "map" of the project.
Observable state: Simple adapters scan the actual file system to see what's really there.
Deviation detection: The system compares the two states and reports any deviation, instantly marking on the graph undocumented files or components that have been deleted but not updated.
Here is a simplified example of its structure:
// In graph_parts/templates.jsonnet
{
FileEntity(path, purpose, tags=[]) :: {
type: 'File',
path: path,
purpose: purpose,
tags: tags,
metadata: { timestamp: std.extVar('timestamp') }
}
}
// In project_graph.jsonnet
local templates = import 'graph_parts/templates.jsonnet';
{
entities: {
'package.json': templates.FileEntity(
path: 'package.json',
purpose: 'Defines project dependencies and scripts.',
tags: ['build', 'config']
),
'src/main.ts': templates.FileEntity(
path: 'src/main.ts',
purpose: 'The main entry point for the application.'
),
}
}
I am talking about this here because it is a practical, artificial intelligence-based confirmation of Jsonnet's capabilities in the field of system configuration and modeling. It's still in the early stages of alpha testing and is more of a hobby and a side project for me, but I think it's a powerful demonstration of the language's capabilities.I would be very interested to hear your thoughts, feedback, or suggestions on this use case.
Thank you,
Igor Lebedev