feat: initial commit

This commit is contained in:
johannes committed 2026-07-26 11:42:17 +02:00
commit b802ff49ab
454 files changed
+52429

No files matched your search

@@ -0,0 +1,153 @@
# C4 Code Level — Agent Reference
Agent: `c4-code` | Model: haiku | Output: `c4-code-<name>.md`
## Purpose
Documents individual source code directories at the most granular C4 level. Captures every function, class, module, and dependency. Creates documentation that feeds into the Component level.
## Capabilities
- Directory structure analysis and file relationships
- Function/method signature extraction (parameters, return types, type hints)
- Class hierarchy and module export documentation
- Internal and external dependency mapping
- Design pattern and architectural pattern recognition
- Language-agnostic (Python, TypeScript, Java, Go, Rust, C#, Ruby, etc.)
- Mermaid diagram generation (classDiagram for OOP, flowchart for FP/procedural)
## Programming Paradigm → Diagram Type
| Code Style | Diagram | When |
| -------------------------------- | -------------------------------- | -------------------------------------------------- |
| OOP (classes, interfaces) | `classDiagram` | Inheritance, composition, interface implementation |
| FP (pure functions, pipelines) | `flowchart` | Data transformations, function composition |
| FP (modules with exports) | `classDiagram` with `<<module>>` | Module structure and dependencies |
| Procedural (structs + functions) | `classDiagram` | Data structures and associated functions |
| Mixed | Combination | Use multiple diagrams if needed |
## Workflow
1. Analyze directory structure (file relationships, module boundaries)
2. Extract all functions/classes/modules with complete signatures
3. Map all dependencies (internal and external)
4. Generate structured documentation following the template below
5. Add Mermaid diagrams for complex relationships
## Documentation Template
```markdown
# C4 Code Level: [Directory Name]
## Overview
- **Name**: [Descriptive name for this code directory]
- **Description**: [Short description of what this code does]
- **Location**: [Link to actual directory path]
- **Language**: [Primary programming language(s)]
- **Purpose**: [What this code accomplishes]
## Code Elements
### Functions/Methods
- `functionName(param1: Type, param2: Type): ReturnType`
- Description: [What this function does]
- Location: [file path:line number]
- Dependencies: [what this function depends on]
### Classes/Modules
- `ClassName`
- Description: [What this class does]
- Location: [file path]
- Methods: [list of methods]
- Dependencies: [what this class depends on]
## Dependencies
### Internal Dependencies
- [List of internal code dependencies]
### External Dependencies
- [List of external libraries, frameworks, services]
## Relationships
[Optional Mermaid diagram — see paradigm table above]
```
## OOP Diagram Example
```mermaid
---
title: Code Diagram for [Component Name]
---
classDiagram
namespace ComponentName {
class Class1 {
+attribute1 Type
+method1() ReturnType
}
class Interface1 {
<<interface>>
+requiredMethod() ReturnType
}
}
Class1 ..|> Interface1 : implements
```
## FP Module Structure Example
```mermaid
---
title: Module Structure for [Component Name]
---
classDiagram
namespace DataProcessing {
class validators {
<<module>>
+validateInput(data) Result~Data, Error~
+sanitize(input) string
}
class transformers {
<<module>>
+parseJSON(raw) Record
+normalize(data) NormalizedData
}
}
transformers --> validators : uses
```
## FP Data Flow Example
```mermaid
---
title: Data Pipeline for [Component Name]
---
flowchart LR
subgraph Input
A[readFile]
end
subgraph Transform
B[parseJSON]
C[validateInput]
D[normalize]
end
subgraph Output
E[writeFile]
end
A -->|raw string| B
B -->|parsed data| C
C -->|valid data| D
D -->|normalized| E
```
## Notes
- Analyze starting from the deepest directories upward
- Document every significant code element, not just public APIs
- Create one `c4-code-<directory-name>.md` file per analyzed directory
- This output feeds directly into the Component level agent
@@ -0,0 +1,121 @@
# C4 Component Level — Agent Reference
Agent: `c4-component` | Model: sonnet | Input: `c4-code-*.md` | Output: `c4-component-<name>.md` + index
## Purpose
Synthesizes C4 Code-level documentation into logical, well-bounded components. Defines component interfaces, maps relationships, and creates Component-level diagrams. Bridges code detail with deployment concerns (handled at Container level).
## Core Philosophy
Components represent logical groupings of code that work together to provide cohesive functionality. Boundaries should align with domain, technical, or organizational boundaries. Each component must have clear responsibilities and well-defined interfaces.
## Workflow
1. Review all `c4-code-*.md` files to understand code structure
2. Identify logical component boundaries (domain, technical, or organizational)
3. Define component names, descriptions, and responsibilities
4. List software features provided by each component
5. Link `c4-code-*.md` files to their containing components
6. Document component interfaces (APIs, protocols, data contracts)
7. Map dependencies and relationships between components
8. Generate Mermaid C4Component diagrams
9. Create master `c4-component.md` index with all components
## Documentation Template
```markdown
# C4 Component Level: [Component Name]
## Overview
- **Name**: [Component name]
- **Description**: [Short description of component purpose]
- **Type**: [Application, Service, Library, etc.]
- **Technology**: [Primary technologies used]
## Purpose
[Detailed description of what this component does and what problems it solves]
## Software Features
- [Feature 1]: [Description]
- [Feature 2]: [Description]
## Code Elements
This component contains the following code-level elements:
- [c4-code-file-1.md](./c4-code-file-1.md) - [Description]
- [c4-code-file-2.md](./c4-code-file-2.md) - [Description]
## Interfaces
### [Interface Name]
- **Protocol**: [REST/GraphQL/gRPC/Events/etc.]
- **Description**: [What this interface provides]
- **Operations**:
- `operationName(params): ReturnType` - [Description]
## Dependencies
### Components Used
- [Component Name]: [How it's used]
### External Systems
- [External System]: [How it's used]
## Component Diagram
[See diagram syntax below]
```
## Component Diagram Syntax
Use `C4Component` Mermaid syntax. Shows components **within a single container**:
```mermaid
C4Component
title Component Diagram for [Container Name]
Container_Boundary(container, "Container Name") {
Component(component1, "Component 1", "Type", "Description")
Component(component2, "Component 2", "Type", "Description")
ComponentDb(component3, "Component 3", "Database", "Description")
}
Container_Ext(externalContainer, "External Container", "Description")
System_Ext(externalSystem, "External System", "Description")
Rel(component1, component2, "Uses")
Rel(component2, component3, "Reads from and writes to")
Rel(component1, externalContainer, "Uses", "API")
```
## Master Index Template
```markdown
# C4 Component Level: System Overview
## System Components
### [Component 1]
- **Name**: [Component name]
- **Description**: [Short description]
- **Documentation**: [c4-component-name-1.md](./c4-component-name-1.md)
## Component Relationships
[Mermaid diagram showing all components and their relationships]
```
## Key Principles
- Focus on **logical grouping**, not deployment concerns (deferred to Container level)
- Component boundaries should reflect domain or technical cohesion
- Every component needs clear responsibilities and at least one defined interface
- This output feeds directly into the Container level agent
@@ -0,0 +1,275 @@
# C4 Container Level — Agent Reference
Agent: `c4-container` | Model: sonnet | Input: Component docs + deployment configs | Output: `c4-container.md` + OpenAPI specs
## Purpose
Maps logical components to deployment containers (processes, applications, services, databases). Documents container interfaces as OpenAPI/Swagger specs. Shows high-level technology choices and deployment architecture.
## Core Philosophy
Containers are deployable units that must be running for the system to work. Container diagrams show **high-level technology choices** and how responsibilities are distributed. Technology details belong here, not at Component or Context level.
## Workflow
1. Review all `c4-component-*.md` files to understand component structure
2. Review deployment definitions (Dockerfiles, K8s manifests, Terraform, cloud configs)
3. Map components to containers based on deployment reality
4. Identify container names, descriptions, and deployment characteristics
5. Create OpenAPI/Swagger specs for all container interfaces
6. Map inter-container communication (HTTP, gRPC, queues, events)
7. Generate Mermaid C4Container diagrams
8. Link container docs to API specs and deployment configs
## Documentation Template
```markdown
# C4 Container Level: System Deployment
## Containers
### [Container Name]
- **Name**: [Container name]
- **Description**: [Short description of container purpose and deployment]
- **Type**: [Web Application, API, Database, Message Queue, etc.]
- **Technology**: [Node.js, Python, PostgreSQL, Redis, etc.]
- **Deployment**: [Docker, Kubernetes, Cloud Service, etc.]
## Purpose
[Detailed description of what this container does and how it's deployed]
## Components
This container deploys the following components:
- [Component Name]: [Description]
- Documentation: [c4-component-name.md](./c4-component-name.md)
## Interfaces
### [API/Interface Name]
- **Protocol**: [REST/GraphQL/gRPC/Events/etc.]
- **Description**: [What this interface provides]
- **Specification**: [Link to OpenAPI/Swagger/API Spec file]
- **Endpoints**:
- `GET /api/resource` - [Description]
- `POST /api/resource` - [Description]
## Dependencies
### Containers Used
- [Container Name]: [How it's used, communication protocol]
### External Systems
- [External System]: [How it's used, integration type]
## Infrastructure
- **Deployment Config**: [Link to Dockerfile, K8s manifest, etc.]
- **Scaling**: [Horizontal/vertical scaling strategy]
- **Resources**: [CPU, memory, storage requirements]
## Container Diagram
[See diagram syntax below]
```
## Container Diagram Syntax
```mermaid
C4Container
title Container Diagram for [System Name]
Person(user, "User", "Uses the system")
System_Boundary(system, "System Name") {
Container(webApp, "Web Application", "Spring Boot, Java", "Provides web interface")
Container(api, "API Application", "Node.js, Express", "Provides REST API")
ContainerDb(database, "Database", "PostgreSQL", "Stores data")
Container_Queue(messageQueue, "Message Queue", "RabbitMQ", "Handles async messaging")
}
System_Ext(external, "External System", "Third-party service")
Rel(user, webApp, "Uses", "HTTPS")
Rel(webApp, api, "Makes API calls to", "JSON/HTTPS")
Rel(api, database, "Reads from and writes to", "SQL")
Rel(api, messageQueue, "Publishes messages to")
Rel(api, external, "Uses", "API")
```
## OpenAPI Spec Template
For each container API, create a specification file (e.g., `api-spec.yaml`):
```yaml
openapi: 3.1.0
info:
title: [Container Name] API
description: [API description]
version: 1.0.0
servers:
- url: https://api.example.com
description: Production server
paths:
/api/resource:
get:
summary: [Operation summary]
description: [Operation description]
responses:
'200':
description: [Response description]
content:
application/json:
schema:
type: object
```
## Key Principles
- This is where **technology details belong** in the C4 model
- Map based on deployment reality, not just logical grouping
- Every container interface should have an OpenAPI/Swagger spec
- Show communication protocols between containers
- Link to deployment configs (Dockerfiles, K8s manifests, etc.)
- This output feeds into the Context level agen# C4 Container Level — Agent Reference
Agent: `c4-container` | Model: sonnet | Input: Component docs + deployment configs | Output: `c4-container.md` + OpenAPI specs
## Purpose
Maps logical components to deployment containers (processes, applications, services, databases). Documents container interfaces as OpenAPI/Swagger specs. Shows high-level technology choices and deployment architecture.
## Core Philosophy
Containers are deployable units that must be running for the system to work. Container diagrams show **high-level technology choices** and how responsibilities are distributed. Technology details belong here, not at Component or Context level.
## Workflow
1. Review all `c4-component-*.md` files to understand component structure
2. Review deployment definitions (Dockerfiles, K8s manifests, Terraform, cloud configs)
3. Map components to containers based on deployment reality
4. Identify container names, descriptions, and deployment characteristics
5. Create OpenAPI/Swagger specs for all container interfaces
6. Map inter-container communication (HTTP, gRPC, queues, events)
7. Generate Mermaid C4Container diagrams
8. Link container docs to API specs and deployment configs
## Documentation Template
```markdown
# C4 Container Level: System Deployment
## Containers
### [Container Name]
- **Name**: [Container name]
- **Description**: [Short description of container purpose and deployment]
- **Type**: [Web Application, API, Database, Message Queue, etc.]
- **Technology**: [Node.js, Python, PostgreSQL, Redis, etc.]
- **Deployment**: [Docker, Kubernetes, Cloud Service, etc.]
## Purpose
[Detailed description of what this container does and how it's deployed]
## Components
This container deploys the following components:
- [Component Name]: [Description]
- Documentation: [c4-component-name.md](./c4-component-name.md)
## Interfaces
### [API/Interface Name]
- **Protocol**: [REST/GraphQL/gRPC/Events/etc.]
- **Description**: [What this interface provides]
- **Specification**: [Link to OpenAPI/Swagger/API Spec file]
- **Endpoints**:
- `GET /api/resource` - [Description]
- `POST /api/resource` - [Description]
## Dependencies
### Containers Used
- [Container Name]: [How it's used, communication protocol]
### External Systems
- [External System]: [How it's used, integration type]
## Infrastructure
- **Deployment Config**: [Link to Dockerfile, K8s manifest, etc.]
- **Scaling**: [Horizontal/vertical scaling strategy]
- **Resources**: [CPU, memory, storage requirements]
## Container Diagram
[See diagram syntax below]
```
## Container Diagram Syntax
```mermaid
C4Container
title Container Diagram for [System Name]
Person(user, "User", "Uses the system")
System_Boundary(system, "System Name") {
Container(webApp, "Web Application", "Spring Boot, Java", "Provides web interface")
Container(api, "API Application", "Node.js, Express", "Provides REST API")
ContainerDb(database, "Database", "PostgreSQL", "Stores data")
Container_Queue(messageQueue, "Message Queue", "RabbitMQ", "Handles async messaging")
}
System_Ext(external, "External System", "Third-party service")
Rel(user, webApp, "Uses", "HTTPS")
Rel(webApp, api, "Makes API calls to", "JSON/HTTPS")
Rel(api, database, "Reads from and writes to", "SQL")
Rel(api, messageQueue, "Publishes messages to")
Rel(api, external, "Uses", "API")
```
## OpenAPI Spec Template
For each container API, create a specification file (e.g., `api-spec.yaml`):
```yaml
openapi: 3.1.0
info:
title: [Container Name] API
description: [API description]
version: 1.0.0
servers:
- url: https://api.example.com
description: Production server
paths:
/api/resource:
get:
summary: [Operation summary]
description: [Operation description]
responses:
'200':
description: [Response description]
content:
application/json:
schema:
type: object
```
## Key Principles
- This is where **technology details belong** in the C4 model
- Map based on deployment reality, not just logical grouping
- Every container interface should have an OpenAPI/Swagger spec
- Show communication protocols between containers
- Link to deployment configs (Dockerfiles, K8s manifests, etc.)
- This output feeds into the Context level agent
@@ -0,0 +1,117 @@
# C4 Context Level — Agent Reference
Agent: `c4-context` | Model: sonnet | Input: Container/component docs + README + tests | Output: `c4-context.md`
## Purpose
Creates the highest-level C4 view: the system as a box surrounded by users and external systems. Focuses on **people and software systems**, not technologies. Produces stakeholder-friendly documentation understandable by non-technical audiences.
## Core Philosophy
Context diagrams show the system boundary, all users (human and programmatic), and all external systems the system interacts with. Technology, protocols, and low-level details are deliberately excluded at this level.
## Workflow
1. Review `c4-container.md` to understand system deployment
2. Review `c4-component.md` to understand system components
3. Review system documentation (README, architecture docs, requirements)
4. Review test files to understand system behavior and features
5. Identify system purpose and boundaries
6. Identify all personas (human users AND programmatic users / external systems)
7. Identify all high-level features provided by the system
8. Map user journeys for each key feature per persona
9. Identify all external systems and dependencies
10. Generate Mermaid C4Context diagram
11. Create comprehensive context documentation
## Documentation Template
```markdown
# C4 Context Level: System Context
## System Overview
### Short Description
[One-sentence description of what the system does]
### Long Description
[Detailed description of the system's purpose, capabilities, and the problems it solves]
## Personas
### [Persona Name]
- **Type**: [Human User / Programmatic User / External System]
- **Description**: [Who this persona is and what they need]
- **Goals**: [What this persona wants to achieve]
- **Key Features Used**: [List of features this persona uses]
## System Features
### [Feature Name]
- **Description**: [What this feature does]
- **Users**: [Which personas use this feature]
- **User Journey**: [Link to user journey map]
## User Journeys
### [Feature Name] - [Persona Name] Journey
1. [Step 1]: [Description]
2. [Step 2]: [Description]
3. [Step 3]: [Description]
### [External System] Integration Journey
1. [Step 1]: [Description]
2. [Step 2]: [Description]
## External Systems and Dependencies
### [External System Name]
- **Type**: [Database, API, Service, Message Queue, etc.]
- **Description**: [What this external system provides]
- **Integration Type**: [API, Events, File Transfer, etc.]
- **Purpose**: [Why the system depends on this]
## System Context Diagram
[See diagram syntax below]
## Related Documentation
- [Container Documentation](./c4-container.md)
- [Component Documentation](./c4-component.md)
```
## Context Diagram Syntax
```mermaid
C4Context
title System Context Diagram
Person(user, "User", "Uses the system to accomplish their goals")
System(system, "System Name", "Provides features X, Y, and Z")
System_Ext(external1, "External System 1", "Provides service A")
System_Ext(external2, "External System 2", "Provides service B")
SystemDb(externalDb, "External Database", "Stores data")
Rel(user, system, "Uses")
Rel(system, external1, "Uses", "API")
Rel(system, external2, "Sends events to")
Rel(system, externalDb, "Reads from and writes to")
```
## Key Principles
- Focus on **people and software systems**, not technologies or protocols
- Show the **system boundary** clearly (what's inside vs. outside)
- Include **all users**: human and programmatic (external systems that call the system are also "users")
- Include all **external systems** the system interacts with
- Keep it **stakeholder-friendly** — avoid implementation details
- Document **user journeys** for each key feature and persona
- This is the final step of the C4 documentation chain