Metadata-Version: 2.4
Name: taskdog-core
Version: 0.18.6
Summary: Core business logic and infrastructure for Taskdog
Author: Kohei Wada
License: MIT
Project-URL: Homepage, https://github.com/Kohei-Wada/taskdog
Project-URL: Repository, https://github.com/Kohei-Wada/taskdog
Project-URL: Bug Tracker, https://github.com/Kohei-Wada/taskdog/issues
Keywords: task,management,scheduling
Classifier: Development Status :: 4 - Beta
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Requires-Python: >=3.12
Description-Content-Type: text/markdown
Requires-Dist: alembic>=1.13.0
Requires-Dist: holidays>=0.60.0
Requires-Dist: sqlalchemy>=2.0.0
Provides-Extra: dev
Requires-Dist: pytest>=7.0.0; extra == "dev"
Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
Requires-Dist: mypy>=1.0.0; extra == "dev"
Requires-Dist: ruff>=0.7.0; extra == "dev"

# taskdog-core

Core business logic and infrastructure for Taskdog task management system.

## Overview

This package contains the core components shared by both the Taskdog server and UI:

- **Domain Layer**: Business entities, domain services, and interfaces
- **Application Layer**: Use cases, queries, DTOs, and business logic orchestration
- **Infrastructure Layer**: Persistence implementations, external service integrations
- **Controllers**: Business logic orchestrators used by presentation layers

## Installation

```bash
pip install taskdog-core
```

For development:

```bash
pip install -e ".[dev]"
```

## Architecture

Follows Clean Architecture principles:

```text
Domain (entities, services, repositories)
  ↑
Application (use cases, queries, DTOs)
  ↑
Infrastructure (SQLite, file storage)
  ↑
Controllers (orchestration layer)
```

### Key Components

**Domain Layer** (`taskdog_core/domain/`):

- `Task` - Core entity with status, priority, deadlines, dependencies
- `TaskStatus` - PENDING, IN_PROGRESS, COMPLETED, CANCELED
- `TimeTracker` - Records actual_start/actual_end timestamps
- `TaskNotFoundException`, `TaskValidationError` - Domain exceptions

**Application Layer** (`taskdog_core/application/`):

- **Use Cases**: CreateTaskUseCase, StartTaskUseCase, OptimizeScheduleUseCase, etc.
- **Validators**: TaskFieldValidatorRegistry with Status and Dependency validators
- **Services**: WorkloadAllocator, OptimizationSummaryBuilder, TaskQueryService
- **Optimization**: 9 scheduling strategies (greedy, balanced, backward, priority_first, earliest_deadline, round_robin, dependency_aware, genetic, monte_carlo)

**Infrastructure Layer** (`taskdog_core/infrastructure/`):

- `SqliteTaskRepository` - SQLite persistence with transactional writes
- `SqliteNotesRepository` - Database-based notes storage
- `ConfigManager` - TOML configuration loading

**Controllers** (`taskdog_core/controllers/`):

- `TaskCrudController` - Create, update, delete operations
- `TaskLifecycleController` - Start, complete, pause, cancel, reopen
- `TaskRelationshipController` - Dependencies and tags
- `TaskAnalyticsController` - Statistics and optimization
- `QueryController` - Read-only operations

## Usage Example

```python
from taskdog_core.domain.entities.task import Task, TaskStatus
from taskdog_core.infrastructure.persistence.database.sqlite_task_repository import SqliteTaskRepository
from taskdog_core.controllers.task_crud_controller import TaskCrudController
from taskdog_core.infrastructure.config.config_manager import ConfigManager
# Setup
repository = SqliteTaskRepository("sqlite:///tasks.db")
config = ConfigManager()

# Create controller
crud_controller = TaskCrudController(repository, notes_repository, config)

# Create a task
from taskdog_core.application.dto.task_request import CreateTaskRequest
request = CreateTaskRequest(name="My Task", priority=100)
task = crud_controller.create_task(request)
```

## Dependencies

- `holidays`: Holiday checking for scheduling
- `python-dateutil`: Date/time utilities
- `sqlalchemy`: Database ORM

## Related Packages

- [taskdog-server](../taskdog-server/): FastAPI REST API server using this package
- [taskdog-ui](../taskdog-ui/): CLI and TUI interfaces using this package
- [taskdog-client](../taskdog-client/): HTTP client library for API access

For detailed architecture documentation, see [CLAUDE.md](../../CLAUDE.md).

## Testing

```bash
pytest tests/
```

## License

MIT
