Skip to content

Ankana2929/task-analyzer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Smart Task Analyzer

A lightweight task analysis system built with Django REST Framework and HTML/CSS/JavaScript.
It evaluates tasks based on importance, effort, deadline urgency, and dependencies, then returns:

  • Priority scores
  • Sorted task lists
  • Top task suggestions
  • Explanations
  • Circular dependency detection

🚀 Features

  • REST API for analyzing and suggesting tasks
  • Weighted scoring system
  • Circular dependency detection (DFS-based)
  • Input validation & error handling
  • Clean HTML/CSS/JS frontend
  • Custom sorting strategies
  • Unit-tested backend

📦 Tech Stack

  • Backend: Django, Django REST Framework
  • Frontend: HTML, CSS, Vanilla JavaScript
  • Tools: CORS Headers, Python venv

📁 Project Structure

Task-Analyzer/ │ ├── backend/ # Django Backend │ ├── backend/ │ │ ├── settings.py │ │ ├── urls.py │ │ └── ... │ ├── tasks/ │ │ ├── views.py │ │ ├── serializers.py │ │ ├── scoring.py │ │ ├── tests.py │ │ └── ... │ ├── manage.py │ └── requirements.txt │ └── frontend/ # Simple Frontend ├── index.html ├── styles.css └── script.js

⚙️ Backend Setup (Django)

1. Create Virtual Environment

python -m venv venv
# 2. Activate It
 //Windows:

venv\Scripts\activate

//Mac/Linux:

source venv/bin/activate

# 3. Install Dependencies

pip install -r requirements.txt

//If you built manually:

pip install django djangorestframework django-cors-headers
pip freeze > requirements.txt

# 4. Run Backend

cd backend
python manage.py runserver

# Backend URL:

http://127.0.0.1:8000/

#  API Endpoints/

1️⃣ POST /api/tasks/analyze/
Returns all tasks sorted by priority score.

# ✔ Sample Request

[
  {
    "id": "1",
    "title": "Fix login bug",
    "due_date": "2025-11-30",
    "estimated_hours": 3,
    "importance": 9,
    "dependencies": []
  },
  {
    "id": "2",
    "title": "Write documentation",
    "due_date": "2025-12-05",
    "estimated_hours": 2,
    "importance": 6,
    "dependencies": ["1"]
  }
]
# ✔ Sample Response

[
  {
    "id": "1",
    "title": "Fix login bug",
    "score": 7.3,
    "due_date": "2025-11-30",
    "importance": 9,
    "estimated_hours": 3,
    "dependencies": []
  },
  {
    "id": "2",
    "title": "Write documentation",
    "score": 5.1,
    "due_date": "2025-12-05",
    "importance": 6,
    "estimated_hours": 2,
    "dependencies": ["1"]
  }
]
# 2️⃣ POST /api/tasks/suggest/
Returns top 3 most important tasks with explanations.

✔ Sample Response

[
  {
    "id": "1",
    "title": "Fix login bug",
    "score": 7.3,
    "due_date": "2025-11-30",
    "importance": 9,
    "estimated_hours": 3,
    "reason": "High importance, Low effort (quick to finish)"
  }
]

#  Scoring Logic (tasks/scoring.py)
Tasks are scored using these factors:

✔ 1. Importance
Higher score → more important.

✔ 2. Effort (estimated hours)
Lower hours → higher score.

✔ 3. Deadline urgency
Earlier deadlines → added priority.

✔ 4. Dependency value
If a task unblocks many others → higher score.

The system creates a combined weighted score using all these attributes.

#  Dependency Graph & Cycle Detection
// Dependencies form a directed graph:

A → B means “A depends on B”.

The system uses DFS + color marking to detect cycles.

✔ Sample Error Response:

{
  "error": "Circular dependency detected",
  "cycles": [
    ["1", "2", "3", "1"]
  ]
}

# Validation & Error Handling
//The backend ensures://

    -> importance between 1 and 10

    -> estimated_hours ≥ 0

    -> due_date valid YYYY-MM-DD

    -> No duplicate IDs

    ->Unknown dependency IDs are rejected

Cycles are detected

Empty lists are rejected

//Example error message://


{
  "estimated_hours": ["Estimated hours cannot be negative."]
}
# Tests (Backend)
Run tests:

python manage.py test

//Tests cover://

    ->scoring logic

    ->analyze endpoint

    ->suggest endpoint

    ->cycle detection

# Frontend (Lightweight HTML/CSS/JS)
Located in /frontend.

# Features:
✔ Add tasks one-by-one
✔ Paste raw JSON
✔ Analyze tasks
✔ Suggest top tasks
✔ Color-coded priority
✔ Sorting strategies:

-Smart balance

-Fastest wins

-High impact

-Deadline-driven

// Starting the Frontend //

Using VS Code Live Server:

    -> Right-click index.html

    -> Click "Open with Live Server"

    -> Opens at:

http://127.0.0.1:5500/frontend/index.html

# Frontend Output Preview
Each task shows:

    -> Title

    -> Score

    -> Importance

    -> Estimated hours

    -> Due date

    -> Reason

Priority badge with color

    -> 🔴 High (red)

    -> 🟠 Medium (yellow)

    -> 🟢 Low (green)

#  How to Run Everything Together
-->Start Backend:

cd backend
python manage.py runserver

-->Start Frontend (Live Server):

frontend/index.html

-->Then:

    -> Add tasks

    -> Or paste JSON

    -> Click Analyze or Suggest

# Future Extensions
    -> User authentication

    -> Save tasks in database

    -> Editable tasks in frontend

    -> Task search/filter

    -> Dependency graph visualization

About

Task prioritization tool using Smart Scoring, Django backend, and HTML, CSS, clean JS frontend.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published