# simplemobiletools/simple-calendar architecture

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

- Interactive diagram: https://gitdiagram.com/simplemobiletools/simple-calendar
- Repository: https://github.com/simplemobiletools/simple-calendar

## Overview

Based on our analysis of the file tree and README, Simple Calendar is an Android calendar application—a highly customizable, offline schedule and agenda planner with calendar widgets, event creation, reminders, and CalDAV sync capabilities. The project is organized as an Android app (using Kotlin) with clearly defined UI, business logic, data, and synchronization layers.

- UI Layer: This includes all activities, fragments, dialogs, adapters, and custom views. From the file structure, note components in:
– app/src/main/kotlin/com/simplemobiletools/calendar/pro/activities (e.g., MainActivity, EventActivity, SettingsActivity, etc.)
– fragments (DayFragment, MonthFragment, WeekFragment, YearFragment, etc.)
– dialogs (for event editing, reminders, custom repeat rules)
– adapters (managing lists for event types, calendar days, widget lists)
– custom views (MonthView, WeeklyViewGrid, etc.)
- Data Layer: Encapsulate the domain models and database management.
– Models (Event, EventType, Reminder, Task, etc. in app/src/main/kotlin/com/simplemobiletools/calendar/pro/models)
– Database components (EventsDatabase, DAOs under interfaces)
– Schema files (under app/schemas)
- Business Logic and Helper Layer: This handles the app’s core functionalities.
– Interfaces and objects (to abstract database operations, calendar synchronization, and configuration)
- Services and Background Processes:
– Android Services and receivers (MarkCompletedService, SnoozeService, BootCompletedReceiver, CalDAVUpdateListener, etc.)
– Job scheduling and syncing (CalDAV sync, automatic backups)
- External Integrations:
– CalDAV support for synchronizing with external calendar providers (Google Calendar, Outlook, etc.)
– ICS file import/export for sharing/synchronizing calendar data

##### Relationships and Interactions
- The UI layer communicates with the Business Logic layer:
– Activities and fragments receive user input and use adapters to update list views or widgets.
– Dialogs capture event details, which are then passed to helper classes for processing.
- The Business Logic layer interacts with the Data Layer:
– Helpers and DAOs make calls to the EventsDatabase to read or write event data.
– Models encapsulate the data exchanged between these components.
- The Services/Background Processes synchronize data:
– Services (like the CalDAV sync or backup receivers) update both the Business Logic and Data Layers.
– Widgets use dedicated providers (MyWidgetDateProvider, MyWidgetListProvider, etc.) to display calendar information based on database content.
- The External Integration component:
– CalDAV and ICS file handling act as bridges between external calendars and the internal data store.

##### Architectural Patterns and Design Principles
- Although not formally stated as an MVVM/MVP pattern in the file structure, the separation of activities/fragments (view layer), helper/service classes (business logic), and DAO/database files (data layer) suggests a form of layered architecture.
- There is a clear separation of concerns: UI handling is distinct from event processing and data management.
- The use of adapters, helper classes, and interfaces indicate extensibility and modularity.

##### Technologies and Tools
- Android, Kotlin, and the Android SDK form the backbone of the application.
- Gradle (with Kotlin DSL) is used for build management.
- Fastlane is employed for release automation and metadata management.
- CalDAV protocols and ICS format handling for calendar synchronization.
- Various Android resource qualifiers for localization and different screen sizes.

## Diagram (Mermaid)

