Product EngineeringFeaturesTask ManagerBackend

Overview

Backend implementation overview for Task Manager in crelio-app.

👤 Akshay Goregaonkar📅 Updated: May 4, 2026🏷️ feature🏷️ backend🏷️ task-management

Task Manager — Backend

All server-side logic lives in crelio-app/services/task_manager. The feature provides a comprehensive task management system with different task types, assignment capabilities, attachments, logging, and references to various entities.


What this section covers

PageCovers
Data ModelMigration files, Task, TaskType, TaskAttachment, TaskLog, TaskReference models
API ReferenceTask creation, listing, updates, assignments, attachments, and comments endpoints
Comments & MentionsCentralized comment creation, task comment fetching, attachments, and mention support

Architecture


Proxy architecture

The Task Manager uses Django proxy models to implement task-type-specific behavior while keeping a single Task database table.

  • services/task_manager/utils/constants.py maps task type IDs to proxy classes:
    • TaskType.TASK_TYPE_PERSONAL_TASKPersonalTask
    • TaskType.TASK_TYPE_REPORT_EXCEPTIONReportExceptionTask
    • TaskType.TASK_TYPE_SAMPLE_EXCEPTIONSampleExceptionTask
  • TaskCreateView resolves the proxy via get_task_type_child_class(task_type_id).
  • TaskUpdateView and TaskResolveView restore proxy behavior on existing tasks with cast_to_task_type_child(task).

Each proxy class implements specialized task creation behavior through:

  • validate_initialize(context)
  • prepare_title()
  • prepare_description()
  • prepare_default_reporter_and_assignee()
  • prepare_references()

Shared lifecycle behavior lives in services/task_manager/proxies/abstract_task.py, including create_task(), open(), close(), and add_references().


Task lifecycle

The Task Manager lifecycle is generic at the Task model level and customizable through proxy classes.

  1. Create
    • TaskCreateView receives task_type_id and context
    • It resolves the right proxy and calls create_task(context)
    • AbstractTask.create_task() validates inputs, initializes metadata, saves the Task, and persists references
  2. Update / Assign
    • TaskUpdateView loads the task, casts it to the proxy class, applies field updates, and saves
    • Supports title, description, assignee_id, org_id, status, and reference add/remove operations
    • self-assign routes the current session user as assignee
  3. Resolve
    • TaskResolveView uses close(updated_by_lab_user_id) to set status = RESOLVED, record resolved_at, and store who closed it
  4. Reopen
    • AbstractTask.open() resets status = OPEN and clears resolved_at

Status transitions follow the expected workflow: OPENIN_PROGRESSRESOLVED.


Key files

FileRole
services/task_manager/migrations/0001_initial.pyInitial schema — Task, TaskType, TaskAttachment, TaskLog, TaskReference models
services/task_manager/migrations/0002_task_updated_by_doctor_task_updated_by_lab_user_and_more.pyAdded updated_by fields and task log enhancements
services/task_manager/models/task.pyMain Task model with statuses, assignees, reporters
services/task_manager/proxies/Task type proxies for different task categories
services/task_manager/views/API endpoints for task operations
services/task_manager/serializers/Data serialization for API responses

On this page