Here is the refactored job queue system organized into a clean, modular package structure:

```
queue/
├── __init__.py      # Exports: JobQueue, Job
├── core.py          # Job dataclass, basic queue operations
├── priority.py      # Priority queue implementation
└── retry.py         # Retry logic with exponential backoff
```

---

### `queue/__init__.py`
```python
"""
Job Queue Package

Provides a modular job queue system with priority support and retry logic.
"""

from queue.core import Job, JobQueue
from queue.retry import process_with_retry

__all__ = ["Job", "JobQueue", "process_with_retry"]
__version__ = "1.0.0"
```

---

### `queue/core.py`
```python
"""
Core Job Queue Implementation

Defines the Job dataclass and basic queue operations.
"""

from dataclasses import dataclass, field
from datetime import datetime
from typing import Optional, Callable, Any
from queue.priority import PriorityQueue


@dataclass
class Job:
    """Represents a job to be processed."""
    id: str
    task: Callable
    args: tuple = ()
    kwargs: dict = field(default_factory=dict)
    priority: int = 0  # Higher = more urgent
    created_at: datetime = field(default_factory=datetime.utcnow)
    retry_count: int = 0
    max_retries: int = 3
    status: str = "pending"  # pending, running, completed, failed
    result: Any = None
    error: Optional[str] = None

    def __lt__(self, other):
        return self.priority > other.priority

    def is_ready(self):
        return self.status == "pending"

    def mark_running(self):
        self.status = "running"

    def mark_completed(self, result=None):
        self.status = "completed"
        self.result = result

    def mark_failed(self, error: str):
        self.status = "failed"
        self.error = error


class JobQueue:
    """Basic queue managing job execution."""

    def __init__(self):
        self._priority_queue = PriorityQueue()

    def enqueue(self, job: Job) -> None:
        """Add a job to the queue."""
        if job.is_ready():
            self._priority_queue.push(job)

    def dequeue(self) -> Optional[Job]:
        """Remove and return the highest priority job."""
        return self._priority_queue.pop() if not self._priority_queue.is_empty() else None

    def get_next_job(self) -> Optional[Job]:
        """Peek at the next job without removing it."""
        return self._priority_queue.peek() if not self._priority_queue.is_empty() else None

    def size(self) -> int:
        """Return the number of jobs in the queue."""
        return self._priority_queue.size()

    def is_empty(self) -> bool:
        """Check if the queue is empty."""
        return self._priority_queue.is_empty()

    def process(self, job: Job) -> None:
        """Process a job."""
        job.mark_running()
        try:
            result = job.task(*job.args, **job.kwargs)
            job.mark_completed(result)
        except Exception as e:
            job.mark_failed(str(e))
```

---

### `queue/priority.py`
```python
"""
Priority Queue Implementation

A min-heap based priority queue for efficient job scheduling.
"""

import heapq
from typing import List, Optional, Any


class PriorityQueue:
    """Priority queue based on heapq."""

    def __init__(self):
        self._heap: List[Any] = []

    def push(self, item: Any) -> None:
        """Push an item onto the queue."""
        heapq.heappush(self._heap, item)

    def pop(self) -> Optional[Any]:
        """Pop the highest priority item."""
        return heapq.heappop(self._heap) if self._heap else None

    def peek(self) -> Optional[Any]:
        """Peek at the highest priority item."""
        return self._heap[0] if self._heap else None

    def is_empty(self) -> bool:
        """Check if the queue is empty."""
        return len(self._heap) == 0

    def size(self) -> int:
        """Return the number of items in the queue."""
        return len(self._heap)
```

---

### `queue/retry.py`
```python
"""
Retry Logic with Exponential Backoff

Handles job retrying with configurable backoff strategy.
"""

import time
from typing import Callable, Optional, Any
from queue.core import Job


def calculate_backoff(attempt: int, base: float = 1.0, max_delay: float = 300.0) -> float:
    """Calculate exponential backoff delay."""
    delay = base * (2 ** attempt)
    return min(delay, max_delay)


def process_with_retry(job: Job, executor: Callable[[Job], Any], max_attempts: Optional[int] = None) -> bool:
    """
    Process a job with automatic retry on failure.

    Args:
        job: The job to process.
        executor: Function that executes the job.
        max_attempts: Override max_retries if set.

    Returns:
        True if the job succeeded, False otherwise.
    """
    attempts = max_attempts or job.max_retries
    for attempt in range(attempts):
        try:
            executor(job)
            return True
        except Exception as e:
            job.retry_count = attempt + 1
            job.error = str(e)
            if attempt < attempts - 1:
                backoff = calculate_backoff(attempt)
                time.sleep(backoff)

    return False
```

---

### Example Usage
```python
from queue import Job, JobQueue, process_with_retry

def my_task(x, y):
    return x + y

job = Job(
    id="001",
    task=my_task,
    args=(3, 4),
    priority=5
)

queue = JobQueue()
queue.enqueue(job)

success = process_with_retry(job, lambda j: j.mark_completed(j.task(*j.args, **j.kwargs)))
print("Job succeeded:", success)
```

---

### Summary of Responsibilities

| Module      | Responsibility                              |
|-------------|---------------------------------------------|
| `__init__.py` | Public API exports                          |
| `core.py`     | Job model and queue logic                   |
| `priority.py` | Heap-based priority queue                   |
| `retry.py`    | Retry logic with exponential backoff        |

This modular design ensures maintainability, testability, and scalability while preserving all original functionality.