# planetable/planet architecture

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

- Interactive diagram: https://gitdiagram.com/planetable/planet
- Repository: https://github.com/planetable/planet

## Overview

##### Project’s Core Purpose and Type
- Planet is a native macOS application built with SwiftUI.
- Its main objective is to allow users to publish blogs and follow web content in a decentralized manner using both IPFS (for peer-to-peer content distribution) and Ethereum Name Service (ENS) for content addressing.
- It works as a full-featured app with a built-in local IPFS node, content pinning, RSS reading, and various integrations (wallet, analytics, file handling).

##### Relationships & Data Flow
- How the UI components interact with the underlying business logic (e.g., views sending events to corresponding view models in “Views” and “Writer”).
- Use of the API layer (found under “Planet/API”) that includes services for authentication, logging, and control of the app’s web views.
- Integration with IPFS – for example, how the “IPFS” module handles starting/monitoring the local node and how content gets pinned and updated to IPNS.

##### Architectural Patterns & Design Principles
- Separation of concerns – clearly delineate between presentation (UI/SwiftUI views), business logic (entities, models, services), and integration layers (IPFS, ENS, Wallets).
- Dependency Injection & Communication – indicate probable use of view models and helpers that serve as intermediaries between UI and data sources.
- Peer-to-peer & decentralized architecture – mark the IPFS node and ENS interfaces as critical service blocks.

##### Final Assembly
- Notes for components such as “Key Manager”, “TemplateBrowser”, and “Labs” which provide extended functionalities (payments, wallet integration, dApps).
- Finally, be sure to capture the many supporting modules (e.g., Downloads, Quick Share, and various Views) by grouping them into common functional clusters.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% User Interface Layer
    subgraph "User Interface Layer"
        UI1["SwiftUI Views (Articles, Sidebar, My, Onboarding)"]:::ui
        UI2["Writer Module (WriterView, WriterViewModel)"]:::ui
    end

    %% Business Logic & Domain Layer
    subgraph "Business Logic & Domain Layer"
        BL1["Entities (ArticleModel, MyArticleModel, MyPlanetModel, etc.)"]:::logic
        BL2["Helpers (MarkdownUtils, HTTPRequest, KeychainHelper, Updater, etc.)"]:::logic
    end

    %% Integration & Service Layer
    subgraph "Integration & Service Layer"
        INT1["IPFS Integration (Local Node, Daemon, Status)"]:::integration
        INT2["ENS Integration"]:::integration
        INT3["External Integrations (Plausible, Filebase, etc.)"]:::integration
        INT3a["Wallet Integration"]:::integration
        INT4["API Layer (Authentication, Logging, Web Views)"]:::integration
    end

    %% Application Infrastructure
    subgraph "Application Infrastructure"
        INF1["App Entry & Config (PlanetApp, PlanetAppDelegate, xcconfig)"]:::infra
        INF2["Core Data Models (Planet.xcdatamodeld)"]:::infra
    end

    %% Optional/Specialized Versions
    subgraph "Optional/Specialized Versions"
        OPT1["PlanetLite Variant UI"]:::optional
    end

    %% Connections between layers
    UI1 -->|"triggers"| BL1
    UI2 -->|"triggers"| BL2

    BL1 -->|"calls"| INT4
    BL2 -->|"calls"| INT4

    BL1 -->|"uses"| INT1
    BL2 -->|"uses"| INT2
    BL2 -->|"integrates"| INT3
    BL2 -->|"integrates"| INT3a

    INT4 -->|"configures"| INF1

    OPT1 -->|"shares config with"| INF1

    %% Click Events
    click UI1 "https://github.com/planetable/planet/tree/main/Planet/Views"
    click UI2 "https://github.com/planetable/planet/tree/main/Planet/Writer"
    click BL1 "https://github.com/planetable/planet/tree/main/Planet/Entities"
    click BL2 "https://github.com/planetable/planet/tree/main/Planet/Helper"
    click INT1 "https://github.com/planetable/planet/tree/main/Planet/IPFS"
    click INT2 "https://github.com/planetable/planet/blob/main/Planet/Helper/ENSUtils.swift"
    click INT3 "https://github.com/planetable/planet/tree/main/Planet/Integrations"
    click INT3a "https://github.com/planetable/planet/tree/main/Planet/Labs/Wallet"
    click INT4 "https://github.com/planetable/planet/tree/main/Planet/API"
    click INF1 "https://github.com/planetable/planet/blob/main/Planet/PlanetApp.swift"
    click INF2 "https://github.com/planetable/planet/blob/main/Planet/Planet.xcdatamodeld"
    click OPT1 "https://github.com/planetable/planet/tree/main/PlanetLite/"

    %% Styles
    classDef ui fill:#cfe2f3,stroke:#000,stroke-width:1px;
    classDef logic fill:#d1e7dd,stroke:#000,stroke-width:1px;
    classDef integration fill:#fff3cd,stroke:#000,stroke-width:1px;
    classDef infra fill:#f8d7da,stroke:#000,stroke-width:1px;
    classDef optional fill:#e2e3e5,stroke:#000,stroke-width:1px;
```
