# johanwilfer/siephp architecture

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

- Interactive diagram: https://gitdiagram.com/johanwilfer/siephp
- Repository: https://github.com/johanwilfer/siephp

## Overview

##### Project type and purpose
- This is an open-source PHP library (not a full‐stack app) whose sole purpose is to export bookkeeping data into the Swedish SIE format (currently SIE4).
- Key indicators: a “src” folder containing domain/data classes, a “Dumper” component, examples, and no “frontend” or “backend” web folders.

##### File structure
- Top‐level artifacts
- composer.json / composer.lock – declares it as a PHP library
- src/SIE/Data – domain model classes (Company, Account, Transaction, Verification, etc.)
- src/SIE/Dumper – SIEDumper which turns a populated Company model into a text stream
- src/SIE/Exception – domain exceptions (validation errors)
- examples/ – consumer code showing how to build the model and call the dumper
- tests/ – PHPUnit tests covering Data and Dumper
- docker/, compose.yml – development containers for PHP 8.3–8.5
- CI config in .github/workflows – automated code checks
- Patterns: a clear separation between domain model, dumping logic, and usage examples/tests.

##### README for additional insights
- Confirms the library builds around simple data‐classes, then dumps to SIE.
- No runtime web/API server—pure in-process library.
- Example usage: create Company → add Accounts & VerificationSeries → add Verifications & Transactions → validate → dump.

##### Detail is key
- Every folder as a component if it plays a role (e.g., tests + CI)
- Future maintainers can glance at it and instantly see how data flows from client code into the SIE file via the model and dumper layers.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Consumer Layer
    subgraph "Consumer / Integration Layer"
        examples_simple["simple.php"]:::consumer
        examples_tsv["TSVtoSIE.php"]:::consumer
    end

    %% Domain Model Layer
    subgraph "Domain Model Layer"
        company["Company"]:::domain
        account["Account"]:::domain
        accbal["AccountBalance"]:::domain
        dimension["Dimension"]:::domain
        dimobj["DimensionObject"]:::domain
        fiscal["FiscalYear"]:::domain
        transaction["Transaction"]:::domain
        verification["Verification"]:::domain
        series["VerificationSeries"]:::domain
    end

    %% Exception Layer
    exception["DomainException"]:::exception

    %% Dumper Layer
    subgraph "Dumper Layer"
        siedumper["SIEDumper"]:::dumper
    end

    %% External Artifact
    external["SIE Text File"]:::external

    %% Development & CI Tools
    subgraph "Development & CI Tools"
        composer["composer.json / composer.lock"]:::dev
        dockerfiles["docker/dockerfile-siephp-php83\n/dockerfile-siephp-php84\n/dockerfile-siephp-php85"]:::dev
        compose["compose.yml"]:::dev
        tooling["phpstan.neon\nrector.php\necs.php"]:::dev
        ci[".github/workflows/code_checks.yaml"]:::dev
        phpunitconf["phpunit.xml.dist"]:::dev
    end

    %% Connections
    examples_simple -->|"build objects"| company
    examples_tsv -->|"build objects"| company
    company -->|"Company::validate() throws"| exception
    examples_simple -->|"calls SIEDumper::dump()"| siedumper
    examples_tsv -->|"calls SIEDumper::dump()"| siedumper
    siedumper -->|"generates SIE text"| external

    %% Click Events - Consumer
    click examples_simple "https://github.com/johanwilfer/siephp/blob/master/examples/simple.php"
    click examples_tsv "https://github.com/johanwilfer/siephp/blob/master/examples/TSVtoSIE.php"

    %% Click Events - Domain Model
    click company "https://github.com/johanwilfer/siephp/blob/master/src/SIE/Data/Company.php"
    click account "https://github.com/johanwilfer/siephp/blob/master/src/SIE/Data/Account.php"
    click accbal "https://github.com/johanwilfer/siephp/blob/master/src/SIE/Data/AccountBalance.php"
    click dimension "https://github.com/johanwilfer/siephp/blob/master/src/SIE/Data/Dimension.php"
    click dimobj "https://github.com/johanwilfer/siephp/blob/master/src/SIE/Data/DimensionObject.php"
    click fiscal "https://github.com/johanwilfer/siephp/blob/master/src/SIE/Data/FiscalYear.php"
    click transaction "https://github.com/johanwilfer/siephp/blob/master/src/SIE/Data/Transaction.php"
    click verification "https://github.com/johanwilfer/siephp/blob/master/src/SIE/Data/Verification.php"
    click series "https://github.com/johanwilfer/siephp/blob/master/src/SIE/Data/VerificationSeries.php"

    %% Click Events - Exception
    click exception "https://github.com/johanwilfer/siephp/blob/master/src/SIE/Exception/DomainException.php"

    %% Click Events - Dumper
    click siedumper "https://github.com/johanwilfer/siephp/blob/master/src/SIE/Dumper/SIEDumper.php"

    %% Click Events - Dev & CI
    click composer "https://github.com/johanwilfer/siephp/blob/master/composer.json"
    click composer "https://github.com/johanwilfer/siephp/blob/master/composer.lock"
    click dockerfiles "https://github.com/johanwilfer/siephp/tree/master/docker/dockerfile-siephp-php83"
    click dockerfiles "https://github.com/johanwilfer/siephp/tree/master/docker/dockerfile-siephp-php84"
    click dockerfiles "https://github.com/johanwilfer/siephp/tree/master/docker/dockerfile-siephp-php85"
    click compose "https://github.com/johanwilfer/siephp/blob/master/compose.yml"
    click tooling "https://github.com/johanwilfer/siephp/blob/master/phpstan.neon"
    click tooling "https://github.com/johanwilfer/siephp/blob/master/rector.php"
    click tooling "https://github.com/johanwilfer/siephp/blob/master/ecs.php"
    click ci "https://github.com/johanwilfer/siephp/blob/master/.github/workflows/code_checks.yaml"
    click phpunitconf "https://github.com/johanwilfer/siephp/blob/master/phpunit.xml.dist"

    %% Styles
    classDef domain fill:#cce5ff,stroke:#333,stroke-width:1px
    classDef dumper fill:#d4edda,stroke:#333,stroke-width:1px
    classDef consumer fill:#fff3cd,stroke:#333,stroke-width:1px
    classDef external fill:#e2e3e5,stroke:#333,stroke-width:1px
    classDef exception fill:#f8d7da,stroke:#333,stroke-width:1px
    classDef dev fill:#f0f0f0,stroke:#bbb,stroke-width:1px
```
