# piqoni/matcha architecture

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

- Interactive diagram: https://gitdiagram.com/piqoni/matcha
- Repository: https://github.com/piqoni/matcha

## Overview

##### Main Components Identification

a. Core Components:
- Feed Processor (feeds_writer.go)
- Markdown Generator (markdown_writer.go)
- Terminal Output System (terminal_writer.go)
- Weather Service Integration (weather.go)
- OPML Handler (opml.go)
- Summarization Service (summarize.go)

b. External Services:
- RSS Feeds
- OpenAI API / LocalAI
- Weather API (YR)
- Instapaper
- Google News

**┌─ Input Sources ─────┐  ┌─ External Services ─┐**
- RSS Feeds        │  │ - OpenAI/LocalAI    │
- OPML Files      │  │ - Weather API       │
- Google News     │  │ - Instapaper        │
- ┘  └──────────────────────┘
- ↓                       ↕
**┌─ Core Processing ──────────────────────────┐**
- ┌─ Feed Processing ─┐ ┌─ Content Gen ───┐ │
- Feed Fetching   │ │ - Markdown Gen  │ │
- OPML Parsing    │ │ - Terminal Out  │ │
- Article Filter  │ │ - Summarization │ │
- ┘ └───────────────────┘ │
- ┘
- ↓
**┌─ Output Formats ────────────────────────────┐**
- Daily Digest Markdown Files              │
- Terminal Output                          │
- ┘

##### Important Details

a. Configuration Flow:
- How config.yaml influences the system
- Optional configurations (OpenAI API, weather, etc.)

b. Processing Pipeline:
- Demonstrate the daily digest generation flow
- How article filtering works (avoiding duplicates)
- Where summarization occurs in the pipeline

c. Integration Points:
- API connections to external services
- Error handling and fallback paths

##### Technical Details to Highlight
- Go-based implementation
- File-system interactions
- API integrations
- Configuration management
- Output format handling

Remember to indicate the extensibility points where new features could be added (like new output formats or input sources) and show the clear separation between the core processing logic and the various I/O operations.

This system design should help developers understand both the current implementation and potential areas for future enhancement or modification.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Style Definitions
    classDef input fill:#a8d1ff,stroke:#333
    classDef external fill:#ffd7a8,stroke:#333
    classDef core fill:#a8ffc1,stroke:#333
    classDef output fill:#e6a8ff,stroke:#333
    classDef config fill:#f2f2f2,stroke:#333

    %% Input Sources Layer
    subgraph InputLayer["Input Sources"]
        RSS["RSS Feeds"]:::input
        OPML["OPML Files"]:::input
        GNews["Google News"]:::input
    end

    %% External Services Layer
    subgraph ExternalLayer["External Services"]
        AI["OpenAI/LocalAI"]:::external
        Weather["Weather API (YR)"]:::external
        Instapaper["Instapaper"]:::external
    end

    %% Core Processing Layer
    subgraph CoreLayer["Core Processing"]
        Config["Configuration Manager"]:::config
        
        subgraph FeedProc["Feed Processing"]
            FeedProcessor["Feed Processor"]:::core
            OPMLHandler["OPML Handler"]:::core
            ArticleFilter["Article Filter"]:::core
        end
        
        subgraph ContentGen["Content Generation"]
            MarkdownGen["Markdown Generator"]:::core
            TerminalOut["Terminal Output"]:::core
            Summarizer["Summarization Service"]:::core
        end
    end

    %% Output Layer
    subgraph OutputLayer["Output Formats"]
        DigestFiles["Daily Digest Markdown"]:::output
        TerminalDisplay["Terminal Display"]:::output
    end

    %% Connections
    RSS --> FeedProcessor
    OPML --> OPMLHandler
    GNews --> FeedProcessor
    
    OPMLHandler --> FeedProcessor
    FeedProcessor --> ArticleFilter
    ArticleFilter --> MarkdownGen
    ArticleFilter --> Summarizer
    
    Summarizer --> AI
    Weather --> MarkdownGen
    Instapaper --> ArticleFilter
    
    MarkdownGen --> DigestFiles
    TerminalOut --> TerminalDisplay
    
    Config --> FeedProc
    Config --> ContentGen

    %% Click Events
    click FeedProcessor "https://github.com/piqoni/matcha/blob/main/feeds_writer.go"
    click MarkdownGen "https://github.com/piqoni/matcha/blob/main/markdown_writer.go"
    click TerminalOut "https://github.com/piqoni/matcha/blob/main/terminal_writer.go"
    click Weather "https://github.com/piqoni/matcha/blob/main/weather.go"
    click OPMLHandler "https://github.com/piqoni/matcha/blob/main/opml.go"
    click Summarizer "https://github.com/piqoni/matcha/blob/main/summarize.go"
    click Config "https://github.com/piqoni/matcha/blob/main/config.go"

    %% Legend
    subgraph Legend["Legend"]
        L1["Input Sources"]:::input
        L2["External Services"]:::external
        L3["Core Components"]:::core
        L4["Output Formats"]:::output
        L5["Configuration"]:::config
    end
```
