# lightningralf/obsidian-calendar-plugin architecture

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

- Interactive diagram: https://gitdiagram.com/lightningralf/obsidian-calendar-plugin
- Repository: https://github.com/lightningralf/obsidian-calendar-plugin

## Overview

##### Component Breakdown

a. UI Layer Components (Purple):
- Calendar View Component (src/ui/Calendar.svelte)
- Modal Component (src/ui/modal.ts)
- File Menu Component (src/ui/fileMenu.ts)
- Data Source Components:
- Streak Source
- Tags Source
- Tasks Source
- Word Count Source

b. Core Logic Layer (Blue):
- Main Plugin Controller (src/main.ts)
- Settings Manager (src/settings.ts)
- View Controller (src/view.ts)
- Constants Manager (src/constants.ts)

c. I/O Layer (Green):
- Handlers:
- Daily Notes Handler
- Monthly Notes Handler
- Quarterly Notes Handler
- Weekly Notes Handler
- Yearly Notes Handler

##### Integration Points

External integration points:
- Obsidian API Connection
- File System Interface
- Template System Integration

##### Special Elements

Specific features mentioned in README:
- Word Count Visualization System
- Task Tracking System
- Date Navigation System
- Template Processing System

##### Technical Details

Annotations for:
- Svelte Components
- TypeScript Implementation
- CSS Customization Points
- Plugin Settings Interface

Key Considerations:

##### Plugin's integration with Obsidian
- Clear boundaries between plugin and host application
- API interaction points

##### Modular architecture
- Separate concerns between UI, logic, and I/O
- How different note types are handled

##### Features
- Calendar visualization
- Management
- Data source integration
- Customization options

##### State management
- How the stores.ts manages state
- Data flow between components

Use these visual conventions:
- Rounded rectangles for external systems

Remember to include a note about the test utilities (src/testUtils) as a separate section, showing how they support the main architecture but aren't part of the runtime system.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Styles
    classDef ui fill:#E6E6FA,stroke:#000
    classDef core fill:#ADD8E6,stroke:#000
    classDef io fill:#90EE90,stroke:#000
    classDef external fill:#FFE4B5,stroke:#000
    classDef test fill:#FFC0CB,stroke:#000

    %% UI Layer
    subgraph UI
        Calendar["Calendar View"]
        Modal["Modal Component"]
        FileMenu["File Menu"]
        
        subgraph DataSources
            Streak["Streak Source"]
            Tags["Tags Source"]
            Tasks["Tasks Source"]
            WordCount["Word Count Source"]
        end
        
        Stores["Store Management"]
        UIUtils["UI Utilities"]
    end

    %% Core Layer
    subgraph Core
        MainPlugin["Main Plugin Controller"]
        Settings["Settings Manager"]
        ViewController["View Controller"]
        Constants["Constants Manager"]
    end

    %% I/O Layer
    subgraph IO
        DailyNotes["Daily Notes Handler"]
        MonthlyNotes["Monthly Notes Handler"]
        QuarterlyNotes["Quarterly Notes Handler"]
        WeeklyNotes["Weekly Notes Handler"]
        YearlyNotes["Yearly Notes Handler"]
    end

    %% Testing Infrastructure
    subgraph Testing
        MockApp["Mock App"]
        TestSettings["Test Settings"]
        UIMocks["UI Mocks"]
    end

    %% External Systems
    ObsidianAPI["Obsidian API"]
    FileSystem["File System"]
    TemplateSystem["Template System"]

    %% Relationships
    Calendar --> MainPlugin
    Modal --> MainPlugin
    FileMenu --> MainPlugin
    DataSources --> Stores
    Stores --> MainPlugin
    MainPlugin --> Settings
    MainPlugin --> ViewController
    MainPlugin --> Constants
    ViewController --> IO
    IO --> FileSystem
    MainPlugin --> ObsidianAPI
    IO --> TemplateSystem

    %% Click Events
    click Calendar "https://github.com/lightningRalf/obsidian-calendar-plugin/blob/master/src/ui/Calendar.svelte"
    click Modal "https://github.com/lightningRalf/obsidian-calendar-plugin/blob/master/src/ui/modal.ts"
    click FileMenu "https://github.com/lightningRalf/obsidian-calendar-plugin/blob/master/src/ui/fileMenu.ts"
    click Streak "https://github.com/lightningRalf/obsidian-calendar-plugin/blob/master/src/ui/sources/streak.ts"
    click Tags "https://github.com/lightningRalf/obsidian-calendar-plugin/blob/master/src/ui/sources/tags.ts"
    click Tasks "https://github.com/lightningRalf/obsidian-calendar-plugin/blob/master/src/ui/sources/tasks.ts"
    click WordCount "https://github.com/lightningRalf/obsidian-calendar-plugin/blob/master/src/ui/sources/wordCount.ts"
    click Stores "https://github.com/lightningRalf/obsidian-calendar-plugin/blob/master/src/ui/stores.ts"
    click UIUtils "https://github.com/lightningRalf/obsidian-calendar-plugin/blob/master/src/ui/utils.ts"
    click MainPlugin "https://github.com/lightningRalf/obsidian-calendar-plugin/blob/master/src/main.ts"
    click Settings "https://github.com/lightningRalf/obsidian-calendar-plugin/blob/master/src/settings.ts"
    click ViewController "https://github.com/lightningRalf/obsidian-calendar-plugin/blob/master/src/view.ts"
    click Constants "https://github.com/lightningRalf/obsidian-calendar-plugin/blob/master/src/constants.ts"
    click DailyNotes "https://github.com/lightningRalf/obsidian-calendar-plugin/blob/master/src/io/dailyNotes.ts"
    click MonthlyNotes "https://github.com/lightningRalf/obsidian-calendar-plugin/blob/master/src/io/monthlyNotes.ts"
    click QuarterlyNotes "https://github.com/lightningRalf/obsidian-calendar-plugin/blob/master/src/io/quarterlyNotes.ts"
    click WeeklyNotes "https://github.com/lightningRalf/obsidian-calendar-plugin/blob/master/src/io/weeklyNotes.ts"
    click YearlyNotes "https://github.com/lightningRalf/obsidian-calendar-plugin/blob/master/src/io/yearlyNotes.ts"
    click MockApp "https://github.com/lightningRalf/obsidian-calendar-plugin/blob/master/src/testUtils/mockApp.ts"
    click TestSettings "https://github.com/lightningRalf/obsidian-calendar-plugin/blob/master/src/testUtils/settings.ts"
    click UIMocks "https://github.com/lightningRalf/obsidian-calendar-plugin/blob/master/src/ui/__mocks__/obsidian.ts"

    %% Styling
    class Calendar,Modal,FileMenu,Streak,Tags,Tasks,WordCount,Stores,UIUtils ui
    class MainPlugin,Settings,ViewController,Constants core
    class DailyNotes,MonthlyNotes,QuarterlyNotes,WeeklyNotes,YearlyNotes io
    class ObsidianAPI,FileSystem,TemplateSystem external
    class MockApp,TestSettings,UIMocks test
```
