How neozenith/injinja works
Project Type & Purpose
• Type: A Python-based CLI tool / library for “injectable” Jinja2 configuration templating.
• Purpose:
– Gather dynamic inputs (env flags, files)
– Load & template many small config files (YAML/JSON/TOML)
– Deep-merge them into one dict
– Render a target Jinja template with that merged config
– Optionally validate or output intermediate merged config
Top-Level Components
A. CLI Front-End (src/injinja/__main__.py)
B. Argument Parser & Dispatcher
C. Dynamic Config Collector
• Reads --env flags, optional .env files, prefix filtering
• Produces an in-memory dict
D. Static Config Collector
• Reads one or more config globs or explicit file paths
• Parses JSON/YAML/TOML, honors override ordering
• Produces a list of rendered dicts (each config file is itself a Jinja template)
E. Merger
• Uses deepmerge.always_merger to recursively combine dicts
• Result: merged_config (dict)
F. Template Renderer
• Loads the Jinja template file
• Renders it using merged_config
• Produces final_output (string or file)
G. Output & Validation
• Writes to stdout or output file
• If ‑-output config-json/yaml: serializes merged_config
• If ‑-validate: difflib diff against expectation file
External Dependencies & Data Stores
• File System (config files, templates, validation files)
• Environment Variables
• Jinja2 library
• deepmerge library
• Parsers: PyYAML, json, toml
Relationships & Interactions
• CLI Front-End calls Argument Parser
• Arg Parser fans out to Dynamic & Static Config Collectors in parallel
• Both collectors feed into the Merger
• Merger feeds the Template Renderer
• Renderer outputs final text, which then goes to Output subsystem
• If validation is requested, branch to the Validation module to produce a diff
Important Patterns & Principles
• Pipeline pattern: small independent stages chained by data flow
• Convention-over-configuration: config files treated uniformly as Jinja templates
• Deep immutable merge: ordering of flags determines override semantics