```mermaid
graph TD

    %% UI Layer
    subgraph "UI Layer"
        UI_A("Activities"):::ui
        UI_F("Fragments"):::ui
        UI_D("Dialogs"):::ui
        UI_Ad("Adapters"):::ui
        UI_CV("Custom Views"):::ui
    end

    %% Business Logic / Helpers Layer
    subgraph "Business Logic / Helpers"
        LOGIC_H("Helpers"):::logic
        LOGIC_I("Interfaces"):::logic
    end

    %% Data Layer
    subgraph "Data Layer"
        DATA_M("Models"):::data
        DATA_DB("Database"):::data
    end

    %% Services & Background Processes
    subgraph "Services & Background"
        SERVICES_S("Services"):::services
        SERVICES_R("Receivers"):::services
    end

    %% External Integrations
    subgraph "External Integrations"
        EXT_C("CalDAV"):::ext
        EXT_IE("IcsExporter"):::ext
        EXT_II("IcsImporter"):::ext
        EXT_IA("ICS Assets"):::ext
    end

    %% Interactions between layers
    UI_A -->|"triggers"| LOGIC_H
    UI_F -->|"triggers"| LOGIC_H
    UI_D -->|"captures_events"| LOGIC_H
    UI_Ad -->|"displays_data"| LOGIC_H
    UI_CV -->|"renders_views"| LOGIC_H

    LOGIC_H -->|"CRUD_ops"| DATA_DB
    LOGIC_I -->|"DB_access"| DATA_DB
    LOGIC_I -->|"uses_models"| DATA_M

    SERVICES_S -->|"sync_update"| LOGIC_H
    SERVICES_S -->|"update_data"| DATA_DB
    SERVICES_R -->|"trigger_sync"| SERVICES_S

    EXT_C -->|"sync_data"| LOGIC_H
    EXT_IE -->|"export_import"| LOGIC_H
    EXT_II -->|"export_import"| LOGIC_H
    EXT_IA -->|"assets"| EXT_IE
    EXT_IA -->|"assets"| EXT_II

    %% Legend
    %% ui: Blue rectangles represent UI components.
    %% logic: Green rectangles represent Business Logic/Helper components.
    %% data: Yellow rectangles represent Data components.
    %% services: Orange rectangles represent Services/Background processes.
    %% ext: Purple rectangles represent External Integration components.

    classDef ui fill:#AED6F1,stroke:#1F618D,color:black;
    classDef logic fill:#A9DFBF,stroke:#196F3D,color:black;
    classDef data fill:#F9E79F,stroke:#B7950B,color:black;
    classDef services fill:#F5CBA7,stroke:#AF601A,color:black;
    classDef ext fill:#D6EAF8,stroke:#7D3C98,color:black;

click UI_A "https://github.com/simplemobiletools/simple-calendar/tree/master/app/src/main/kotlin/com/simplemobiletools/calendar/pro/activities"
click UI_F "https://github.com/simplemobiletools/simple-calendar/tree/master/app/src/main/kotlin/com/simplemobiletools/calendar/pro/fragments"
click UI_D "https://github.com/simplemobiletools/simple-calendar/tree/master/app/src/main/kotlin/com/simplemobiletools/calendar/pro/dialogs"
click UI_Ad "https://github.com/simplemobiletools/simple-calendar/tree/master/app/src/main/kotlin/com/simplemobiletools/calendar/pro/adapters"
click UI_CV "https://github.com/simplemobiletools/simple-calendar/tree/master/app/src/main/kotlin/com/simplemobiletools/calendar/pro/views"
click DATA_M "https://github.com/simplemobiletools/simple-calendar/tree/master/app/src/main/kotlin/com/simplemobiletools/calendar/pro/models"
click DATA_DB "https://github.com/simplemobiletools/simple-calendar/blob/master/app/src/main/kotlin/com/simplemobiletools/calendar/pro/databases/EventsDatabase.kt"
click LOGIC_H "https://github.com/simplemobiletools/simple-calendar/tree/master/app/src/main/kotlin/com/simplemobiletools/calendar/pro/helpers"
click LOGIC_I "https://github.com/simplemobiletools/simple-calendar/tree/master/app/src/main/kotlin/com/simplemobiletools/calendar/pro/interfaces"
click SERVICES_S "https://github.com/simplemobiletools/simple-calendar/tree/master/app/src/main/kotlin/com/simplemobiletools/calendar/pro/services"
click SERVICES_R "https://github.com/simplemobiletools/simple-calendar/tree/master/app/src/main/kotlin/com/simplemobiletools/calendar/pro/receivers"
click EXT_C "https://github.com/simplemobiletools/simple-calendar/blob/master/app/src/main/kotlin/com/simplemobiletools/calendar/pro/helpers/CalDAVHelper.kt"
click EXT_IE "https://github.com/simplemobiletools/simple-calendar/blob/master/app/src/main/kotlin/com/simplemobiletools/calendar/pro/helpers/IcsExporter.kt"
click EXT_II "https://github.com/simplemobiletools/simple-calendar/blob/master/app/src/main/kotlin/com/simplemobiletools/calendar/pro/helpers/IcsImporter.kt"
click EXT_IA "https://github.com/simplemobiletools/simple-calendar/tree/master/app/src/main/assets"
```
