# matthewleigh/to-do-list architecture

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

- Interactive diagram: https://gitdiagram.com/matthewleigh/to-do-list
- Repository: https://github.com/matthewleigh/to-do-list

## Overview

##### Main Components

a. User Interface (UI) Layer:
- Activities: The project has at least two primary activities (MainActivity and ManageTaskActivity) in the “activities” package. These form the entry points for app interactions.
- Dialogs: There is a BottomSheetDialog indicating additional UI interactions (possibly for creating or editing tasks).

b. ViewModel Layer:
- ViewModel: The “TaskViewModel” in the “task” package manages the UI-related data, possibly interacting with the repository to fetch or update tasks.

c. Data/Domain Layer:
- Repository: The “TaskRepository” abstracts data operations and mediates between the ViewModel and lower-level data sources.
- Data Access Objects: “TaskDao” represents the data access interface for database operations.
- Database and Schema: The “AppDatabase” and “TaskTable” in the database and task packages define the database configuration and table structure. “AppDatabaseConverters” indicates handling of custom data types.

d. Support Components:
- Adapters: The “TaskAdapter” is used to bind data (tasks) to list views or recycler views.
- Testing: There are unit test and instrumented test directories to ensure component functionality.

##### Determining Relationships and Interactions

- UI components (Activities and Dialogs) initiate user actions.
- These activities interact with the TaskViewModel, which acts as a mediator between UI and data.
- The ViewModel calls the TaskRepository, which abstracts the database interactions.
- The repository uses TaskDao to perform CRUD operations on the AppDatabase.
- Data flows from the Database (persistent storage) back up through the Repository and ViewModel to refresh the UI.
- Resources such as layouts and drawables enhance the UI components’ visual integrity.

##### Architectural Patterns and Design Principles

- MVVM Pattern: The separation into Activities, ViewModel, and Repository/DAO indicates an MVVM implementation.
- Separation of Concerns: Each package is dedicated to a specific area (UI, data access, business logic), ensuring the code is modular and maintainable.
- Repository Pattern: The TaskRepository abstracts the data layer and decouples the data source from the UI.

##### Relevant Technologies, Frameworks, & Tools

- Android SDK: The project is built with Android’s API framework.
- Gradle: Build and dependency management using Gradle Kotlin DSL (build.gradle.kts).
- Room (implied): Given the database structure and DAOs, it is likely that Room or a similar ORM is used.
- Testing Frameworks: Android testing (instrumentation tests) and unit tests are part of the project.

##### Final Recommendations

- Every major package or functionality in the project is represented, so nothing crucial is omitted.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% UI Layer
    subgraph "UI Layer"
        UI1("MainActivity (Activity)"):::ui
        UI2("ManageTaskActivity (Activity)"):::ui
        UI3("BottomSheetDialog (Dialog)"):::ui
        UI4("Layouts & Resources (XML)"):::ui
    end

    %% ViewModel Layer
    subgraph "ViewModel Layer"
        VM("TaskViewModel"):::viewmodel
    end

    %% Data/Domain Layer
    subgraph "Data/Domain Layer"
        Repo("TaskRepository"):::domain
        DAO("TaskDao"):::domain
    end

    %% Database Layer
    subgraph "Database Layer"
        DB("AppDatabase"):::data
        Table("TaskTable"):::data
        Converters("AppDatabaseConverters"):::data
    end

    %% Support Components
    subgraph "Support Components"
        Adapter("TaskAdapter"):::support
    end

    %% External Dependencies
    subgraph "External Dependencies"
        Ext1("Android SDK"):::external
        Ext2("Gradle (Build System)"):::external
    end

    %% Relationships within UI Layer to ViewModel
    UI1 -->|"invokes"| VM
    UI2 -->|"invokes"| VM
    UI3 -->|"invokes"| VM
    UI1 -->|"loadsLayout"| UI4
    UI2 -->|"loadsLayout"| UI4
    UI1 -->|"bindsTasks"| Adapter

    %% ViewModel to Data/Domain Layer
    VM -->|"calls"| Repo

    %% Data/Domain Layer to Database Layer
    Repo -->|"accesses"| DAO
    DAO -->|"queries"| DB
    Converters -->|"convertsDataFor"| DB
    DB -->|"storesSchemaIn"| Table

    %% External Dependencies supporting UI
    Ext1 -->|"supports"| UI1
    Ext1 -->|"supports"| UI2
    Ext1 -->|"supports"| UI3
    Ext2 -->|"builds"| UI1
    Ext2 -->|"builds"| VM

    %% Classes Definitions for styling
    classDef ui fill:#AED6F1,stroke:#1F618D,stroke-width:2px;
    classDef viewmodel fill:#A2D9CE,stroke:#196F3D,stroke-width:2px;
    classDef domain fill:#F9E79F,stroke:#B7950B,stroke-width:2px;
    classDef data fill:#F5B7B1,stroke:#C0392B,stroke-width:2px;
    classDef support fill:#D7BDE2,stroke:#8E44AD,stroke-width:2px;
    classDef external fill:#D5DBDB,stroke:#7F8C8D,stroke-width:2px;

    %% Click Events
    click UI1 "https://github.com/matthewleigh/to-do-list/blob/main/app/src/main/java/com/example/todolist/activities/MainActivity.kt"
    click UI2 "https://github.com/matthewleigh/to-do-list/blob/main/app/src/main/java/com/example/todolist/activities/ManageTaskActivity.kt"
    click UI3 "https://github.com/matthewleigh/to-do-list/blob/main/app/src/main/java/com/example/todolist/dialogs/BottomSheetDialog.kt"
    click UI4 "https://github.com/matthewleigh/to-do-list/tree/main/app/src/main/res/layout"
    click VM "https://github.com/matthewleigh/to-do-list/blob/main/app/src/main/java/com/example/todolist/task/TaskViewModel.kt"
    click Repo "https://github.com/matthewleigh/to-do-list/blob/main/app/src/main/java/com/example/todolist/task/TaskRepository.kt"
    click DAO "https://github.com/matthewleigh/to-do-list/blob/main/app/src/main/java/com/example/todolist/task/TaskDao.kt"
    click DB "https://github.com/matthewleigh/to-do-list/blob/main/app/src/main/java/com/example/todolist/database/AppDatabase.kt"
    click Converters "https://github.com/matthewleigh/to-do-list/blob/main/app/src/main/java/com/example/todolist/database/AppDatabaseConverters.kt"
    click Table "https://github.com/matthewleigh/to-do-list/blob/main/app/src/main/java/com/example/todolist/task/TaskTable.kt"
    click Adapter "https://github.com/matthewleigh/to-do-list/blob/main/app/src/main/java/com/example/todolist/task/TaskAdapter.kt"
```
