# lilbunnyrabbit/task-manager architecture

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

- Interactive diagram: https://gitdiagram.com/lilbunnyrabbit/task-manager
- Repository: https://github.com/lilbunnyrabbit/task-manager

## Overview

##### Project Type & Purpose
- This is a TypeScript-based task orchestration library that provides a framework to create, group, and manage both synchronous and asynchronous tasks.
- Its purpose is to allow users to compose tasks (via Task, TaskGroup, and TaskManager components), define execution flows (sequential or parallel), and track progress with error handling and logging.
- Additionally, there is a “web” directory dedicated to API documentation and examples, demonstrating the use cases and providing a UI overview for the library.

##### Analyzing the File Structure
- The project is modularly organized:
- The “src” directory contains the core logic split into several modules:
▸ “common” for shared utilities such as logging, error handling (TaskError, TasksError), and basic types.
▸ “core” is subdivided into clearly defined areas:
- Flow Controller (orchestrates execution flow)
- Task, TaskGroup, and TaskManager modules that implement the primary API.
- Task Query – likely used for querying task state or logs.
- Configuration files (package.json, tsconfig.json, etc.) and testing scripts are also clearly present.
- The “web” folder holds the documentation site, styling, examples, and a separate package configuration, which indicates that the project provides a consumer-facing UI for its docs and demos.

##### Main Components to Represent & Their Relationships
- Core Functionalities:
- Task: Represents a unit of work with an execution method, progress tracking, logging, and error handling.
- TaskGroup: Bundles together a collection of tasks, providing a means to structure workflows and define execution order.
- TaskManager: Acts as the central orchestrator, adding tasks or groups, starting execution, tracking progress, and handling state resets or failures.
- Flow Controller: Likely governs the execution flow, managing sequential versus parallel task execution.
- Shared Utilities:
- Logger: Provides logging capabilities shared across modules.
- Error Handling: Centralized management of task errors (TaskError, TasksError).
- Task Query: Interface used by components to query logs, state, or results.
- Web Documentation / UI:
- The “web” module serves as the front-end documentation and example UI. It visually represents the API and provides interactive examples of how to use the task manager.
- External Dependencies:
- Libraries such as @lilbunnyrabbit/event-emitter, @lilbunnyrabbit/optional, and @lilbunnyrabbit/utils are complementary and support additional features like event management and utility functions.

##### Architectural Patterns & Design Principles
- Separation of Concerns: Core business logic is separated from shared utilities (in “common”) and the front-end documentation/examples (in “web”).
- Component-Based & Modular Organization: Code is split into well-defined modules (e.g., task, task-group, task-manager) facilitating reusability and maintainability.
- Type Safety: The entire system is implemented in TypeScript, revolving around typed interfaces and definitions.
- Composable Workflows: The design supports building tasks into groups and passing them to a central manager for execution.
- Configurability & Extensibility: Build scripts, configuration files (tsconfig, package, etc.) and external modules (via npm) indicate that the system is designed to be easily extended or integrated.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Core Modules Subgraph
    subgraph "Core Modules"
        TM["TaskManager"]:::core
        TG["TaskGroup"]:::core
        T["Task"]:::core
        FC["FlowController"]:::core
        TQ["TaskQuery"]:::core
    end

    %% Utilities Subgraph
    subgraph "Utilities"
        L["Logger"]:::utilities
        TE["TaskError"]:::utilities
        TSE["TasksError"]:::utilities
    end

    %% Web Documentation Subgraph
    subgraph "Web Documentation"
        WD["Web Documentation & UI"]:::web
    end

    %% External Dependencies Subgraph
    subgraph "External Dependencies"
        EL["External Libraries"]:::external
    end

    %% Core relationships
    TM -->|"manages"| TG
    TM -->|"manages"| T
    TG -->|"contains"| T
    FC -->|"coordinates"| TM
    T -->|"queries"| TQ
    TG -->|"queries"| TQ
    T -->|"error_propagate"| TM
    TG -->|"error_propagate"| TM

    %% Dependencies on Utilities
    T -->|"logs"| L
    TG -->|"logs"| L

    %% External Dependencies usage
    TM -->|"uses"| EL
    T -->|"uses"| EL
    TG -->|"uses"| EL
    FC -->|"uses"| EL

    %% Web Documentation consumes API from Core
    WD -->|"consumes_API_from"| TM

    %% Click Events
    click T "https://github.com/lilbunnyrabbit/task-manager/blob/master/src/core/task/task.ts"
    click TG "https://github.com/lilbunnyrabbit/task-manager/blob/master/src/core/task-group/task-group.ts"
    click TM "https://github.com/lilbunnyrabbit/task-manager/blob/master/src/core/task-manager/task-manager.ts"
    click FC "https://github.com/lilbunnyrabbit/task-manager/blob/master/src/core/flow-controller/flow-controller.ts"
    click L "https://github.com/lilbunnyrabbit/task-manager/blob/master/src/common/logger/logger.ts"
    click TE "https://github.com/lilbunnyrabbit/task-manager/blob/master/src/common/task-error.ts"
    click TSE "https://github.com/lilbunnyrabbit/task-manager/blob/master/src/common/tasks-error.ts"
    click TQ "https://github.com/lilbunnyrabbit/task-manager/blob/master/src/core/task-query/task-query.ts"
    click WD "https://github.com/lilbunnyrabbit/task-manager/tree/master/web"

    %% Styles
    classDef core fill:#add8e6,stroke:#000,stroke-width:1px;
    classDef utilities fill:#98fb98,stroke:#000,stroke-width:1px;
    classDef web fill:#ffcccb,stroke:#000,stroke-width:1px;
    classDef external fill:#d3d3d3,stroke:#000,stroke-width:1px;
```
