# TodoAI - AI-Powered Task Manager

A terminal-based task manager with AI-powered task analysis and organization.

## Features

- Terminal User Interface (TUI) for managing tasks
- AI-powered task analysis (priority, category, time estimates)
- Background analysis during idle hours
- Task searching and filtering
- Multiple AI model support with fallback mechanisms
- SQLite database with connection pooling
- Configurable via environment variables

## Installation

### Prerequisites

- Go 1.21 or higher
- SQLite3
- Ollama (for AI analysis)

### Building from source

1. Clone the repository:

```bash
git clone https://github.com/your-username/todo
cd todo
```

2. Install dependencies:

```bash
make install-deps
```

3. Build the application:

```bash
make build
```

### Using Docker

Build and run with Docker:

```bash
make docker-build
make docker-run
```

## Configuration

The application can be configured using environment variables:

### Database Settings

- `DB_PATH`: Path to SQLite database (default: "todoai.db")
- `DB_MAX_OPEN_CONNS`: Maximum open connections (default: 25)
- `DB_MAX_IDLE_CONNS`: Maximum idle connections (default: 5)
- `DB_CONN_MAX_LIFETIME`: Connection lifetime in minutes (default: 5)

### AI Settings

- `AI_MODEL_NAME`: Name of the AI model (default: "deepseek-r1:latest")
- `AI_PROVIDER`: AI provider (default: "ollama")
- `AI_API_KEY`: API key for AI service (if required)

### UI Settings

- `UI_THEME`: UI theme (default: "default")
- `UI_REFRESH_INTERVAL`: Task list refresh interval in seconds (default: 60)
- `UI_IDLE_START_HOUR`: Start hour for background analysis (default: 22)
- `UI_IDLE_END_HOUR`: End hour for background analysis (default: 6)
- `UI_MAX_DISPLAY_TASKS`: Maximum tasks to display (default: 100)

## Usage

### Keyboard Shortcuts

- `n`: New task
- `/`: Search tasks
- `TAB`: Toggle completed tasks
- `c`: Complete selected task
- `q` or `Ctrl+C`: Quit
- `ESC`: Cancel current action
- `Enter`: Select/confirm

## Development

### Running Tests

```bash
make test
```

### Code Quality

```bash
make lint
```

### Pre-commit Checks

```bash
make pre-commit
```

## Project Structure

```
.
├── src/
│   ├── ai/          # AI analysis functionality
│   ├── config/      # Configuration management
│   ├── database/    # Database operations
│   ├── models/      # Data models
│   └── ui/          # Terminal UI
├── main.go          # Application entry point
├── Dockerfile       # Container configuration
└── Makefile        # Build and development tasks
```

## Contributing

1. Fork the repository
2. Create a feature branch
3. Make your changes
4. Run tests and linting (`make pre-commit`)
5. Submit a pull request

## License

MIT License - see LICENSE file for details
