# drumato/peachcomb architecture

> Architecture diagram of the GitHub repository drumato/peachcomb, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-10). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/drumato/peachcomb
- Repository: https://github.com/drumato/peachcomb

## Overview

##### Project’s Core Components
- Library Core: Emphasize the "pkg" directory which contains the heart of the combinator library.
- pkg/combinator – Contains various combinator functions (sequence, alternate, separated, etc.) that govern the parsing logic.
- pkg/strparse – Handles parsing operations on string inputs.
- pkg/byteparse – Handles parsing operations on byte inputs.
- pkg/parser – Provides higher-level parser abstractions and utility functions including file streams.
- Examples: The “examples” directory demonstrates practical applications:
- examples/jsonparser – Demonstrates a JSON parser built using the combinator library.
- examples/custominput – Showcases usage with custom input types.
- Build/Dev Infrastructure: Although not part of the parsing logic, acknowledge:
- GitHub workflows and Dependabot configuration, Makefile, LICENSE, go.mod/go.sum which set up CI, dependency management, and build instructions.

- That parser functions built in strparse and byteparse serve as foundational building blocks that are then composed with combinators to form more complex parsing logic.
- That examples (e.g., JSON parser) depend on the library modules to assemble a fully functional parser, highlighting the data flow from input (raw string/byte data) to parsed output.

##### Architectural Patterns and Design Principles
- Modular Design: The separation into distinct packages (combinator, strparse, byteparse) indicates a clear modular architecture.
- Reusability and Composability: The combinator pattern allows the construction of complex parsers by composing smaller ones.
- Use of Go Generics: Note that the library leverages Go generics for type safety and flexibility, which underpins the parser function signatures.
- Test-Driven Structure: The file tree includes test files for nearly every component, underscoring an iterative, tested design.

##### Relevant Technologies and Naming Conventions
- Mention Go (Golang) as the primary language and Go modules as dependency management.
- Incorporate GitHub Actions (via .github/workflows) for CI/CD processes and Dependabot for dependency updates.
- Specify that the design should differentiate between library code (in pkg) and practical usage examples (in examples).

## Diagram (Mermaid)

```mermaid
graph TD
    %% Library Core
    subgraph "Library Core"
        strparse["pkg/strparse: String parser functions"] 
        byteparse["pkg/byteparse: Byte parser functions"]
        combinator["pkg/combinator: Combines parser functions"]
        parser["pkg/parser: Parser abstractions & utilities"]
    end

    %% Example Applications
    subgraph "Example Applications"
        jsonExample["JSON Parser Example"]
        customExample["Custom Input Parser"]
    end

    %% Build & Infrastructure
    subgraph "Build & Infrastructure"
        github["GitHub Workflows & Config"]
        builddefs["Build Definitions"]
    end

    %% Relationships and Data Flow
    strparse -->|"composition"| combinator
    byteparse -->|"composition"| combinator
    combinator -->|"orchestration"| parser
    parser -->|"utilizes"| jsonExample
    parser -->|"utilizes"| customExample

    %% Supporting Build Infrastructure (dotted arrows)
    github -.->|"CI/CD"| parser
    builddefs -.->|"build/dependency"| parser

    %% Click Events for Component Mapping
    click combinator "https://github.com/drumato/peachcomb/tree/main/pkg/combinator"
    click strparse "https://github.com/drumato/peachcomb/tree/main/pkg/strparse"
    click byteparse "https://github.com/drumato/peachcomb/tree/main/pkg/byteparse"
    click parser "https://github.com/drumato/peachcomb/tree/main/pkg/parser"
    click jsonExample "https://github.com/drumato/peachcomb/tree/main/examples/jsonparser"
    click customExample "https://github.com/drumato/peachcomb/tree/main/examples/custominput"
    click github "https://github.com/drumato/peachcomb/blob/main/.github"
    click builddefs "https://github.com/drumato/peachcomb/tree/main/Makefile"

    %% Styles for clear colour coding
    class strparse,byteparse,combinator,parser library
    class jsonExample,customExample example
    class github,builddefs infra

    %% Class Definitions
    classDef library fill:#c7f9cc,stroke:#333,stroke-width:2px;
    classDef example fill:#a9def9,stroke:#333,stroke-width:2px;
    classDef infra fill:#f7d6e0,stroke:#333,stroke-width:2px;
```
