# mawkler/maconomy-cli architecture

> Architecture diagram of the GitHub repository mawkler/maconomy-cli, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-26). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/mawkler/maconomy-cli
- Repository: https://github.com/mawkler/maconomy-cli

## Overview

##### Main Components

a) Client-Side Components:
- CLI Interface Layer
- Domain Layer
- Infrastructure Layer
- Authentication Service
- HTTP Client

b) External Systems:
- Maconomy API
- SSO Authentication Service
- Browser (for authentication)
- File System (for config and cookie storage)

##### Architecture Pattern
The project follows a clean architecture pattern with clear separation of concerns, evident from the directory structure:
- Domain layer (core business logic)
- Infrastructure layer (external interactions)
- CLI layer (user interface)

**[User] → [CLI Layer] → [Domain Layer] → [Infrastructure Layer] → [External Systems]**

##### Important Details to Highlight

- Authentication flow through browser
- Cookie storage mechanism
- Configuration file interaction
- TimeSheet data flow
- Error handling paths

##### Specific Implementation Notes

Notes about:
- SSO authentication process
- Cookie management
- Config file location and format
- API interaction patterns

- Component types
- File locations
- Configuration requirements

This will create a comprehensive system design that accurately represents both the architectural patterns and the specific implementation details of this Maconomy CLI tool.

## Diagram (Mermaid)

```mermaid
%%{init: {
  'theme': 'base',
  'themeVariables': {
    'primaryColor': '#2b2b2b',
    'primaryTextColor': '#fff',
    'primaryBorderColor': '#7C0000',
    'lineColor': '#F8B229',
    'secondaryColor': '#006100',
    'tertiaryColor': '#0000ff'
  }
}}%%

flowchart TB
    classDef cli fill:#98FB98,stroke:#006400
    classDef domain fill:#ADD8E6,stroke:#0000A0
    classDef infra fill:#FFA07A,stroke:#8B4513
    classDef external fill:#D3D3D3,stroke:#696969
    classDef storage fill:#DEB887,stroke:#8B4513

    subgraph CLI["CLI Layer"]
        UI[CLI Interface]:::cli
        CMD[Command Processing]:::cli
        ARG[Argument Parsing]:::cli
        RENDER[UI Rendering]:::cli
        DPARSE[Date Parsing]:::cli
    end

    subgraph Domain["Domain Layer"]
        TS[TimeSheet Model]:::domain
        DAY[Day Model]:::domain
        WEEK[Week Model]:::domain
        HOURS[Hours Model]:::domain
        TSS[TimeSheet Service]:::domain
    end

    subgraph Infrastructure["Infrastructure Layer"]
        AUTH[Authentication Service]:::infra
        HTTP[HTTP Service]:::infra
        REPO[TimeSheet Repository]:::infra
        MCLIENT[Maconomy HTTP Client]:::infra
        
        subgraph Models["API Models"]
            TREG[Time Registration]:::infra
            SRESP[Search Response]:::infra
            TNAME[Task Name]:::infra
        end
    end

    subgraph External["External Systems"]
        MAPI[Maconomy API]:::external
        SSO[SSO Auth Service]:::external
        BROWSER[Browser]:::external
        
        subgraph Storage["Local Storage"]
            CONFIG[Config File]:::storage
            COOKIE[Cookie Storage]:::storage
        end
    end

    UI --> CMD
    UI --> ARG
    UI --> RENDER
    CMD --> DPARSE
    CMD --> TSS
    
    TSS --> TS
    TSS --> DAY
    TSS --> WEEK
    TSS --> HOURS
    
    TSS --> REPO
    REPO --> MCLIENT
    MCLIENT --> HTTP
    HTTP --> AUTH
    
    AUTH --> SSO
    AUTH --> BROWSER
    AUTH --> COOKIE
    
    REPO --> TREG
    REPO --> SRESP
    REPO --> TNAME
    
    HTTP --> MAPI
    TSS --> CONFIG

    %% Click events for component mapping
    click UI "https://github.com/mawkler/maconomy-cli/blob/main/src/cli/mod.rs"
    click CMD "https://github.com/mawkler/maconomy-cli/blob/main/src/cli/commands.rs"
    click ARG "https://github.com/mawkler/maconomy-cli/blob/main/src/cli/arguments.rs"
    click RENDER "https://github.com/mawkler/maconomy-cli/blob/main/src/cli/rendering.rs"
    click DPARSE "https://github.com/mawkler/maconomy-cli/blob/main/src/cli/day_parser.rs"
    click TS "https://github.com/mawkler/maconomy-cli/blob/main/src/domain/models/time_sheet.rs"
    click DAY "https://github.com/mawkler/maconomy-cli/blob/main/src/domain/models/day.rs"
    click WEEK "https://github.com/mawkler/maconomy-cli/blob/main/src/domain/models/week.rs"
    click HOURS "https://github.com/mawkler/maconomy-cli/blob/main/src/domain/models/hours.rs"
    click TSS "https://github.com/mawkler/maconomy-cli/blob/main/src/domain/time_sheet_service.rs"
    click AUTH "https://github.com/mawkler/maconomy-cli/blob/main/src/infrastructure/auth_service.rs"
    click HTTP "https://github.com/mawkler/maconomy-cli/blob/main/src/infrastructure/http_service.rs"
    click REPO "https://github.com/mawkler/maconomy-cli/blob/main/src/infrastructure/repositories/time_sheet_repository.rs"
    click MCLIENT "https://github.com/mawkler/maconomy-cli/blob/main/src/infrastructure/repositories/maconomy_http_client.rs"
    click TREG "https://github.com/mawkler/maconomy-cli/blob/main/src/infrastructure/models/time_registration.rs"
    click SRESP "https://github.com/mawkler/maconomy-cli/blob/main/src/infrastructure/models/search_response.rs"
    click TNAME "https://github.com/mawkler/maconomy-cli/blob/main/src/infrastructure/models/taskname.rs"
    click CONFIG "https://github.com/mawkler/maconomy-cli/blob/main/src/config/mod.rs"
```
