danwel - Entry/Task Management System

Comprehensive task and project management functionality within danwel.

---

Table of Contents



1. [Overview](#overview)
2. [Entry Model](#entry-model)
3. [Comments System](#comments-system)
4. [Labels System](#labels-system)
5. [API Endpoints](#api-endpoints)
6. [Frontend Integration](#frontend-integration)
7. [GitHub Integration](#github-integration)

---

Overview

The Entry system in danwel extends beyond simple time tracking to provide full project management capabilities. Entries represent tasks, issues, or work items that can be tracked, commented on, labeled, and linked to time blocks.

Key Features



  • • **Task Management** - Create, update, and track work items

  • • **Time Estimation** - Set and track time estimates vs actual time spent

  • • **Status Tracking** - Track progress through different states

  • • **Priority System** - Set and manage task priorities

  • • **Comments** - Team collaboration through threaded comments

  • • **Labels** - Organize and categorize entries with flexible labels

  • • **GitHub Integration** - Link entries to GitHub issues and repositories

  • • **Time Tracking** - Connect entries to time blocks for accurate billing
  • ---

    Entry Model



    Core Fields



    // Entry model attributes
    $entry = [
    'id' => 1,
    'organization_id' => 1,
    'project_id' => 1,
    'created_by' => 1,
    'title' => 'Implement user authentication',
    'description' => 'Add OAuth and 2FA support',
    'status' => 'in_progress',
    'priority' => 'high',
    'time_estimate' => 480, // minutes
    'is_archived' => false,
    'github_issue_number' => 42,
    'github_issue_url' => 'https://github.com/org/repo/issues/42',
    'created_at' => '2024-01-01T00:00:00Z',
    'updated_at' => '2024-01-01T00:00:00Z'
    ];


    Status Values



    | Status | Description |
    |--------|-------------|
    | todo | Not started |
    | in_progress | Currently being worked on |
    | review | Ready for review |
    | done | Completed |
    | blocked | Blocked by dependencies |

    Priority Values



    | Priority | Description |
    |----------|-------------|
    | low | Nice to have |
    | medium | Standard priority |
    | high | Important task |
    | urgent | Critical/urgent |

    ---

    Comments System



    Comment Model



    // EntryComment model
    $comment = [
    'id' => 1,
    'entry_id' => 1,
    'user_id' => 1,
    'content' => 'This needs to be updated to include WebAuthn',
    'created_at' => '2024-01-01T00:00:00Z',
    'updated_at' => '2024-01-01T00:00:00Z'
    ];


    Features



  • • **Rich Text Content** - Supports markdown formatting

  • • **User Attribution** - Track who made each comment

  • • **Timestamps** - Created and updated timestamps

  • • **Organization Scoped** - Comments are isolated by organization
  • ---

    Labels System



    Label Model



    // Label model
    $label = [
    'id' => 1,
    'organization_id' => 1,
    'name' => 'bug',
    'color' => '#ef4444',
    'created_at' => '2024-01-01T00:00:00Z'
    ];


    Features



  • • **Flexible Tagging** - Create custom labels for organization

  • • **Color Coding** - Visual categorization with custom colors

  • • **Many-to-Many** - Entries can have multiple labels

  • • **Organization Scoped** - Labels are private to each organization


  • Common Label Examples



    $commonLabels = [
    ['name' => 'bug', 'color' => '#ef4444'],
    ['name' => 'feature', 'color' => '#10b981'],
    ['name' => 'enhancement', 'color' => '#3b82f6'],
    ['name' => 'documentation', 'color' => '#8b5cf6'],
    ['name' => 'urgent', 'color' => '#f59e0b'],
    ['name' => 'backend', 'color' => '#6b7280'],
    ['name' => 'frontend', 'color' => '#ec4899']
    ];

    ---

    API Endpoints



    Entry Endpoints



    ``http
    GET /api/entries # List entries with filters
    POST /api/entries # Create new entry
    GET /api/entries/{id} # Get single entry
    PUT /api/entries/{id} # Update entry
    DELETE /api/entries/{id} # Delete entry

    POST /api/entries/{id}/toggle-status # Toggle between todo/done
    POST /api/entries/{id}/toggle-priority # Cycle through priorities
    PUT /api/entries/{id}/time-estimate # Update time estimate
    POST /api/entries/{id}/archive # Archive entry

    Comment Endpoints


    http
    GET /api/entries/{id}/comments # List comments for entry
    POST /api/entries/{id}/comments # Add comment to entry
    PUT /api/comments/{id} # Update comment
    DELETE /api/comments/{id} # Delete comment

    Label Endpoints


    http
    GET /api/labels # List all labels
    POST /api/labels # Create label
    PUT /api/labels/{id} # Update label
    DELETE /api/labels/{id} # Delete label

    POST /api/entries/{id}/labels # Attach label to entry
    PUT /api/entries/{id}/labels # Sync entry labels
    DELETE /api/entries/{id}/labels/{label_id} # Remove label from entry

    Example API Responses



    **List Entries:**
    json
    {
    "data": [
    {
    "id": 1,
    "title": "Implement user authentication",
    "description": "Add OAuth and 2FA support",
    "status": "in_progress",
    "priority": "high",
    "time_estimate": 480,
    "project": {
    "id": 1,
    "name": "Web App v2"
    },
    "created_by": {
    "id": 1,
    "name": "John Doe"
    },
    "labels": [
    {
    "id": 1,
    "name": "feature",
    "color": "#10b981"
    }
    ],
    "comments_count": 3,
    "time_blocks_count": 2,
    "total_time_spent": 240,
    "github_issue_number": 42,
    "created_at": "2024-01-01T00:00:00Z"
    }
    ],
    "meta": {
    "total": 1,
    "per_page": 20,
    "current_page": 1
    }
    }

    ---

    Frontend Integration



    Entry List View

    The entries are displayed in /tasks route with:

  • • **Kanban Board** - Visual status columns (Todo, In Progress, Review, Done)

  • • **Filtering** - By status, priority, labels, assignee

  • • **Search** - Full-text search across title and description

  • • **Quick Actions** - Status toggle, priority change, archive


  • Entry Detail View

    Individual entries show:

  • • **Full Description** - Rich text with markdown support

  • • **Metadata** - Status, priority, time estimate, GitHub links

  • • **Comments Thread** - Real-time comments with user avatars

  • • **Labels** - Visual tag display with colors

  • • **Time Tracking** - Associated time blocks and total time spent

  • • **Activity Timeline** - History of changes and updates


  • Blade Templates



    // Entry list page
    Route::get('/tasks', [SettingsController::class, 'tasks'])->name('tasks');

    // Entry detail view (documents)
    Route::get('/documents/{entry}', [SettingsController::class, 'showDocument'])
    ->name('documents.show');

    ---

    GitHub Integration



    Linking Entries to GitHub Issues

    Entries can be linked to GitHub issues through:

    1. **Manual Linking** - Enter GitHub issue URL or number
    2. **Automatic Import** - Sync from connected GitHub repositories
    3. **Webhook Updates** - Real-time updates from GitHub events

    Synchronized Data



    | GitHub Field | Entry Field |
    |--------------|-------------|
    |
    issue.title | title |
    |
    issue.body | description |
    |
    issue.number | github_issue_number |
    |
    issue.html_url | github_issue_url |
    |
    issue.state | status (mapped) |
    |
    issue.labels | labels (synced) |

    Status Mapping



    | GitHub State | Entry Status |
    |--------------|--------------|
    |
    open | todo or in_progress |
    |
    closed | done |

    Webhook Processing

    GitHub webhooks automatically update entries when:

  • • Issue is created/updated/closed

  • • Issue labels are changed

  • • Issue is assigned/unassigned

  • • Comments are added to issue
  • ---

    Database Schema



    Entries Table


    sql
    CREATE TABLE entries (
    id BIGINT UNSIGNED PRIMARY KEY AUTO_INCREMENT,
    organization_id BIGINT UNSIGNED NOT NULL,
    project_id BIGINT UNSIGNED NULL,
    created_by BIGINT UNSIGNED NOT NULL,
    title VARCHAR(255) NOT NULL,
    description TEXT NULL,
    status ENUM('todo', 'in_progress', 'review', 'done', 'blocked') DEFAULT 'todo',
    priority ENUM('low', 'medium', 'high', 'urgent') DEFAULT 'medium',
    time_estimate INT NULL, -- in minutes
    is_archived BOOLEAN DEFAULT FALSE,
    github_issue_number INT NULL,
    github_issue_url VARCHAR(255) NULL,
    created_at TIMESTAMP NULL,
    updated_at TIMESTAMP NULL,

    FOREIGN KEY (organization_id) REFERENCES organizations(id) ON DELETE CASCADE,
    FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE SET NULL,
    FOREIGN KEY (created_by) REFERENCES users(id) ON DELETE CASCADE,
    INDEX idx_org_status (organization_id, status),
    INDEX idx_project_status (project_id, status)
    );

    Entry Comments Table


    sql
    CREATE TABLE entry_comments (
    id BIGINT UNSIGNED PRIMARY KEY AUTO_INCREMENT,
    entry_id BIGINT UNSIGNED NOT NULL,
    user_id BIGINT UNSIGNED NOT NULL,
    content TEXT NOT NULL,
    created_at TIMESTAMP NULL,
    updated_at TIMESTAMP NULL,

    FOREIGN KEY (entry_id) REFERENCES entries(id) ON DELETE CASCADE,
    FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE,
    INDEX idx_entry_created (entry_id, created_at)
    );

    Labels Table


    sql
    CREATE TABLE labels (
    id BIGINT UNSIGNED PRIMARY KEY AUTO_INCREMENT,
    organization_id BIGINT UNSIGNED NOT NULL,
    name VARCHAR(100) NOT NULL,
    color VARCHAR(7) NOT NULL, -- hex color
    created_at TIMESTAMP NULL,
    updated_at TIMESTAMP NULL,

    FOREIGN KEY (organization_id) REFERENCES organizations(id) ON DELETE CASCADE,
    UNIQUE INDEX idx_org_name (organization_id, name)
    );

    Entry Labels Pivot Table


    sql
    CREATE TABLE entry_labels (
    id BIGINT UNSIGNED PRIMARY KEY AUTO_INCREMENT,
    entry_id BIGINT UNSIGNED NOT NULL,
    label_id BIGINT UNSIGNED NOT NULL,
    created_at TIMESTAMP NULL,

    FOREIGN KEY (entry_id) REFERENCES entries(id) ON DELETE CASCADE,
    FOREIGN KEY (label_id) REFERENCES labels(id) ON DELETE CASCADE,
    UNIQUE INDEX idx_entry_label (entry_id, label_id)
    );

    ---

    Usage Examples



    Creating an Entry with Labels


    javascript
    // Create entry
    const entry = await fetch('/api/entries', {
    method: 'POST',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify({
    title: 'Fix login bug',
    description: 'Users cannot log in with Google OAuth',
    status: 'todo',
    priority: 'high',
    project_id: 1,
    time_estimate: 120
    })
    });

    // Add labels
    await fetch(
    /api/entries/${entry.id}/labels, {
    method: 'POST',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify({
    label_ids: [1, 3] // bug, urgent labels
    })
    });

    Adding Comments


    javascript
    await fetch(
    /api/entries/${entryId}/comments, {
    method: 'POST',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify({
    content: 'I found the issue - it\'s in the OAuth callback handler.'
    })
    });

    Filtering Entries


    javascript
    // Get entries by status and label
    const entries = await fetch('/api/entries?' + new URLSearchParams({
    status: 'in_progress',
    labels: 'bug,urgent',
    project_id: 1
    }));
    ``

    ---

    This entry system provides comprehensive task management capabilities that integrate seamlessly with danwel's time tracking and project management features.