# janecea/argparser architecture

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

- Interactive diagram: https://gitdiagram.com/janecea/argparser
- Repository: https://github.com/janecea/argparser

## Overview

ArgParser is a declarative .NET CLI parsing library. A consumer defines a `BaseArgs` type with attributes, creates a parser through the factory, and passes command-line tokens to `Parse`; the result is a populated typed argument object, or a parsing/help exception. Construction reflects and validates the declaration, then prepares metadata used to couple tokens, parse values, enforce requirements and validators, and assign results. Help generation and the Roslyn attribute-usage analyzer are additional capabilities. Edges reflect the excerpts, SOURCE INDEX references, or README; unsampled analyzer internals and other implementation details are not inferred.

Main entry points: [`src/ArgParser/ArgParser.cs`](https://github.com/janecea/argparser/blob/main/src/ArgParser/ArgParser.cs) (Parser entry point), [`src/ArgParser/ArgParserFactory.cs`](https://github.com/janecea/argparser/blob/main/src/ArgParser/ArgParserFactory.cs) (Parser factory), [`src/ArgParser/Internal/Metadata/PropertyMetadata.cs`](https://github.com/janecea/argparser/blob/main/src/ArgParser/Internal/Metadata/PropertyMetadata.cs) (Property metadata), [`src/ArgParser/Internal/CommandLine/CoupledArgs.cs`](https://github.com/janecea/argparser/blob/main/src/ArgParser/Internal/CommandLine/CoupledArgs.cs) (Token coupling)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["Declaration and API"]
  node_args["Argument model<br/>[BaseArgs.cs]"]
  node_attributes["Declaration attributes"]
  node_factory["Parser factory"]
end

subgraph group_metadata["Configuration metadata"]
  node_classmeta["Class metadata"]
  node_propertymeta["Property metadata"]
  node_metavalidator["Configuration validation"]
  node_processedmeta["Runtime metadata"]
end

subgraph group_runtime["Parsing runtime"]
  node_parser["Parser entry point<br/>[ArgParser.cs]"]
  node_exceptions["Parser exceptions"]
  node_coupling["Token coupling<br/>[CoupledArgs.cs]"]
  node_standards["CLI conventions<br/>[CliStandards.cs]"]
  node_valueparser["Value conversion<br/>[ValueParser.cs]"]
  node_validation["Input validation"]
  node_help["Help generation"]
end

subgraph group_analysis["Compile-time analysis"]
  node_analyzer["Attribute usage analyzer"]
  node_analyzercontracts["Analyzer contracts<br/>[Abstractions.cs]"]
end

node_consumer(("CLI consumer"))
node_compiler(("Roslyn compiler"))

node_consumer -->|"declares"| node_args
node_consumer -->|"creates parser"| node_factory
node_factory -->|"reflects type"| node_classmeta
node_classmeta -->|"builds properties"| node_propertymeta
node_factory -->|"validates declaration"| node_metavalidator
node_metavalidator -->|"checks properties"| node_propertymeta
node_factory -->|"prepares runtime metadata"| node_processedmeta
node_factory -->|"configures help"| node_help
node_consumer -->|"passes tokens"| node_parser
node_parser -->|"groups tokens"| node_coupling
node_coupling -->|"looks up names"| node_processedmeta
node_coupling -->|"uses conventions"| node_standards
node_parser -->|"checks occurrences"| node_validation
node_parser -->|"converts values"| node_valueparser
node_valueparser -->|"reads type policy"| node_propertymeta
node_parser -->|"reads parse metadata"| node_processedmeta
node_parser -->|"populates result"| node_args
node_parser -->|"signals failures"| node_exceptions
node_parser -->|"returns help"| node_help
node_attributes -->|"supplies declarations"| node_classmeta
node_attributes -->|"supplies property settings"| node_propertymeta
node_compiler -->|"runs analysis"| node_analyzer
node_analyzer -->|"uses contracts"| node_analyzercontracts

click node_args "https://github.com/janecea/argparser/blob/main/src/ArgParser/BaseArgs.cs"
click node_attributes "https://github.com/janecea/argparser/tree/main/src/ArgParser/Attributes"
click node_factory "https://github.com/janecea/argparser/blob/main/src/ArgParser/ArgParserFactory.cs"
click node_parser "https://github.com/janecea/argparser/blob/main/src/ArgParser/ArgParser.cs"
click node_exceptions "https://github.com/janecea/argparser/blob/main/src/ArgParser/Exceptions/CommandLineParsingException.cs"
click node_classmeta "https://github.com/janecea/argparser/blob/main/src/ArgParser/Internal/Metadata/ArgsClassMetadata.cs"
click node_propertymeta "https://github.com/janecea/argparser/blob/main/src/ArgParser/Internal/Metadata/PropertyMetadata.cs"
click node_metavalidator "https://github.com/janecea/argparser/blob/main/src/ArgParser/Internal/Metadata/MetadataValidator.cs"
click node_processedmeta "https://github.com/janecea/argparser/blob/main/src/ArgParser/Internal/Metadata/ProcessedClassMetadata.cs"
click node_coupling "https://github.com/janecea/argparser/blob/main/src/ArgParser/Internal/CommandLine/CoupledArgs.cs"
click node_standards "https://github.com/janecea/argparser/blob/main/src/ArgParser/Internal/CliStandards.cs"
click node_valueparser "https://github.com/janecea/argparser/blob/main/src/ArgParser/Internal/CommandLine/ValueParser.cs"
click node_validation "https://github.com/janecea/argparser/blob/main/src/ArgParser/Internal/CommandLine/CommandLineValidator.cs"
click node_help "https://github.com/janecea/argparser/blob/main/src/ArgParser/Internal/HelpMessageGenerator.cs"
click node_analyzer "https://github.com/janecea/argparser/blob/main/src/analyzers/ArgParser.Analyzers/AttributeUsageAnalyzer.cs"
click node_analyzercontracts "https://github.com/janecea/argparser/blob/main/src/analyzers/ArgParser.Analyzers.Abstractions/Abstractions.cs"

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_args,node_attributes,node_factory toneBlue
class node_classmeta,node_propertymeta,node_metavalidator,node_processedmeta toneAmber
class node_parser,node_exceptions,node_coupling,node_standards,node_valueparser,node_validation,node_help toneMint
class node_analyzer,node_analyzercontracts toneRose
class node_consumer,node_compiler toneIndigo
```

## Components

### Declaration and API

- [Argument model](https://github.com/janecea/argparser/blob/main/src/ArgParser/BaseArgs.cs): `src/ArgParser/BaseArgs.cs`
- [Declaration attributes](https://github.com/janecea/argparser/tree/main/src/ArgParser/Attributes): `src/ArgParser/Attributes`
- [Parser factory](https://github.com/janecea/argparser/blob/main/src/ArgParser/ArgParserFactory.cs): `src/ArgParser/ArgParserFactory.cs`

### Configuration metadata

- [Class metadata](https://github.com/janecea/argparser/blob/main/src/ArgParser/Internal/Metadata/ArgsClassMetadata.cs): `src/ArgParser/Internal/Metadata/ArgsClassMetadata.cs`
- [Property metadata](https://github.com/janecea/argparser/blob/main/src/ArgParser/Internal/Metadata/PropertyMetadata.cs): `src/ArgParser/Internal/Metadata/PropertyMetadata.cs`
- [Configuration validation](https://github.com/janecea/argparser/blob/main/src/ArgParser/Internal/Metadata/MetadataValidator.cs): `src/ArgParser/Internal/Metadata/MetadataValidator.cs`
- [Runtime metadata](https://github.com/janecea/argparser/blob/main/src/ArgParser/Internal/Metadata/ProcessedClassMetadata.cs): `src/ArgParser/Internal/Metadata/ProcessedClassMetadata.cs`

### Parsing runtime

- [Parser entry point](https://github.com/janecea/argparser/blob/main/src/ArgParser/ArgParser.cs): `src/ArgParser/ArgParser.cs`
- [Parser exceptions](https://github.com/janecea/argparser/blob/main/src/ArgParser/Exceptions/CommandLineParsingException.cs): `src/ArgParser/Exceptions/CommandLineParsingException.cs`
- [Token coupling](https://github.com/janecea/argparser/blob/main/src/ArgParser/Internal/CommandLine/CoupledArgs.cs): `src/ArgParser/Internal/CommandLine/CoupledArgs.cs`
- [CLI conventions](https://github.com/janecea/argparser/blob/main/src/ArgParser/Internal/CliStandards.cs): `src/ArgParser/Internal/CliStandards.cs`
- [Value conversion](https://github.com/janecea/argparser/blob/main/src/ArgParser/Internal/CommandLine/ValueParser.cs): `src/ArgParser/Internal/CommandLine/ValueParser.cs`
- [Input validation](https://github.com/janecea/argparser/blob/main/src/ArgParser/Internal/CommandLine/CommandLineValidator.cs): `src/ArgParser/Internal/CommandLine/CommandLineValidator.cs`
- [Help generation](https://github.com/janecea/argparser/blob/main/src/ArgParser/Internal/HelpMessageGenerator.cs): `src/ArgParser/Internal/HelpMessageGenerator.cs`

### Compile-time analysis

- [Attribute usage analyzer](https://github.com/janecea/argparser/blob/main/src/analyzers/ArgParser.Analyzers/AttributeUsageAnalyzer.cs): `src/analyzers/ArgParser.Analyzers/AttributeUsageAnalyzer.cs`
- [Analyzer contracts](https://github.com/janecea/argparser/blob/main/src/analyzers/ArgParser.Analyzers.Abstractions/Abstractions.cs): `src/analyzers/ArgParser.Analyzers.Abstractions/Abstractions.cs`

### Other components

- **CLI consumer**
- **Roslyn compiler**

## Connections

- CLI consumer → Argument model: declares (evidence: `README.md`)
- CLI consumer → Parser factory: creates parser (evidence: `README.md`)
- Parser factory → Class metadata: reflects type (evidence: `src/ArgParser/ArgParserFactory.cs`)
- Class metadata → Property metadata: builds properties (evidence: `src/ArgParser/Internal/Metadata/ArgsClassMetadata.cs`)
- Parser factory → Configuration validation: validates declaration (evidence: `src/ArgParser/ArgParserFactory.cs`)
- Configuration validation → Property metadata: checks properties (evidence: `src/ArgParser/Internal/Metadata/MetadataValidator.cs`)
- Parser factory → Runtime metadata: prepares runtime metadata (evidence: `src/ArgParser/ArgParserFactory.cs`)
- Parser factory → Help generation: configures help (evidence: `src/ArgParser/ArgParserFactory.cs`)
- CLI consumer → Parser entry point: passes tokens (evidence: `README.md`)
- Parser entry point → Token coupling: groups tokens (evidence: `src/ArgParser/ArgParser.cs`)
- Token coupling → Runtime metadata: looks up names (evidence: `src/ArgParser/Internal/CommandLine/CoupledArgs.cs`)
- Token coupling → CLI conventions: uses conventions (evidence: `src/ArgParser/Internal/CommandLine/CoupledArgs.cs`)
- Parser entry point → Input validation: checks occurrences (evidence: `src/ArgParser/ArgParser.cs`)
- Parser entry point → Value conversion: converts values (evidence: `src/ArgParser/ArgParser.cs`)
- Value conversion → Property metadata: reads type policy (evidence: `src/ArgParser/Internal/CommandLine/ValueParser.cs`)
- Parser entry point → Runtime metadata: reads parse metadata (evidence: `src/ArgParser/ArgParser.cs`)
- Parser entry point → Argument model: populates result (evidence: `src/ArgParser/ArgParser.cs`)
- Parser entry point → Parser exceptions: signals failures (evidence: `src/ArgParser/ArgParser.cs`)
- Parser entry point → Help generation: returns help (evidence: `src/ArgParser/ArgParser.cs`)
- Declaration attributes → Class metadata: supplies declarations (evidence: `src/ArgParser/Internal/Metadata/ArgsClassMetadata.cs`)
- Declaration attributes → Property metadata: supplies property settings (evidence: `src/ArgParser/Internal/Metadata/PropertyMetadata.cs`)
- Roslyn compiler → Attribute usage analyzer: runs analysis (evidence: `README.md`)
- Attribute usage analyzer → Analyzer contracts: uses contracts (evidence: `src/analyzers/ArgParser.Analyzers/AttributeUsageAnalyzer.cs`)
